平均からの乖離
公開日:
:
マネー
平均(移動平均線)からの乖離をトレードシグナルにしていらっしゃる人が結構います。
ということで、乖離率を表示するインディケーターを自作してみました。
ついでに、乖離率の移動平均であるシグナルも表示します。
乖離率の計算に使用する移動平均線の種類も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);
}
//+------------------------------------------------------------------+
###
関連記事
-
-
2023/3/1 外国債券(既発債)続伸中
以前の記事「2023/2/22 外国債券が調子良い」で書きましたが、まだまだ米国の金利が上がりそうだ
-
-
[FX] 無限回廊act1 バグなしバージョン
以前、MT4用のFX自動売買ソフト「無限回廊」システムact1 のバグありお試しバージョンを公開して
-
-
[FX] QQE の問題点
QQE は RSI のみから作られるオシレーター 前回の記事「PLATINUM TURBO FX
-
-
[FX]yasciiHA04a 実戦投入
昨日タイムフィルタの話をしましたが、そこで検証したシステム・・・平均足クロスシステムにクラウドフ
-
-
【FX】エターナルエンジンという EA(2)
以前に紹介した MQL5 フォーラムで 599$で販売されている Eternal Engine とい
-
-
簡単な平均足システム (2)
以前の記事「簡単な平均足システム」で作った簡単な平均足システムを改良してみました。 改良その1
-
-
【FX】AXI Select のドル口座が動作を開始
AXI という海外FX業者はスプレッドが狭くて、なかなか気に入っています。 現在、円建ての口座 3
-
-
[FX]yasciiHA04a パラメーター変更
以前の記事「yasciiHA04a 実戦投入」の続きです。先週金曜日は指標発表のため EA は止
-
-
東京五輪PRに 12億円
あのPRがたった 12億円 リオ五輪閉会式で流された 東京五輪のPR(ビデ
-
-
今はETF投資の方がリスクは低くリターンが高い
登録していつも観ている Youtube チャンネル「とも'sチャンネル」の本日のビデオ のタ







