平均からの乖離
公開日:
:
マネー
平均(移動平均線)からの乖離をトレードシグナルにしていらっしゃる人が結構います。
ということで、乖離率を表示するインディケーターを自作してみました。
ついでに、乖離率の移動平均であるシグナルも表示します。
乖離率の計算に使用する移動平均線の種類も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 利回りランキング 2020-11-24 版
本日たまたま見つけたサイト(↓)に載っていた表です。 >高分配金ETF(海外):
-
-
iFreeレバレッジ NASDAQ100 購入開始しました
iFreeレバレッジ NASDAQ100 は昨日から買付を始めた投資信託で、日本の大和投資信
-
-
【FX】Black Diamond V4 という EA
Black Diamond V4 という EA については以前も触れました。 最新の Blac
-
-
富裕層ビジネス 成功の秘訣 / 中谷 彰宏
富裕層ビジネス 成功の秘訣 中谷 彰宏 ぜんにち出版 2006-07
-
-
2015年2月アメリカ雇用統計
昨日のドル円相場です。 すごいでしょ。昇り龍みたいですね。 第一金曜日の夜は毎月恒例のア
-
-
[FX] EA は24時間起動してね
以前の記事の「私のやり方」の補足です。 私の作ったものはそうですが、そうでない EA もほとん
-
-
年末FXトレーディング
下は 11/10 から今日までの USDJPN の 1時間足です。 12/8 まで長期の円安ト
-
-
【FX】Silent Falcon という EA
本日見つけた FX 自動売買ソフト(EA)です。 私のいうバースト系(急激な価格変動をトリガー
-
-
CEPI / REX クリプト・エクイティ・プレミアム・インカムETF
昨年の 12月から日本で売られている まだ1年経っていない新しい ETF に CEPI というものが
-
-
【FX】 スリーラインストライク EA
昨日の記事「スリーラインストライク」ですが、人間心理を表したプライスアクションなので確度が高いと言わ







