平均からの乖離
公開日:
:
マネー
平均(移動平均線)からの乖離をトレードシグナルにしていらっしゃる人が結構います。
ということで、乖離率を表示するインディケーターを自作してみました。
ついでに、乖離率の移動平均であるシグナルも表示します。
乖離率の計算に使用する移動平均線の種類も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);
}
//+------------------------------------------------------------------+
###
関連記事
-
-
不思議な AXI Select
AXI Select は海外FXブローカーの Axi が提供する参加費無料のプロップトレードプログラ
-
-
【FX】VantageTrading という海外業者
わたしのようにスキャルピングやデイトレが主体のものにとっては、スプレッドが狭い業者を選ぶのは最も重要
-
-
【FX】Titan Scalper という EA
情報が少ないのですが、最近調子のよさそうな EA を見つけました。 Titan Scalper
-
-
FXトレード 2014/1/5
うちのマックトリプルバーガーと名づけた EA(自動売買プログラム)のトレードですが、早速ビビ
-
-
Schaff Trend Cycle について
Schaff Trend Cycle は私の好きな指標の一つで、MACD のストキャスをストキャ
-
-
2020/10/28 アメリカ株3日連続の下げ
コロナがまたぶり返しているのと、大統領選直前ということでなのか、アメリカ株の「暴落」が3日連続してい
-
-
【FX】Hippo Trader という EA(8)
以前の記事「【FX】Hippo Trader という EA(7)」の続きです。 この EA は
-
-
損するはずのない投資
下はみなさん大好き NISA 対象の円建て投資信託 eMAXIS Slim 米国株式(S&P
-
-
【FX】2本の EMA と 1本の CCI を使う EA
昨日の記事「2本の CCI をフィルタに使う EA」では、短期と中期の CCI を0より上か下かとい
-
-
【FX】Fintokei ステップ1終了
FX プロップファームの Fintokei(フィントケイ)のパール コースのチャレンジ1ステップが昨







