平均からの乖離
公開日:
:
マネー
平均(移動平均線)からの乖離をトレードシグナルにしていらっしゃる人が結構います。
ということで、乖離率を表示するインディケーターを自作してみました。
ついでに、乖離率の移動平均であるシグナルも表示します。
乖離率の計算に使用する移動平均線の種類も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);
}
//+------------------------------------------------------------------+
###
関連記事
-
-
Bollinger BandWidth について
ボリンジャーバンド Bollinger Band という、投資家にとってはなくてはならないものが
-
-
【FX】現在主力の AA(仮称)という自動売買プログラム
現在、リアル口座でも主力として使っている自動売買プログラム(EA)は AA(仮称)というプログラムで
-
-
FXの教科書 / 松田 哲
FXの教科書 松田 哲 扶桑社 2008-03-01 売り上げランキング
-
-
[FX] ボリンジャーバンド順張りシンプル版
昨日読んだ本「FX ボリンジャーバンド常勝のワザ / 山中康司」に触発されて、もっともシンプルなボリ
-
-
クラウドフィルタ考案
一目均衡表は大好きですが、それで使われるミステリアスな雲をフィルタにしてみようと思いつきました。
-
-
2025年株式投資 簡単すぎる総括
本日で今年の投資は終わりです。 楽天銀行の現在高は以上のとおり。 上出来です。 で
-
-
【FX】Han という EA
これも蔵から引っ張り出してきた EA です。Best Scalper と同じく 2年くらい前に入手し
-
-
【FX】AXI Select 20日目
AXI Select とは AXI Select とは AXI という海外FX業者がみずから行って
-
-
[FX] 新たな Tokyo Boxプログラム(2)
先日作製した Tokyo Boxプログラムは、少しずつ改良を加えていますが、まだまだ暫定的。
-
-
日本政府「国の借金」過去最大の1039兆円
別に私が言うことではありませんが・・・ ネタ元> 日本経済新聞「国の借金」、過去最大の1039







