平均からの乖離
公開日:
:
マネー
平均(移動平均線)からの乖離をトレードシグナルにしていらっしゃる人が結構います。
ということで、乖離率を表示するインディケーターを自作してみました。
ついでに、乖離率の移動平均であるシグナルも表示します。
乖離率の計算に使用する移動平均線の種類も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】ゴールドの実質コスト
昨日のゴールド(証拠金取引;いわゆる XAUUSD のこと)のスプレッドを調べてみました。 海外F
-
-
【FX】TitanFX はデモ口座開設が簡単
TitanFX のブレード口座は最良というわけではありませんが、そこそこスプレッド&手数料が安く、ス
-
-
【FX】ボリンジャーバンド順張りの EA(改良)
ボリンジャーバンドは順張りで使えと、ボリンジャーさんは草葉の陰で唱えています。あ、まだ存命中でしたか
-
-
[FX] 2015/4/13 EA 緊急停止 トレンドが消失
昨日は週明けの月曜日ということもあり、通常よりも夜間の仕事が多めで、夜12時ごろまで仕事をしてい
-
-
FEPI / REX ファング&イノベーション・エクイティ・プレミアム・インカムETF
今日は REX社の高配当ETF の残りの1つである、FEPI(REX ファング&イノベーショ
-
-
[FX] 勝率を上げる zero trailing
勝率を上げる一つの方法を思いついたので、EA に組み込んでみました。 いえ、裁量ではしょっちゅ
-
-
津島式FXシステムトレード入門 / 津島朋憲
津島式FXシステムトレード入門 posted with amazlet at
-
-
スローな TII にしてくれ
TII をさらに使いやすくする方法を考えました。 下のチャートのサブウィンドウに3種類の TI
-
-
[FX]前週の平均値と順張り&逆張り EA化(7) サマータイム
以前の記事「前週の平均値と順張り&逆張り EA化(4) GBPJPY版のみ始動 」で、ぼちぼちリ
-
-
KOSPI ベアETN が熱い (2)
「KOSPI ベアETN が熱い 」の続きです。 KOSPI ベアETN とは韓国の株







