昨日の記事の続きです。
[MT4インジケータ]21本高値安値には意味がある?周期高値安値インジケータ
昨日のインジケータに中心線を追加してみましょう。
上昇トレンドの場合は、中心線より上に値が来ますし、下降トレンドの際には中心線より下にきます。レンジのばあいには中心線を間に行ったり来たりという感じですね。高値安値の中心線は短期波形成分をキャンセルした線としても捉えることができます。高値・安値更新中の際には、移動平均より機敏に反応しますので、トレンドの変化点としても移動平均より早めに検知できる可能性があります。
しっかり波形が出ている相場の場合は、中間値を超えた時点で高値ラインまでの上昇を見込めます。
また、次の動き出しに前に、高値安値が同時に狭まる現象が発生します。三角持合い時などに発生します。このように単純ですが、高値安値ラインはいろいろ見どころのあるインジケータです。
//------------------------------------------------------------------
// 高値 安値ライン表示インジケータ
#property copyright "Copyright 2015, Daisuke"
#property link "http://mt4program.blogspot.jp/"
#property version "1.00"
#property strict
#property indicator_chart_window
// 円周率
#define PI 3.14159265359
//バッファーを指定する。
#property indicator_buffers 3
//プロット数を指定する。
#property indicator_plots 3
#property indicator_label1 "HIGH"
#property indicator_type1 DRAW_LINE
#property indicator_color1 clrAqua
#property indicator_style1 STYLE_SOLID
#property indicator_width1 2
#property indicator_label2 "LOW"
#property indicator_type2 DRAW_LINE
#property indicator_color2 clrIndianRed
#property indicator_style2 STYLE_SOLID
#property indicator_width2 2
#property indicator_label3 "CENTER"
#property indicator_type3 DRAW_LINE
#property indicator_color3 clrYellow
#property indicator_style3 STYLE_SOLID
#property indicator_width3 2
extern int Period = 13;
double highBuffer[];
double lowBuffer[];
double centerBuffer[];
//------------------------------------------------------------------
//初期化
int OnInit()
{
//インジケーターバッファを初期化する。
SetIndexBuffer(0,highBuffer);
SetIndexBuffer(1,lowBuffer);
SetIndexBuffer(2,centerBuffer);
SetIndexDrawBegin(0, Period);
SetIndexDrawBegin(1, Period);
SetIndexDrawBegin(2, Period);
string short_name = "HIGHLOW(" + IntegerToString(Period) + ")";
IndicatorShortName(short_name);
return(INIT_SUCCEEDED);
}
//------------------------------------------------------------------
//計算イベント
int OnCalculate(const int rates_total, //各レート要素数
const int prev_calculated, //計算済み要素数
const datetime &time[], //要素ごとの時間配列
const double &open[], //オープン価格配列
const double &high[], //高値配列
const double &low[], //安値配列
const double &close[], //クローズ価格配列
const long &tick_volume[], //ティック数(要素の更新回数)
const long &volume[], //実ボリューム(?)
const int &spread[]) //スプレット
{
for( int i = (rates_total - prev_calculated - 1); i >= 0 && !IsStopped(); i-- )
{
if( i >= rates_total - Period ) continue;
int highest = iHighest( NULL, PERIOD_CURRENT, MODE_HIGH, Period, i + 1);
int lowest = iLowest( NULL, PERIOD_CURRENT, MODE_LOW, Period, i + 1);
highBuffer[i] = high[highest];
lowBuffer[i] = low[lowest];
centerBuffer[i] = (highBuffer[i] + lowBuffer[i] ) / 2;
}
//元となる値を計算する。
return(rates_total);
}
//+------------------------------------------------------------------+