平均からの乖離
公開日:
:
マネー
平均(移動平均線)からの乖離をトレードシグナルにしていらっしゃる人が結構います。
ということで、乖離率を表示するインディケーターを自作してみました。
ついでに、乖離率の移動平均であるシグナルも表示します。
乖離率の計算に使用する移動平均線の種類も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】東京仲値トレード(2)
以前にも書いたのですが、東京仲値トレード という有名なトレード法があります。 仲値とは、その国
-
-
RYLD はどうだ?
昨日の記事「QYLD が有望?」ですが、QYLD は ナスダック100の ETF を買ってデリバティ
-
-
早起きは5pipsの得 (2)
本日は休日だということに朝7時に気づきました。^^ 前回の記事で紹介した「早起きは5pipsの
-
-
【FX】AXI Select 25日め
各FX業者から毎日メールで各口座の報告書が来ます。 あ、月報も月に 1回来ます。 昨日、AX
-
-
2019/9/16 ユーロ円下げにお付き合い
今回のもう一つの FX取引は EURUSD。 ユーロドルは月足、週足、日足、1時間足ど
-
-
日経平均史上最高値 さらに上放れかも?
日経平均が最高値をまた超えました。 本日の終値は 41580円。 日足チャートでは ちょ
-
-
日本年金機構からのお尋ね
先日、日本年金機構からのお尋ねなる封書が来ていました。 私の過去の共済年金記録の欠落部分につい
-
-
【FX】EA詐欺について
EA詐欺という言葉を聞いたことがないでしょうか。 EA とは自動売買プログラムのこと。
-
-
[FX] HL Band(High Low Band) について(2)
以前の記事「HL Band(High Low Band) について 」で書きましたが、HL band







