スポンサーリンク
検索

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


iMomentum


モメンタムインジケータを計算し、その値を返します。


関数書式:
double  iMomentum(
   string       symbol,        // 通貨ペア
   int          timeframe,     // 時間軸
   int          period,        // 平均期間
   int          applied_price, // 適用価格
   int          shift          // シフト
   );



■引数
引数名 初期値 I/O 詳細
symbol - In インジケータ計算するデータの通貨ペア名。
NULLは現在の通貨ぺアを意味します。
timeframe - In 時間軸。
ENUM_TIMEFRAMES列挙の値を指定します。
0は現在の時間軸を意味します。
period - In メインラインを計算をする平均期間
applied_price - In 適用価格。
ENUM_APPLIED_PRICE列挙の値を指定します
shift - In インジケータバッファから取得する値のインデックス。
(現在バーを基準にして、指定した時間軸のバー数分を過去方向へシフト)


■戻り値
モメンタムインジケータ計算値を返します。



■備考
無し

サンプルソース:
    double result = iMomentum(
                                 NULL,           // 通貨ペア
                                 0,              // 時間軸
                                 12,             // 平均期間
                                 PRICE_CLOSE,  // 適用価格
                                 1               // シフト
                                );


サンプルソース:
#property strict // strictは絶対に削除しない事
#property indicator_separate_window // カスタムインジケータをサブウインドウに表示する

// インジケータプロパティ設定
#property  indicator_buffers    1               // カスタムインジケータのバッファ数
#property  indicator_color1     clrRed         // インジケータ1の色
#property  indicator_type1      DRAW_LINE     // インジケータ1の描画スタイル

// インジケータ表示用動的配列
double     _IndBuffer1[];                          // インジケータ1表示用動的配列

//+------------------------------------------------------------------+
//| OnInit(初期化)イベント
//+------------------------------------------------------------------+
int OnInit()
{
   SetIndexBuffer( 0, _IndBuffer1 );     // インジケータ1表示用動的配列をインジケータ1にバインドする

   return( INIT_SUCCEEDED );      // 戻り値:初期化成功
}

//+------------------------------------------------------------------+
//| 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 end_index = Bars - prev_calculated;  // バー数取得(未計算分)

    for( int icount = 0 ; icount < end_index ; icount++ ) {

        // テクニカルインジケータ算出
        double result = iMomentum(
                                     NULL,           // 通貨ペア
                                     0,              // 時間軸
                                     12,             // 平均期間
                                     PRICE_CLOSE,  // 適用価格
                                     icount // シフト
                                    ); 


       _IndBuffer1[icount] = result;   // インジケータ1に算出結果を設定
    }

   return( rates_total ); // 戻り値設定:次回OnCalculate関数が呼ばれた時のprev_calculatedの値に渡される
}






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


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


Top

inserted by FC2 system