引数名 | 初期値 | I/O | 詳細 |
index | - | In | インジケータバッファインデックス
指定範囲は0~7です。 |
shift | - | In | バーのシフト数
|
// インジケータウインドウ設定 #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 ExIndLine25shift[100]; // インジケータバッファ2:ライン用 //+------------------------------------------------------------------+ //| OnInit(初期化)イベント | //|------------------------------------------------------------------| void OnInit() { SetIndexBuffer(0,ExIndLine25); // ExIndVol25をインジケータ1に登録 SetIndexBuffer(1,ExIndLine25shift); // ExIndVol75をインジケータ2に登録 SetIndexStyle(0,DRAW_LINE); // インジケータスタイルをラインに設定 SetIndexStyle(1,DRAW_LINE); // インジケータスタイルをラインに設定 SetIndexLabel(0,"SMA:25"); // インジケータ1のラベル設定 SetIndexLabel(1,"SMA:25shift"); // インジケータ2のラベル設定 SetIndexShift(1,10); // インジケータ2を10(バー数)シフトして描画 } //+------------------------------------------------------------------+ //| 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); ExIndLine25shift[icount] = ExIndLine25[icount]; } return(rates_total); }