平均からの乖離
公開日:
:
マネー
平均(移動平均線)からの乖離をトレードシグナルにしていらっしゃる人が結構います。
ということで、乖離率を表示するインディケーターを自作してみました。
ついでに、乖離率の移動平均であるシグナルも表示します。
乖離率の計算に使用する移動平均線の種類も4種類から選べるようにしました。
サブウィンドウが乖離率です。
え、ボリンジャーバンドを見るから要らない!?
プログラムソース
//+------------------------------------------------------------------+
//| yasciiKairi01.mq4
//+------------------------------------------------------------------+
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Orange
#property indicator_color2 Violet
#property indicator_level1 0
//---- input parameters
extern int MA_period = 20;
extern int Sig_period = 9;
extern int MA_method = 0; // SMA(0), EMA(1), SMMA(2), LWMA(3)
//---- buffers
double kairi[];
double kairiX[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
IndicatorBuffers(2);
IndicatorShortName("Kairi(" + MA_period + ")");
SetIndexStyle(0, DRAW_LINE);
SetIndexBuffer(0, kairi);
SetIndexBuffer(1, kairiX);
SetIndexStyle(1, DRAW_LINE);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars = IndicatorCounted();
int i, j, limit ;
// to prevent possible error
if(counted_bars < 0)
{
return(-1);
}
if(MA_method >= 4)
{
MA_method = 0;
}
limit = Bars - counted_bars;
for(i = limit - MA_period ; i >= 0; i--)
{
double sma20 = iMA(NULL, 0, MA_period, 0 , MA_method , PRICE_CLOSE, i) ;
kairi[i] = 100.0 * (Close[i]- sma20) / sma20 ;
}
for(j = limit - MA_period - Sig_period; j >= 0; j--)
{
kairiX[j] = iMAOnArray(kairi,0,Sig_period,0,MODE_EMA,j);
}
return(0);
}
//+------------------------------------------------------------------+
###
関連記事
-
-
[FX] たった1本の移動平均線でスイングトレード
できるだけ物事は簡単なほうがいいと思っている人が多いでしょうが、私もその末席におります。 一番
-
-
幸せな経済自由人の金銭哲学 マネー編 / 本田健(4)
幸せな経済自由人の金銭哲学 マネー編 (ゴマ文庫) 本田 健 ゴマブックス
-
-
私の投資信託の買い方
私の投資信託の買い方ですが、毎月5万円ほど定額積立をしている以外の、スポット買いの方法をお示しします
-
-
確定申告やっと終わり
昨日は確定申告書の作成に時間が掛かり、ブログ更新ができませんでした。 本日郵便局から郵送。
-
-
【FX】ThreeTrader の Rawゼロ口座は最強
以前の記事「ThreeTrader で新たなタイプの口座を開いてみる」で述べた海外FX業者の Thr
-
-
アメリカ株投資 2021-7-2
「アメリカ株投資 2021-6-26」の続きです。 前回は 130万円を超えたと言いま
-
-
【FX】 Hunter Scalper 1.10 という EA(2)
「【FX】 Hunter Scalper 1.10 という EA」の続きです。 この Hunt
-
-
FX トレード 2014/11/19 日中
本日もリアルトレード。 今日は自宅。仕事はヒマなのでチャートを眺めながら仕事中。 昨日持ち越
-
-
QQE を使った自動売買ソフト
QQE という RSI を元にした指標がありまして、結構精度が高いので気になっていました。 オ
-
-
ミニPC(NipoGi AK1plus-n97)にて 10ケの MT4 を動作させる
Intel N97 CPU を積んだミニ PCの NipoGi AK1plus-n97 ですが、現在







