平均からの乖離
公開日:
:
マネー
平均(移動平均線)からの乖離をトレードシグナルにしていらっしゃる人が結構います。
ということで、乖離率を表示するインディケーターを自作してみました。
ついでに、乖離率の移動平均であるシグナルも表示します。
乖離率の計算に使用する移動平均線の種類も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);
}
//+------------------------------------------------------------------+
###
関連記事
-
-
今はETF投資の方がリスクは低くリターンが高い
登録していつも観ている Youtube チャンネル「とも'sチャンネル」の本日のビデオ のタ
-
-
新生銀行 ATM使用料無料
* みなさんのお住まいのところは銀行は近いのでしょうか。 もし遠ければ新生銀行の口座でも作られてはい
-
-
[FX] 15分足スキャルピング自動運転プログラム(2)
昨日の記事の 「15分足スキャルピング自動運転プログラム」は、トレンドのないときと正の向きのトレンド
-
-
FOOD & LIFE COMPANIES の株式を 100株取得しました
本日、渦中のスシローを傘下に持つ FOOD & LIFE COMPANIES(3563)を
-
-
私の高配当株投資法の変遷について
最近、超高配当の投資信託を利用しだしてから、想定内のことと想定外のことがありました。 まず、先
-
-
【FX】3本の RCI を使った自動売買プログラム (3)
「 3本の RCI を使った自動売買プログラム (2)」の続きです。 少し改良を加えてみました
-
-
幸せな経済自由人の金銭哲学 マネー編 / 本田健(4)
幸せな経済自由人の金銭哲学 マネー編 (ゴマ文庫) 本田 健 ゴマブックス
-
-
【FX】Han という EA
これも蔵から引っ張り出してきた EA です。Best Scalper と同じく 2年くらい前に入手し
-
-
CEPI / REX クリプト・エクイティ・プレミアム・インカムETF
昨年の 12月から日本で売られている まだ1年経っていない新しい ETF に CEPI というものが
-
-
FX に対する向き合い方
外国為替取引(FX)に対する私の認識です。 個人の意見なので気に入らない人は無視してください。







