平均からの乖離
公開日:
:
マネー
平均(移動平均線)からの乖離をトレードシグナルにしていらっしゃる人が結構います。
ということで、乖離率を表示するインディケーターを自作してみました。
ついでに、乖離率の移動平均であるシグナルも表示します。
乖離率の計算に使用する移動平均線の種類も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】Connect Safe Forex EA
ちょっと気になる自動売買ソフト(EA)をまた見つけてしまいました。 「Connect EA 3
-
-
【FX】エターナルエンジンという EA(2)
以前に紹介した MQL5 フォーラムで 599$で販売されている Eternal Engine とい
-
-
アンディさんのリアルタイム雲
上が一目均衡表で、雲は26本先行しています。 下は有名なト
-
-
アメリカ株投資 2021-6-26
「アメリカ株投資 2021-6-15」の続きです。 純益 が 120万円台から上抜けて
-
-
投資商品乗り換え完了
ようやく2月くらいから始めた 投資信託+日本株の入れ替えが完了しました。 2月
-
-
伝説のトレーダー集団 タートル流投資の魔術 / カーティス・フェイス
伝説のトレーダー集団 タートル流投資の魔術 カーティス・フェイス 飯尾博信+常
-
-
【FX】CrownPrince という EA
CrownPrince という EA があります。 これも 4年前に入手したもので、パフォーマンス
-
-
投資における AI の利用 分析
投資商品が増えてくると管理がめんどくさいですよね。 楽天証券から今年の配当金データを CSV
-
-
ガチ速FX / 及川圭哉 (2)
ガチ速FX 27分で256万を稼いだ“鬼デイトレ” posted with a
-
-
アメリカ長期債券ETF への移行(まだ先は長い)
この前、ナマの債券(個別の債券)を全部売却した話をしました。 債券を全部売却(売却益ありま







