トップ  >  MQL4リファレンス  >  カスタムインジケータ  >  SetIndexDrawBegin
スポンサーリンク
検索

↑の検索エンジンが表示されない人は、
↓の古い検索エンジンを使用して下さい。
カスタム検索
MQL4リファレンスツリー
SetIndexDrawBegin


SetIndexDrawBegin


インジケータライン描画開始し始めるバー番号を設定します


関数書式:
void  SetIndexDrawBegin(
   int     index,       // インジケータバッファインデックス
   int     begin        // 位置
   );



■引数
引数名 初期値 I/O 詳細
index - In インジケータバッファインデックス
指定範囲は0~7です。
begin - In 描画開始するバー位置。
0指定時は全てのデータが描画されます


■戻り値
無し



■備考
インジケータは左から右へ描画されます。
指定したバー位置より左側のインジケータは描画されません。

サンプルソース:
// インジケータウインドウ設定
#property  indicator_chart_window          // インジケータをチャートウインドウに表示

// インジケータ設定
#property  indicator_buffers   2                // インジケータバッファ:2つに設定
#property  indicator_color1    clrYellow       // インジケータ1の色:黄色
#property  indicator_color2    clrWhite       // インジケータ1の色:白
#property  indicator_width1    1                // インジケータ1の太さ:1
#property  indicator_width2    2                // インジケータ1の太さ:2


double ExIndLine25[100];                           // インジケータバッファ1:ライン用
double ExIndLine75[100];                           // インジケータバッファ2:ライン用

//+------------------------------------------------------------------+
//| OnInit(初期化)イベント                         |
//|------------------------------------------------------------------|
void OnInit()
{
    SetIndexBuffer(0,ExIndLine25);              // ExIndVol25をインジケータ1に登録
    SetIndexBuffer(1,ExIndLine75);              // ExIndVol75をインジケータ2に登録

    SetIndexStyle(0,DRAW_LINE);              // インジケータスタイルをラインに設定
    SetIndexStyle(1,DRAW_LINE);              // インジケータスタイルをラインに設定

    SetIndexDrawBegin(0,0);                   // インジケータ1を全て描画
    SetIndexDrawBegin(1,Bars - 50);           // インジケータ2を先頭50本目のバーから描画開始
}


//+------------------------------------------------------------------+
//| OnCalculate(tick受信)イベント                              |
//+------------------------------------------------------------------+
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[],  // Tick出来高
                const long&     volume[],       // Real出来高
                const int&      spread[])       // スプレッド
{
    int icount = 0;
    int icountend;
    
    icountend = rates_total -  prev_calculated;
    if ( icountend >= rates_total ) {
        icountend = rates_total - 1;
    }

    for( icount = 0; icount <= icountend ; icount++ ) {
        ExIndLine25[icount]  = iMA(NULL,0,25,0,MODE_SMA,PRICE_CLOSE,icount);
        ExIndLine75[icount]  = iMA(NULL,0,75,0,MODE_SMA,PRICE_CLOSE,icount);
    }


    return(rates_total);
}








スポンサーリンク
スポンサーリンク


Copyright ©2015 MT4でEA自作しちゃお~ All Rights Reserved.


Top

inserted by FC2 system