MT4toJForexInd.mq4

注意事項:
サンプルソースコードには実際にオーダーを発注するものがあります。
サンプルソースコードのストラテジーを起動する場合は、注意して下さい。



//+------------------------------------------------------------------+
//|                                               MT4toJForexInd.mq4
//|
//| MetaEditor build 1601で作成。
//| インプットのMA_periodに対応したSMAインジケータをチャートウインドウに描画する
//|
//+------------------------------------------------------------------+
#property strict
#property indicator_chart_window

#property indicator_buffers 1

double        MA_buff[];            // MAバッファ

input    int  MA_period = 25;        // MA期間

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping

    SetIndexBuffer(0, MA_buff);
    SetIndexEmptyValue(0, 0);
    SetIndexLabel( 0, "MA-" + (String)MA_period );
    SetIndexStyle( 0, DRAW_LINE, STYLE_SOLID, 1 , clrAqua ); 
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
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[])
  {
//---

    int    icount;
    int    icount_end;
    
    icount_end = rates_total - prev_calculated + 1;           // 計算済みのインジケータは更新しない

    for ( icount = 0; icount <= icount_end; icount++ ) {
        if ( icount >= Bars ) {
            break;
        }

        MA_buff[icount] = iMA(
                        Symbol(),        // 通貨ペア
                        Period(),        // 時間軸
                        MA_period,       // MAの平均期間
                        0,               // MAシフト
                        MODE_SMA,        // MAの平均化メソッド
                        PRICE_CLOSE,     // 適用価格
                        icount           // シフト
                        );
    }
    

//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+


■MT4で使用


■MQLコンバーターでコンパイルしJForexで使用




スポンサーリンク

スポンサーリンク
検索
リファレンスツリー


Copyright ©2016 JForexAPIで自動売買させ隊! All Rights Reserved.


Top

inserted by FC2 system