iAC
この関数はクライアント端末のグローバルキャッシュに Accelerator Oscillator ( AC オシレーター)を作成してハンドルを返します。バッファは 1 つです。
int  iAC(  string          symbol,      ENUM_TIMEFRAMES  period        );  | 
パラメータ
symbol
[in] データが指標計算に使用される有価証券の銘柄名(NULL は現在のシンボル)
period
[in] 期間の値は ENUM_TIMEFRAMES 列挙の値の 1 つで、0 は現在の時間軸の意味です。
戻り値
例:
//+——————————————————————+  //|                                                     Demo_iAC.mq5 |  //|                        Copyright 2011, MetaQuotes Software Corp. |  //|                                             https://www.MQL5.com |  //+——————————————————————+  #property copyright “Copyright 2011, MetaQuotes Software Corp.”  #property link     “https://www.mql5.com”  #property version   “1.00”  #property description “The indicator demonstrates how to obtain data”  #property description “of indicator buffers for the iAC technical indicator.”  #property description “A symbol and timeframe used for calculation of the indicator,”  #property description “are set by the symbol and period parameters.”  #property description “The method of creation of the handle is set through the ‘type’ parameter (function type).” #property indicator_separate_window  #property indicator_buffers 2  #property indicator_plots   1  //— iAC のプロット  #property indicator_label1 “iAC”  #property indicator_type1   DRAW_COLOR_HISTOGRAM  #property indicator_color1  clrGreen, clrRed  #property indicator_style1 STYLE_SOLID  #property indicator_width1  1  //+——————————————————————+  //| 作成を処理する方法の列挙                                              |  //+——————————————————————+  enum Creation  {  Call_iAC,               // iAC を使用する  Call_IndicatorCreate   // IndicatorCreateを使用する  };  //— 入力パラメータ  input Creation             type=Call_iAC;         // 関数の種類  input string               symbol=” “;             // シンボル  input ENUM_TIMEFRAMES     period=PERIOD_CURRENT; // 時間軸  //— 指標バッファ  double iACBuffer[];  double iACColors[];  //— iAC 指標ハンドルを格納する変数  int    handle;  //— 格納に使用される変数  string name=symbol;  //— チャートでの指標名  string short_name;  //— ACオシレーター指標に値の数を保存  int    bars_calculated=0;  //+——————————————————————+  //| カスタム指標を初期化する関数                                            |  //+——————————————————————+  int OnInit()  {  //— 配列の指標バッファへの割り当て  SetIndexBuffer(0,iACBuffer,INDICATOR_DATA);  SetIndexBuffer(1,iACColors,INDICATOR_COLOR_INDEX);  //— 指標が描画するシンボルを決める  name=symbol;  //— 左右のスペースを削する  StringTrimRight(name);  StringTrimLeft(name);  //—「name」文字列の長さがゼロになった場合  if(StringLen(name)==0)  {  //— 指標が接続されているチャートのシンボルを取る  name=_Symbol;  }  //— 指標ハンドルを作成する  if(type==Call_iAC)  handle=iAC(name,period);  else  handle=IndicatorCreate(name,period,IND_AC);  //— ハンドルが作成されなかった場合  if(handle==INVALID_HANDLE)  {  //— 失敗した事実とエラーコードを出力する  PrintFormat(“Failed to create handle of the iAC indicator for the symbol %s/%s, error code %d”,  name,  EnumToString(period),  GetLastError());  //— 指標が早期に中止された  return(INIT_FAILED);  }  //— ACオシレーターが計算された銘柄/時間軸を表示  short_name=StringFormat(“iAC(%s/%s)”,name,EnumToString(period));  IndicatorSetString(INDICATOR_SHORTNAME,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[])  {  //— iAC 指標から複製された値の数  int values_to_copy;  //— 指標で計算された値の数を決める  int calculated=BarsCalculated(handle);  if(calculated<=0)  {  PrintFormat(“BarsCalculated() returned %d, error code %d”,calculated,GetLastError());  return(0);  }  //— これが指標計算の初めであるか iAC 指標の値の数が変更した  //—または、2 つ以上のバーの指標の計算が必要である場合(価格履歴で何かが変更された)  if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1)  {  //— もし iACBuffer 配列が銘柄/期間で iAC 指標の値の数より大きい場合、全体のコピーはしない  //— 他の場合、指標バッファサイズより少ない量をコピーをする  if(calculated>rates_total) values_to_copy=rates_total;  else                       values_to_copy=calculated;  }  else  {  //— これは初回の計算ではなく、  //— 前回の OnCalculate() から、一以上のバーが加えられてない。  values_to_copy=(rates_total-prev_calculated)+1;  }  //— ACオシレーター指標の値で iACBuffer と iACColors 配列を記入する  //— FillArraysFromBuffer が false を返した場合、情報の準備が終わっていないので操作を終了する  if(!FillArraysFromBuffer(iACBuffer,iACColors,handle,values_to_copy)) return(0);  //— メッセージを形成する  string comm=StringFormat(“%s ==>  Updated value in the indicator %s: %d”,  TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS),  short_name,  values_to_copy);  //— チャートにサービスメッセージを表示する  Comment(comm);  //— ACオシレーター指標の値の数を覚える  bars_calculated=calculated;  //— prev_calculated 値を次の関数呼び出しのために返す  return(rates_total);  }  //+——————————————————————+  //| iAC 指標から指標バッファを記入する                                        |  //+——————————————————————+  bool FillArraysFromBuffer(double &values[],       // ACオシレーター値の指標バッファ  double &color_indexes[], // 色のバッファ(色インデックスを格納)  int ind_handle,         // iAC 指標ハンドル  int amount               // 複製された値の数  )  {  //— エラーコードをリセットする  ResetLastError();  //— インデックス0 を持つ指標バッファの値で iACBuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,0,0,amount,values)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iAC indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— 色インデックスを複製する  if(CopyBuffer(ind_handle,1,0,amount,color_indexes)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy color values from the iAC indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— 全てが成功  return(true);  }  //+——————————————————————+  //| 指標初期化解除関数                                                  |  //+——————————————————————+  void OnDeinit(const int reason)  {  //— 指標の削除後チャートをクリアする  Comment(“”);  }  | 
iAD
この関数は Accumulation(蓄積)/ Distribution(分配)指標ハンドルを返します。バッファは 1 つです。
int  iAD(  string              symbol,              ENUM_TIMEFRAMES      period,              ENUM_APPLIED_VOLUME  applied_volume        );  | 
パラメータ
symbol
[in] データが指標計算に使用される有価証券の銘柄名(NULL は現在のシンボル)
period
[in] 期間の値は ENUM_TIMEFRAMES 列挙の値の 1 つで、0 は現在の時間軸の意味です。
applied_volume
[in]  使用されるボリューム(ENUM_APPLIED_VOLUME 値のいずれか)
戻り値
例:
//+——————————————————————+  //|                                                     Demo_iAD.mq5 |  //|                        Copyright 2011, MetaQuotes Software Corp. |  //|                                             https://www.MQL5.com |  //+——————————————————————+  #property copyright “Copyright 2011, MetaQuotes Software Corp.”  #property link     “https://www.mql5.com”  #property version   “1.00”  #property description “The indicator demonstrates how to obtain data”  #property description “of indicator buffers for the iAD technical indicator.”  #property description “A symbol and timeframe used for calculation of the indicator,”  #property description “are set by the symbol and period parameters.”  #property description “The method of creation of the handle is set through the ‘type’ parameter (function type).” #property indicator_separate_window  #property indicator_buffers 1  #property indicator_plots   1  //— iAD をプロットする  #property indicator_label1 “iAD”  #property indicator_type1   DRAW_LINE  #property indicator_color1  clrLightSeaGreen  #property indicator_style1 STYLE_SOLID  #property indicator_width1  1  //+——————————————————————+  //| 作成を処理する方法の列挙                                              |  //+——————————————————————+  enum Creation  {  Call_iAD,               // iAD を使用する  Call_IndicatorCreate   // IndicatorCreateを使用する  };  //— 入力パラメータ  input Creation             type=Call_iAD;         // 型の関数   input ENUM_APPLIED_VOLUME  volumes;               // 使用されるボリューム  input string               symbol=” “;             // シンボル  input ENUM_TIMEFRAMES     period=PERIOD_CURRENT; // 時間軸  //— 指標バッファ  double         iADBuffer[];  //— iAD 指標ハンドルを格納する変数  int    handle;  //— 格納に使用される変数  string name=symbol;  //— チャートでの指標名  string short_name;  //— A/D 指標に値の数を保存  int    bars_calculated=0;  //+——————————————————————+  //| カスタム指標を初期化する関数                                            |  //+——————————————————————+  int OnInit()  {  //— 配列の指標バッファへの割り当て  SetIndexBuffer(0,iADBuffer,INDICATOR_DATA);  //— 指標が描画するシンボルを決める  name=symbol;  //— 左右のスペースを削する  StringTrimRight(name);  StringTrimLeft(name);  //—「name」文字列の長さがゼロになった場合  if(StringLen(name)==0)  {  //— 指標が接続されているチャートのシンボルを取る  name=_Symbol;  }  //— 指標ハンドルを作成する  if(type==Call_iAD)  handle=iAD(name,period,volumes);  else  {  //— 構造体を指標のパラメータで記入  MqlParam pars[1];  pars[0].type=TYPE_INT;  pars[0].integer_value=volumes;  handle=IndicatorCreate(name,period,IND_AD,1,pars);  }  //— ハンドルが作成されなかった場合  if(handle==INVALID_HANDLE)  {  //— 失敗した事実とエラーコードを出力する  PrintFormat(“Failed to create handle of the iAD indicator for the symbol %s/%s, error code %d”,  name,  EnumToString(period),  GetLastError());  //— 指標が早期に中止された  return(INIT_FAILED);  }  //— A/D が計算された銘柄/時間軸を表示  short_name=StringFormat(“iAD(%s/%s)”,name,EnumToString(period));  IndicatorSetString(INDICATOR_SHORTNAME,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[])  {  //— iAD 指標から複製された値の数  int values_to_copy;  //— 指標で計算された値の数を決める  int calculated=BarsCalculated(handle);  if(calculated<=0)  {  PrintFormat(“BarsCalculated() returned %d, error code %d”,calculated,GetLastError());  return(0);  }  //— これが指標計算の初めであるか iAD 指標の値の数が変更した  //—または、2 つ以上のバーの指標の計算が必要である場合(価格履歴で何かが変更された)  if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1)  {  //— もし iADBuffer 配列が銘柄/期間で iAD 指標の値の数より大きい場合、全体のコピーはしない  //— 他の場合、指標バッファサイズより少ない量をコピーをする  if(calculated>rates_total) values_to_copy=rates_total;  else                       values_to_copy=calculated;  }  else  {  //— これは初回の計算ではなく、  //— 前回の OnCalculate() から、一以上のバーが加えられてない。  values_to_copy=(rates_total-prev_calculated)+1;  }  //— iADBuffer 配列をA/D の値で記入  //— FillArraysFromBuffer が false を返した場合、情報の準備が終わっていないので操作を終了する  if(!FillArrayFromBuffer(iADBuffer,handle,values_to_copy)) return(0);  //— メッセージを形成する  string comm=StringFormat(“%s ==>  Updated value in the indicator %s: %d”,  TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS),  short_name,  values_to_copy);  //— チャートにサービスメッセージを表示する  Comment(comm);  //— A/D 指標の値の数を覚える  bars_calculated=calculated;  //— prev_calculated 値を次の関数呼び出しのために返す  return(rates_total);  }  //+——————————————————————+  //| iAD 指標から指標バッファを記入する                                        |  //+——————————————————————+  bool FillArrayFromBuffer(double &values[],   // A/D 指標値の指標バッファ  int ind_handle,   // iAD 指標ハンドル  int amount         // 複製された値の数  )  {  //— エラーコードをリセットする  ResetLastError();  //— インデックス0 を持つ指標バッファの値で iADBuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,0,0,amount,values)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iAD indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— 全てが成功  return(true);  }  //+——————————————————————+  //| 指標初期化解除関数                                                  |  //+——————————————————————+  void OnDeinit(const int reason)  {  //— 指標の削除後チャートをクリアする  Comment(“”);  }  | 
iADX
この関数は ADX (Average Directional Movement )指標ハンドルを返します。
int  iADX(  string          symbol,          ENUM_TIMEFRAMES  period,          int              adx_period        );  | 
パラメータ
symbol
[in] データが指標計算に使用される有価証券の銘柄名(NULL は現在のシンボル)
period
[in] 期間の値は ENUM_TIMEFRAMES 列挙の値の 1 つで、0 は現在の時間軸の意味です。
adx_period
[in]  インデックス計算の期間
戻り値
注意事項
例:
//+——————————————————————+  //|                                                    Demo_iADX.mq5 |  //|                        Copyright 2011, MetaQuotes Software Corp. |  //|                                             https://www.MQL5.com |  //+——————————————————————+  #property copyright “Copyright 2011, MetaQuotes Software Corp.”  #property link     “https://www.mql5.com”  #property version   “1.00”  #property description “The indicator demonstrates how to obtain data”  #property description “of indicator buffers for the iADX technical indicator.”  #property description “A symbol and timeframe used for calculation of the indicator,”  #property description “are set by the symbol and period parameters.”  #property description “The method of creation of the handle is set through the ‘type’ parameter (function type).” #property indicator_separate_window  #property indicator_buffers 3  #property indicator_plots   3  //— ADX をプロットする  #property indicator_label1 “ADX”  #property indicator_type1   DRAW_LINE  #property indicator_color1  clrLightSeaGreen  #property indicator_style1 STYLE_SOLID  #property indicator_width1  1  //— DI_plus をプロットする  #property indicator_label2 “DI_plus”  #property indicator_type2   DRAW_LINE  #property indicator_color2  clrYellowGreen  #property indicator_style2 STYLE_SOLID  #property indicator_width2  1  //— DI_minus をプロットする  #property indicator_label3 “DI_minus”  #property indicator_type3   DRAW_LINE  #property indicator_color3  clrWheat  #property indicator_style3 STYLE_SOLID  #property indicator_width3  1  //+——————————————————————+  //| 作成を処理する方法の列挙                                              |  //+——————————————————————+  enum Creation  {  Call_iADX,             // use iADX を使用する  Call_IndicatorCreate   // IndicatorCreateを使用する  };  //— 入力パラメータ  input Creation             type=Call_iADX;         // 関数の種類   input int                  adx_period=14;         // 計算期間  input string               symbol=” “;             // シンボル  input ENUM_TIMEFRAMES     period=PERIOD_CURRENT; // 時間軸  //— 指標バッファ  double         ADXBuffer[];  double         DI_plusBuffer[];  double         DI_minusBuffer[];  //— iADX 指標ハンドルを格納する変数  int    handle;  //— 格納に使用される変数  string name=symbol;  //— チャートでの指標名  string short_name;  //— ADX 指標に値の数を保存  int    bars_calculated=0;  //+——————————————————————+  //| カスタム指標を初期化する関数                                            |  //+——————————————————————+  int OnInit()  {  //— 配列の指標バッファへの割り当て  SetIndexBuffer(0,ADXBuffer,INDICATOR_DATA);  SetIndexBuffer(1,DI_plusBuffer,INDICATOR_DATA);  SetIndexBuffer(2,DI_minusBuffer,INDICATOR_DATA);  //— 指標が描画するシンボルを決める  name=symbol;  //— 左右のスペースを削する  StringTrimRight(name);  StringTrimLeft(name);  //—「name」文字列の長さがゼロになった場合  if(StringLen(name)==0)  {  //— 指標が接続されているチャートのシンボルを取る  name=_Symbol;  }  //— 指標ハンドルを作成する  if(type==Call_iADX)  handle=iADX(name,period,adx_period);  else  {  //— 構造体を指標のパラメータで記入  MqlParam pars[1];  pars[0].type=TYPE_INT;  pars[0].integer_value=adx_period;  handle=IndicatorCreate(name,period,IND_ADX,1,pars);  }  //— ハンドルが作成されなかった場合  if(handle==INVALID_HANDLE)  {  //— 失敗した事実とエラーコードを出力する  PrintFormat(“Failed to create handle of the iADX indicator for the symbol %s/%s, error code %d”,  name,  EnumToString(period),  GetLastError());  //— 指標が早期に中止された  return(INIT_FAILED);  }  //— ADX が計算された銘柄/時間軸を表示  short_name=StringFormat(“iADX(%s/%s period=%d)”,name,EnumToString(period),adx_period);  IndicatorSetString(INDICATOR_SHORTNAME,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[])  {  //— iADX 指標から複製された値の数  int values_to_copy;  //— 指標で計算された値の数を決める  int calculated=BarsCalculated(handle);  if(calculated<=0)  {  PrintFormat(“BarsCalculated() returned %d, error code %d”,calculated,GetLastError());  return(0);  }  //— これが指標計算の初めであるか iADX 指標の値の数が変更した  //—または、2 つ以上のバーの指標の計算が必要である場合(価格履歴で何かが変更された)  if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1)  {  //— もし iADXBuffer 配列が銘柄/期間で iADX 指標の値の数より大きい場合、全体のコピーはしない  //— 他の場合、指標バッファサイズより少ない量をコピーをする  if(calculated>rates_total) values_to_copy=rates_total;  else                       values_to_copy=calculated;  }  else  {  //— これは初回の計算ではなく、  //— 前回の OnCalculate() から、一以上のバーが加えられてない。  values_to_copy=(rates_total-prev_calculated)+1;  }  //— 配列をADX 指標の値で記入  //— FillArraysFromBuffer が false を返した場合、情報の準備が終わっていないので操作を終了する  if(!FillArraysFromBuffers(ADXBuffer,DI_plusBuffer,DI_minusBuffer,handle,values_to_copy)) return(0);  //— メッセージを形成する  string comm=StringFormat(“%s ==>  Updated value in the indicator %s: %d”,  TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS),  short_name,  values_to_copy);  //— チャートにサービスメッセージを表示する  Comment(comm);  //— Average Directional Movement Index 指標の値の数を覚える<55/66/79% >  bars_calculated=calculated;  //— prev_calculated 値を次の関数呼び出しのために返す  return(rates_total);  }  //+——————————————————————+  //| iADX 指標から指標バッファを記入する                                       |  //+——————————————————————+  bool FillArraysFromBuffers(double &adx_values[],     // ADX 指標値の指標バッファ  double &DIplus_values[],   // DI+ 指標バッファ  double &DIminus_values[], // DI- 指標バッファ  int ind_handle,           // iADX 指標ハンドル  int amount                 // 複製された値の数  )  {  //— エラーコードをリセットする  ResetLastError();  //— インデックス0 を持つ指標バッファの値で iADXBuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,0,0,amount,adx_values)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iADX indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  } //— インデックス 1 を持つ指標バッファの値で DI_plusBuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,1,0,amount,DIplus_values)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iADX indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  } //— インデックス 2 を持つ指標バッファの値で DI_minusBuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,2,0,amount,DIminus_values)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iADX indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— 全てが成功  return(true);  }  //+——————————————————————+  //| 指標初期化解除関数                                                  |  //+——————————————————————+  void OnDeinit(const int reason)  {  //— 指標の削除後チャートをクリアする  Comment(“”);  }  | 
iADXWilder
この関数は Average Directional Movement Index by Welles Wilder のハンドルを返します。
int  iADXWilder(  string          symbol,          ENUM_TIMEFRAMES  period,          int              adx_period        );  | 
パラメータ
symbol
[in] データが指標計算に使用される有価証券の銘柄名(NULL は現在のシンボル)
period
[in] 期間の値は ENUM_TIMEFRAMES 列挙の値の 1 つで、0 は現在の時間軸の意味です。
adx_period
[in]  インデックス計算の期間
戻り値
注意事項
例:
//+——————————————————————+  //|                                                   iADXWilder.mq5 |  //|                        Copyright 2011, MetaQuotes Software Corp. |  //|                                             https://www.MQL5.com |  //+——————————————————————+  #property copyright “Copyright 2011, MetaQuotes Software Corp.”  #property link     “https://www.mql5.com”  #property version   “1.00”  #property description “The indicator demonstrates how to obtain data”  #property description “of indicator buffers for the iADXWilder technical indicator.”  #property description “A symbol and timeframe used for calculation of the indicator,”  #property description “are set by the symbol and period parameters.”  #property description “The method of creation of the handle is set through the ‘type’ parameter (function type).” #property indicator_separate_window  #property indicator_buffers 3  #property indicator_plots   3  //— ADX をプロットする  #property indicator_label1 “ADX”  #property indicator_type1   DRAW_LINE  #property indicator_color1  clrLightSeaGreen  #property indicator_style1 STYLE_SOLID  #property indicator_width1  1  //— DI_plus をプロットする  #property indicator_label2 “DI_plus”  #property indicator_type2   DRAW_LINE  #property indicator_color2  clrYellowGreen  #property indicator_style2 STYLE_SOLID  #property indicator_width2  1  //— DI_minus をプロットする  #property indicator_label3 “DI_minus”  #property indicator_type3   DRAW_LINE  #property indicator_color3  clrWheat  #property indicator_style3 STYLE_SOLID  #property indicator_width3  1  //+——————————————————————+  //| 作成を処理する方法の列挙                                              |  //+——————————————————————+  enum Creation  {  Call_iADXWilder,       // iADXWilder を使用する  Call_IndicatorCreate   // IndicatorCreateを使用する  };  //— 入力パラメータ  input Creation             type=Call_iADXWilder;   // 関数の種類   input int                  adx_period=14;         // 計算期間  input string               symbol=” “;             // シンボル  input ENUM_TIMEFRAMES     period=PERIOD_CURRENT; // 時間軸  //— 指標バッファ  double         ADXBuffer[];  double         DI_plusBuffer[];  double         DI_minusBuffer[];  //— iADXWilder 指標ハンドルを格納する変数  int    handle;  //— 格納に使用される変数  string name=symbol;  //— チャートでの指標名  string short_name;  //— Average Directional Movement Index by Welles Wilder 指標に値の数を保存  int    bars_calculated=0;  //+——————————————————————+  //| カスタム指標を初期化する関数                                            |  //+——————————————————————+  int OnInit()  {  //— 配列の指標バッファへの割り当て  SetIndexBuffer(0,ADXBuffer,INDICATOR_DATA);  SetIndexBuffer(1,DI_plusBuffer,INDICATOR_DATA);  SetIndexBuffer(2,DI_minusBuffer,INDICATOR_DATA);  //— 指標が描画するシンボルを決める  name=symbol;  //— 左右のスペースを削する  StringTrimRight(name);  StringTrimLeft(name);  //—「name」文字列の長さがゼロになった場合  if(StringLen(name)==0)  {  //— 指標が接続されているチャートのシンボルを取る  name=_Symbol;  }  //— 指標ハンドルを作成する  if(type==Call_iADXWilder)  handle=iADXWilder(name,period,adx_period);  else  {  //— 構造体を指標のパラメータで記入  MqlParam pars[1];  pars[0].type=TYPE_INT;  pars[0].integer_value=adx_period;  handle=IndicatorCreate(name,period,IND_ADXW,1,pars);  }  //— ハンドルが作成されなかった場合  if(handle==INVALID_HANDLE)  {  //— 失敗した事実とエラーコードを出力する  PrintFormat(“Failed to create handle of the iADXWilder indicator for the symbol %s/%s, error code %d”,  name,  EnumToString(period),  GetLastError());  //— 指標が早期に中止された  return(INIT_FAILED);  }  //— Average Directional Movement Index by Welles Wilder 指標が計算された銘柄/時間軸を表示  short_name=StringFormat(“iADXWilder(%s/%s period=%d)”,name,EnumToString(period),adx_period);  IndicatorSetString(INDICATOR_SHORTNAME,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[])  {  //— iADXWilder 指標から複製された値の数  int values_to_copy;  //— 指標で計算された値の数を決める  int calculated=BarsCalculated(handle);  if(calculated<=0)  {  PrintFormat(“BarsCalculated() returned %d, error code %d”,calculated,GetLastError());  return(0);  }  //— これが指標計算の初めであるか iADXWilder 指標の値の数が変更した  //—または、2 つ以上のバーの指標の計算が必要である場合(価格履歴で何かが変更された)  if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1)  {  //— もし iADXWilder Buffer 配列が銘柄/期間で iADXWilder 指標の値の数より大きい場合、全体のコピーはしない   //— 他の場合、指標バッファサイズより少ない量をコピーをする  if(calculated>rates_total) values_to_copy=rates_total;  else                       values_to_copy=calculated;  }  else  {  //— これは初回の計算ではなく、  //— 前回の OnCalculate() から、一以上のバーが加えられてない。  values_to_copy=(rates_total-prev_calculated)+1;  }  //— 配列をAverage Directional Movement Index by Welles Wilder 指標の値で記入<81/80/82% >  //— FillArraysFromBuffer が false を返した場合、情報の準備が終わっていないので操作を終了する  if(!FillArraysFromBuffers(ADXBuffer,DI_plusBuffer,DI_minusBuffer,handle,values_to_copy)) return(0);  //— メッセージを形成する  string comm=StringFormat(“%s ==>  Updated value in the indicator %s: %d”,  TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS),  short_name,  values_to_copy);  //— チャートにサービスメッセージを表示する  Comment(comm);  //— Average Directional Movement Index 指標の値の数を覚える<55/66/79% >  bars_calculated=calculated;  //— prev_calculated 値を次の関数呼び出しのために返す  return(rates_total);  }  //+——————————————————————+  //| iADXWilder 指標から指標バッファを記入する                                 |  //+——————————————————————+  bool FillArraysFromBuffers(double &adx_values[],     // ADX 指標値の指標バッファ  double &DIplus_values[],   // DI+ 指標バッファ  double &DIminus_values[], // DI- 指標バッファ  int ind_handle,           // iADXWilder 指標ハンドル  int amount                 // 複製された値の数  )  {  //— エラーコードをリセットする  ResetLastError();  //— インデックス0 を持つ指標バッファの値で iADXBuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,0,0,amount,adx_values)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iADXWilder indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  } //— インデックス 1 を持つ指標バッファの値で DI_plusBuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,1,0,amount,DIplus_values)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iADXWilder indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  } //— インデックス 2 を持つ指標バッファの値で DI_minusBuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,2,0,amount,DIminus_values)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iADXWilder indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— 全てが成功  return(true);  }  //+——————————————————————+  //| 指標初期化解除関数                                                  |  //+——————————————————————+  void OnDeinit(const int reason)  {  //— 指標の削除後チャートをクリアする  Comment(“”);  }  | 
iAlligator
この関数は Alligator (アリゲーター)指標のハンドルを返します。
int  iAlligator(  string              symbol,              ENUM_TIMEFRAMES    period,              int                jaw_period,          int                jaw_shift,          int                teeth_period,        int                teeth_shift,        int                lips_period,        int                lips_shift,          ENUM_MA_METHOD      ma_method,          ENUM_APPLIED_PRICE  applied_price        );  | 
パラメータ
symbol
[in] データが指標計算に使用される有価証券の銘柄名(NULL は現在のシンボル)
period
[in] 期間の値は ENUM_TIMEFRAMES 列挙の値の 1 つで、0 は現在の時間軸の意味です。
jaw_period
[in]  青線の平均期間(アリゲーターの顎)
jaw_shift
[in] 価格チャートに相対した青線のシフト
teeth_period
[in]  赤線の平均期間(アリゲーターの歯)
teeth_shift
[in] 価格チャートに相対した赤線のシフト
lips_period
[in]  緑線の平均期間(アリゲーターの口)
lips_shift
[in] 価格チャートに相対した緑線のシフト
ma_method
[in]  平均化の方法ENUM_MA_METHOD 値のいずれか
applied_price
[in]  使用される価格。ENUM_APPLIED_PRICE 価格定数のいずれか、または別の指標ハンドル。
戻り値
注意事項
例:
//+——————————————————————+  //|                                              Demo_iAlligator.mq5 |  //|                        Copyright 2011, MetaQuotes Software Corp. |  //|                                             https://www.MQL5.com |  //+——————————————————————+  #property copyright “Copyright 2011, MetaQuotes Software Corp.”  #property link     “https://www.mql5.com”  #property version   “1.00”  #property description “The indicator demonstrates how to obtain data”  #property description “of indicator buffers for the iAlligator technical indicator.”  #property description “A symbol and timeframe used for calculation of the indicator,”  #property description “are set by the symbol and period parameters.”  #property description “The method of creation of the handle is set through the ‘type’ parameter (function type).”  #property description “All the other parameters are similar to the standard Alligator.” #property indicator_chart_window  #property indicator_buffers 3  #property indicator_plots   3  //— 顎をプロットする  #property indicator_label1 “Jaws”  #property indicator_type1   DRAW_LINE  #property indicator_color1  clrBlue  #property indicator_style1 STYLE_SOLID  #property indicator_width1  1  //— 歯をプロットする  #property indicator_label2 “Teeth”  #property indicator_type2   DRAW_LINE  #property indicator_color2  clrRed  #property indicator_style2 STYLE_SOLID  #property indicator_width2  1  //— 口をプロットする  #property indicator_label3 “Lips”  #property indicator_type3   DRAW_LINE  #property indicator_color3  clrLime  #property indicator_style3 STYLE_SOLID  #property indicator_width3  1  //+——————————————————————+  //| 作成を処理する方法の列挙                                              |  //+——————————————————————+  enum Creation  {  Call_iAlligator,       // iAlligator を使用する  Call_IndicatorCreate   // IndicatorCreateを使用する  };  //— 入力パラメータ  input Creation             type=Call_iAlligator;   // 関数の種類   input string               symbol=” “;             // シンボル  input ENUM_TIMEFRAMES     period=PERIOD_CURRENT; // 時間軸  input int                  jaw_period=13;         // 顎線の期間  input int                  jaw_shift=8;           // 顎線のシフト  input int                  teeth_period=8;         // 歯線の期間  input int                  teeth_shift=5;         // 歯線のシフト  input int     &nnbsp;            lips_period=5;         // 口線の期間  input int                  lips_shift=3;           // 口線のシフト  input ENUM_MA_METHOD       MA_method=MODE_SMMA;   // アリゲーター線の平均化の方法  input ENUM_APPLIED_PRICE   applied_price=PRICE_MEDIAN;// アリゲーター計算に使用される価格の種類  //— 指標バッファ  double         JawsBuffer[];  double         TeethBuffer[];  double         LipsBuffer[];  //— iAlligator 指標ハンドルを格納する変数  int    handle;  //— 格納に使用される変数  string name=symbol;  //— チャートでの指標名  string short_name;  //— アリゲーター指標に値の数を保存  int    bars_calculated=0;  //+——————————————————————+  //| カスタム指標を初期化する関数                                            |  //+——————————————————————+  int OnInit()  {  //— 配列の指標バッファへの割り当て  SetIndexBuffer(0,JawsBuffer,INDICATOR_DATA);  SetIndexBuffer(1,TeethBuffer,INDICATOR_DATA);  SetIndexBuffer(2,LipsBuffer,INDICATOR_DATA);  //— それぞれの線のシフトを設定  PlotIndexSetInteger(0,PLOT_SHIFT,jaw_shift);  PlotIndexSetInteger(1,PLOT_SHIFT,teeth_shift);  PlotIndexSetInteger(2,PLOT_SHIFT,lips_shift);  //— 指標が描画するシンボルを決める  name=symbol;  //— 左右のスペースを削する  StringTrimRight(name);  StringTrimLeft(name);  //—「name」文字列の長さがゼロになった場合  if(StringLen(name)==0)  {  //— 指標が接続されているチャートのシンボルを取る  name=_Symbol;  }  //— 指標ハンドルを作成する  if(type==Call_iAlligator)  handle=iAlligator(name,period,jaw_period,jaw_shift,teeth_period,  teeth_shift,lips_period,lips_shift,MA_method,applied_price);  else  {  //— 構造体を指標のパラメータで記入  MqlParam pars[8];       //— アリゲーター線の期間とシフト  pars[0].type=TYPE_INT;  pars[0].integer_value=jaw_period;  pars[1].type=TYPE_INT;  pars[1].integer_value=jaw_shift;  pars[2].type=TYPE_INT;  pars[2].integer_value=teeth_period;  pars[3].type=TYPE_INT;  pars[3].integer_value=teeth_shift;  pars[4].type=TYPE_INT;  pars[4].integer_value=lips_period;  pars[5].type=TYPE_INT;  pars[5].integer_value=lips_shift;  //— 平滑化の種類  pars[6].type=TYPE_INT;  pars[6].integer_value=MA_method;  //— 価格の種類  pars[7].type=TYPE_INT;  pars[7].integer_value=applied_price;  //— ハンドルを作成  handle=IndicatorCreate(name,period,IND_ALLIGATOR,8,pars);  }  //— ハンドルが作成されなかった場合  if(handle==INVALID_HANDLE)  {  //— 失敗した事実とエラーコードを出力する  PrintFormat(“Failed to create handle of the iAlligator indicator for the symbol %s/%s, error code %d”,  name,  EnumToString(period),  GetLastError());  //— 指標が早期に中止された  return(INIT_FAILED);  }  //— アリゲーターが計算された銘柄/時間軸を表示  short_name=StringFormat(“iAlligator(%s/%s, %d,%d,%d,%d,%d,%d)”,name,EnumToString(period),  jaw_period,jaw_shift,teeth_period,teeth_shift,lips_period,lips_shift);  IndicatorSetString(INDICATOR_SHORTNAME,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[])  {  //— iAlligator 指標から複製された値の数  int values_to_copy;  //— 指標で計算された値の数を決める  int calculated=BarsCalculated(handle);  if(calculated<=0)  {  PrintFormat(“BarsCalculated() returned %d, error code %d”,calculated,GetLastError());  return(0);  }  //— これが指標計算の初めであるか iAlligator 指標の値の数が変更した  //—または、2 つ以上のバーの指標の計算が必要である場合(価格履歴で何かが変更された)  if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1)  {  //— もし JawsBuffer 配列が銘柄/期間で iAlligator 指標の値の数より大きい場合、全体のコピーはしない  //— 他の場合、指標バッファサイズより少ない量をコピーをする  if(calculated>rates_total) values_to_copy=rates_total;  else                       values_to_copy=calculated;  }  else  {  //— これは初回の計算ではなく、  //— 前回の OnCalculate() から、一以上のバーが加えられてない。  values_to_copy=(rates_total-prev_calculated)+1;  }  //— 配列をアリゲーター指標の値で記入  //— FillArraysFromBuffer が false を返した場合、情報の準備が終わっていないので操作を終了する  if(!FillArraysFromBuffers(JawsBuffer,jaw_shift,TeethBuffer,teeth_shift,LipsBuffer,lips_shift,handle,values_to_copy)) return(0);  //— メッセージを形成する  string comm=StringFormat(“%s ==>  Updated value in the indicator %s: %d”,  TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS),  short_name,  values_to_copy);  //— チャートにサービスメッセージを表示する  Comment(comm);  //— アリゲーター指標の値の数を覚える  bars_calculated=calculated;  //— prev_calculated 値を次の関数呼び出しのために返す  return(rates_total);  }  //+——————————————————————+  //| iAlligator 指標から指標バッファを記入する                                 |  //+——————————————————————+  bool FillArraysFromBuffers(double &jaws_buffer[], // 顎線の指標バッファ  int j_shift,           // 顎線のシフト  double &teeth_buffer[], // 歯線の指標バッファ  int t_shift,           // 歯線のシフト  double &lips_buffer[], // 口線の指標バッファe  int l_shift,           // 口線のシフト  int ind_handle,         // iAlligator 指標ハンドル  int amount             // 複製された値の数  )  {  //— エラーコードをリセットする  ResetLastError();  //— インデックス0 を持つ指標バッファの値で JawsBuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,0,-j_shift,amount,jaws_buffer)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iAlligator indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  } //— インデックス0 を持つ指標バッファの値で TeethBuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,1,-t_shift,amount,teeth_buffer)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iAlligator indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  } //— インデックス 2 を持つ指標バッファの値で LipsBuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,2,-l_shift,amount,lips_buffer)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iAlligator indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— 全てが成功  return(true);  }  //+——————————————————————+  //| 指標初期化解除関数                                                  |  //+——————————————————————+  void OnDeinit(const int reason)  {  //— 指標の削除後チャートをクリアする  Comment(“”);  }  | 
iAMA
この関数は Adaptive Moving Average (適応型移動平均)指標のハンドルを返します。バッファは 1 つです。
int  iAMA(  string              symbol,              ENUM_TIMEFRAMES    period,              int                ama_period,          int                fast_ma_period,      int                slow_ma_period,      int                ama_shift,            ENUM_APPLIED_PRICE  applied_price        );  | 
パラメータ
symbol
[in] データが指標計算に使用される有価証券の銘柄名(NULL は現在のシンボル)
period
[in] 期間の値は ENUM_TIMEFRAMES 列挙の値の 1 つで、0 は現在の時間軸の意味です。
ama_period
[in]  効率係数が計算された計算期間
fast_ma_period
[in]  急速な市場のための平滑化係数計算の高速期間
slow_ma_period
[in]  トレンド不在下での平滑化係数計算の低速期間
ama_shift
[in]  価格チャートに相対した指標のシフト
applied_price
[in]  使用される価格。ENUM_APPLIED_PRICE 価格定数のいずれか、または別の指標ハンドル。
戻り値
例:
//+——————————————————————+  //|                                                    Demo_iAMA.mq5 |  //|                        Copyright 2011, MetaQuotes Software Corp. |  //|                                             https://www.MQL5.com |  //+——————————————————————+  #property copyright “Copyright 2011, MetaQuotes Software Corp.”  #property link     “https://www.mql5.com”  #property version   “1.00”  #property description “The indicator demonstrates how to obtain data”  #property description “of indicator buffers for the iAMA technical indicator.”  #property description “A symbol and timeframe used for calculation of the indicator,”  #property description “are set by the symbol and period parameters.”  #property description “The method of creation of the handle is set through the ‘type’ parameter (function type).”  #property description “All the other parameters are similar to the standard AMA.” #property indicator_chart_window  #property indicator_buffers 1  #property indicator_plots   1  //— iAMA をプロットする  #property indicator_label1 “iAMA”  #property indicator_type1   DRAW_LINE  #property indicator_color1  clrRed  #property indicator_style1 STYLE_SOLID  #property indicator_width1  1  //+——————————————————————+  //| 作成を処理する方法の列挙                                              |  //+——————————————————————+  enum Creation  {  Call_iAMA,             // iAMA を使用する  Call_IndicatorCreate   // IndicatorCreateを使用する  };  //— 入力パラメータ  input Creation             type=Call_iAMA;         // 関数の種類   input string               symbol=” “;             // シンボル   input ENUM_TIMEFRAMES     period=PERIOD_CURRENT;   // 時間軸  input int                  ama_period=15;           // 計算期間  input int                  fast_ma_period=2;       // 高速 MA 期間  input int                  slow_ma_period=30;       // 低速 MA 期間  input int                  ama_shift=0;             // 水平シフト  input ENUM_APPLIED_PRICE   applied_price;           // 価格の種類  //— 指標バッファ  double         iAMABuffer[];  //— iAMA 指標ハンドルを格納する変数  int    handle;  //— 格納に使用される変数  string name=symbol;  //— チャートでの指標名  string short_name;  //— 適応型移動平均指標に値の数を保存  int    bars_calculated=0;  //+——————————————————————+  //| カスタム指標を初期化する関数                                            |  //+——————————————————————+  int OnInit()  {  //— 指標バッファマッピング  SetIndexBuffer(0,iAMABuffer,INDICATOR_DATA);  //— シフトを設定  PlotIndexSetInteger(0,PLOT_SHIFT,ama_shift);  //— 指標が描画するシンボルを決める  name=symbol;  //— 左右のスペースを削する  StringTrimRight(name);  StringTrimLeft(name);  //—「name」文字列の長さがゼロになった場合  if(StringLen(name)==0)  {  //— 指標が接続されているチャートのシンボルを取る  name=_Symbol;  }  //— 指標ハンドルを作成する  if(type==Call_iAMA)  handle=iAMA(name,period,ama_period,fast_ma_period,slow_ma_period,ama_shift,applied_price);  else  {  //— 構造体を指標のパラメータで記入  MqlParam pars[5];  pars[0].type=TYPE_INT;  pars[0].integer_value=ama_period;  pars[1].type=TYPE_INT;  pars[1].integer_value=fast_ma_period;  pars[2].type=TYPE_INT;  pars[2].integer_value=slow_ma_period;  pars[3].type=TYPE_INT;  pars[3].integer_value=ama_shift;  //— 価格の種類  pars[4].type=TYPE_INT;  pars[4].integer_value=applied_price;  handle=IndicatorCreate(name,period,IND_AMA,5,pars);  }  //— ハンドルが作成されなかった場合  if(handle==INVALID_HANDLE)  {  //— 失敗した事実とエラーコードを出力する  PrintFormat(“Failed to create handle of the iAMA indicator for the symbol %s/%s, error code %d”,  name,  EnumToString(period),  GetLastError());  //— 指標が早期に中止された  return(INIT_FAILED);  }  //— 適応型移動平均 が計算された銘柄/時間軸を表示  short_name=StringFormat(“iAMA(%s/%s,%d,%d,%d,d)”,name,EnumToString(period),ama_period,fast_ma_period,slow_ma_period,ama_shift);  IndicatorSetString(INDICATOR_SHORTNAME,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[])  {  //— iAMA 指標から複製された値の数  int values_to_copy;  //— 指標で計算された値の数を決める  int calculated=BarsCalculated(handle);  if(calculated<=0)  {  PrintFormat(“BarsCalculated() returned %d, error code %d”,calculated,GetLastError());  return(0);  }  //— これが指標計算の初めであるか iAMA 指標の値の数が変更した  //—または、2 つ以上のバーの指標の計算が必要である場合(価格履歴で何かが変更された)  if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1)  {  //— もし iAMABuffer 配列が銘柄/期間で iAMA 指標の値の数より大きい場合、全体のコピーはしない  //— 他の場合、指標バッファサイズより少ない量をコピーをする  if(calculated>rates_total) values_to_copy=rates_total;  else                       values_to_copy=calculated;  }  else  {  //— これは初回の計算ではなく、  //— 前回の OnCalculate() から、一以上のバーが加えられてない。  values_to_copy=(rates_total-prev_calculated)+1;  }  //— 配列を 適応型移動平均指標の値で記入  //— FillArraysFromBuffer が false を返した場合、情報の準備が終わっていないので操作を終了する  if(!FillArrayFromBuffer(iAMABuffer,ama_shift,handle,values_to_copy)) return(0);  //— メッセージを形成する  string comm=StringFormat(“%s ==>  Updated value in the indicator %s: %d”,  TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS),  short_name,  values_to_copy);  //— チャートにサービスメッセージを表示する  Comment(comm);  //— 適応型移動平均指標の値の数を覚える  bars_calculated=calculated;  //— prev_calculated 値を次の関数呼び出しのために返す  return(rates_total);  }  //+——————————————————————+  //| iAMA 指標から指標バッファを記入する                                       |  //+——————————————————————+  bool FillArrayFromBuffer(double &ama_buffer[], // AMA 線の指標バッファ  int a_shift,           // AMA 線のシフト  int ind_handle,       // iAMA 指標ハンドル  int amount             // 複製された値の数  )  {  //— エラーコードをリセットする  ResetLastError();  //— インデックス0 を持つ指標バッファの値で iAMABuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,0,-a_shift,amount,ama_buffer)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iAMA indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— 全てが成功  return(true);  }  //+——————————————————————+  //| 指標初期化解除関数                                                  |  //+——————————————————————+  void OnDeinit(const int reason)  {  //— 指標の削除後チャートをクリアする  Comment(“”);  }  | 
iAO
この関数は Awesome Oscillator (オーサムオシレータ)指標のハンドルを返します。バッファは 1 つです。
int  iAO(  string          symbol,      ENUM_TIMEFRAMES  period        );  | 
パラメータ
symbol
[in] データが指標計算に使用される有価証券の銘柄名(NULL は現在のシンボル)
period
[in] 期間の値は ENUM_TIMEFRAMES 列挙の値の 1 つで、0 は現在の時間軸の意味です。
戻り値
例:
//+——————————————————————+  //|                                                     Demo_iAO.mq5 |  //|                        Copyright 2011, MetaQuotes Software Corp. |  //|                                             https://www.MQL5.com |  //+——————————————————————+  #property copyright “Copyright 2011, MetaQuotes Software Corp.”  #property link     “https://www.mql5.com”  #property version   “1.00”  #property description “The indicator demonstrates how to obtain data”  #property description “of indicator buffers for the iAO technical indicator.”  #property description “A symbol and timeframe used for calculation of the indicator,”  #property description “are set by the symbol and period parameters.”  #property description “The method of creation of the handle is set through the ‘type’ parameter (function type).” #property indicator_separate_window  #property indicator_buffers 2  #property indicator_plots   1  //— iAO プロット  #property indicator_label1 “iAO”  #property indicator_type1   DRAW_COLOR_HISTOGRAM  #property indicator_color1  clrGreen,clrRed  #property indicator_style1 STYLE_SOLID  #property indicator_width1  1  //+——————————————————————+  //| 作成を処理する方法の列挙                                              |  //+——————————————————————+  enum Creation  {  Call_iAO,               // iAO を使用する  Call_IndicatorCreate   // IndicatorCreateを使用する  };  //— 入力パラメータ  input Creation             type=Call_iAO;         // 関数の種類   input string               symbol=” “;             // シンボル  input ENUM_TIMEFRAMES     period=PERIOD_CURRENT; // 時間軸  //— 指標バッファ  double         iAOBuffer[];  double         iAOColors[];  //— iAO 指標ハンドルを格納する変数  int    handle;  //— 格納に使用される変数  string name=symbol;  //— チャートでの指標名  string short_name;  //— Awesome Oscillator 指標に値の数を保存  int    bars_calculated=0;  //+——————————————————————+  //| カスタム指標を初期化する関数                                            |  //+——————————————————————+  int OnInit()  {  //— 配列の指標バッファへの割り当て  SetIndexBuffer(0,iAOBuffer,INDICATOR_DATA);  SetIndexBuffer(1,iAOColors,INDICATOR_COLOR_INDEX);  //— 指標が描画するシンボルを決める  name=symbol;  //— 左右のスペースを削する  StringTrimRight(name);  StringTrimLeft(name);  //—「name」文字列の長さがゼロになった場合  if(StringLen(name)==0)  {  //— 指標が接続されているチャートのシンボルを取る  name=_Symbol;  }  //— 指標ハンドルを作成する  if(type==Call_iAO)  handle=iAO(name,period);  else  handle=IndicatorCreate(name,period,IND_AO);  //— ハンドルが作成されなかった場合  if(handle==INVALID_HANDLE)  {  //— 失敗した事実とエラーコードを出力する  PrintFormat(“Failed to create handle of the iAO indicator for the symbol %s/%s, error code %d”,  name,  EnumToString(period),  GetLastError());  //— 指標が早期に中止された  return(INIT_FAILED);  }  //— オーサムオシレーターが計算された銘柄/時間軸を表示r  short_name=StringFormat(“iAO(%s/%s)”,name,EnumToString(period));  IndicatorSetString(INDICATOR_SHORTNAME,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[])  {  //— iAO 指標から複製された値の数  int values_to_copy;  //— 指標で計算された値の数を決める  int calculated=BarsCalculated(handle);  if(calculated<=0)  {  PrintFormat(“BarsCalculated() returned %d, error code %d”,calculated,GetLastError());  return(0);  }  //— これが指標計算の初めであるか iAO 指標の値の数が変更した  //—または、2 つ以上のバーの指標の計算が必要である場合(価格履歴で何かが変更された)  if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1)  {  //— もし iAOBuffer 配列が銘柄/期間で iAO 指標の値の数より大きい場合、全体のコピーはしない  //— 他の場合、指標バッファサイズより少ない量をコピーをする  if(calculated>rates_total) values_to_copy=rates_total;  else                       values_to_copy=calculated;  }  else  {  //— これは初回の計算ではなく、  //— 前回の OnCalculate() から、一以上のバーが加えられてない。  values_to_copy=(rates_total-prev_calculated)+1;  }  //— オーサムオシレーター指標の値で iAOBuffer と iAOColors 配列を記入する  //— FillArraysFromBuffer が false を返した場合、情報の準備が終わっていないので操作を終了する  if(!FillArraysFromBuffer(iAOBuffer,iAOColors,handle,values_to_copy)) return(0);  //— メッセージを形成する  string comm=StringFormat(“%s ==>  Updated value in the indicator %s: %d”,  TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS),  short_name,  values_to_copy);  //— チャートにサービスメッセージを表示する  Comment(comm);  //— オーサムオシレーター 指標の値の数を覚える  bars_calculated=calculated;  //— prev_calculated 値を次の関数呼び出しのために返す  return(rates_total);  }  //+——————————————————————+  //| iAO 指標から指標バッファを記入する                                        |  //+——————————————————————+  bool FillArraysFromBuffer(double &values[],       // オーサムオシレーター値の指標バッファ  double &color_indexes[], // 色のバッファ(色インデックスを格納)  int ind_handle,         // iAO 指標ハンドル  int amount               // 複製された値の数  )  {  //— エラーコードをリセットする  ResetLastError();  //—インデックス0 を持つ指標バッファの値で iAOBuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,0,0,amount,values)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iAO indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— 色インデックスを複製する  if(CopyBuffer(ind_handle,1,0,amount,color_indexes)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy color values from the iAO indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— 全てが成功  return(true);  }  //+——————————————————————+  //| 指標初期化解除関数                                                  |  //+——————————————————————+  void OnDeinit(const int reason)  {  //— 指標の削除後チャートをクリアする  Comment(“”);  }  | 
iATR
この関数は ATR(Average True Range)指標ハンドルを返します。バッファは 1 つです。
int  iATR(  string          symbol,          ENUM_TIMEFRAMES  period,          int              ma_period        );  | 
パラメータ
symbol
[in] データが指標計算に使用される有価証券の銘柄名(NULL は現在のシンボル)
period
[in] 期間の値は ENUM_TIMEFRAMES 列挙の値の 1 つで、0 は現在の時間軸の意味です。
ma_period
[in]  指標計算の平均期間の値
戻り値
例:
//+——————————————————————+  //|                                                    Demo_iATR.mq5 |  //|                        Copyright 2011, MetaQuotes Software Corp. |  //|                                             https://www.MQL5.com |  //+——————————————————————+  #property copyright “Copyright 2011, MetaQuotes Software Corp.”  #property link     “https://www.mql5.com”  #property version   “1.00”  #property description “The indicator demonstrates how to obtain data”  #property description “of indicator buffers for the iATR technical indicator.”  #property description “A symbol and timeframe used for calculation of the indicator,”  #property description “are set by the symbol and period parameters.”  #property description “The method of creation of the handle is set through the ‘type’ parameter (function type).” #property indicator_separate_window  #property indicator_buffers 1  #property indicator_plots   1  //— iATR をプロットする  #property indicator_label1 “iATR”  #property indicator_type1   DRAW_LINE  #property indicator_color1  clrLightSeaGreen  #property indicator_style1 STYLE_SOLID  #property indicator_width1  1  //+——————————————————————+  //| 作成を処理する方法の列挙                                              |  //+——————————————————————+  enum Creation  {  Call_iATR,// iATR を使用する  Call_IndicatorCreate   // IndicatorCreateを使用する  };  //— 入力パラメータ  input int                  atr_period=14;         // 計算期間  input Creation             type=Call_iATR;         // 関数の種類  input string               symbol=” “;             // シンボル  input ENUM_TIMEFRAMES     period=PERIOD_CURRENT; // 時間軸  //— 指標バッファ  double         iATRBuffer[];  //— iAC 指標ハンドルを格納する変数  int    handle;  //— 格納に使用される変数  string name=symbol;  //— チャートでの指標名  string short_name;  //— ATR 指標に値の数を保存  int    bars_calculated=0;  //+——————————————————————+  //| カスタム指標を初期化する関数                                            |  //+——————————————————————+  int OnInit()  {  //— 配列の指標バッファへの割り当て  SetIndexBuffer(0,iATRBuffer,INDICATOR_DATA);  //— 指標が描画するシンボルを決める  name=symbol;  //— 左右のスペースを削する  StringTrimRight(name);  StringTrimLeft(name);  //—「name」文字列の長さがゼロになった場合  if(StringLen(name)==0)  {  //— 指標が接続されているチャートのシンボルを取る  name=_Symbol;  }  //— 指標ハンドルを作成する  if(type==Call_iATR)  handle=iATR(name,period,atr_period);  else  {  //— 構造体を指標のパラメータで記入  MqlParam pars[1];  pars[0].type=TYPE_INT;  pars[0].integer_value=atr_period;  handle=IndicatorCreate(name,period,IND_ATR,1,pars);  }  //— ハンドルが作成されなかった場合  if(handle==INVALID_HANDLE)  {  //— 失敗した事実とエラーコードを出力する  PrintFormat(“Failed to create handle of the iATR indicator for the symbol %s/%s, error code %d”,  name,  EnumToString(period),  GetLastError());  //— 指標が早期に中止された  return(INIT_FAILED);  }  //— ATR 指標が計算された銘柄/時間軸を表示  short_name=StringFormat(“iATR(%s/%s, period=%d)”,name,EnumToString(period),atr_period);  IndicatorSetString(INDICATOR_SHORTNAME,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[])  {  //— iATR 指標から複製された値の数  int values_to_copy;  //— 指標で計算された値の数を決める  int calculated=BarsCalculated(handle);  if(calculated<=0)  {  PrintFormat(“BarsCalculated() returned %d, error code %d”,calculated,GetLastError());  return(0);  }  //— これが指標計算の初めであるか iATR 指標の値の数が変更した  //—または、2 つ以上のバーの指標の計算が必要である場合(価格履歴で何かが変更された)  if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1)  {  //—もし iATRBuffer 配列が銘柄/期間で iATR 指標の値の数より大きい場合、全体のコピーはしない   //— 他の場合、指標バッファサイズより少ない量をコピーをする  if(calculated>rates_total) values_to_copy=rates_total;  else                       values_to_copy=calculated;  }  else  {  //— これは初回の計算ではなく、  //— 前回の OnCalculate() から、一以上のバーが加えられてない。  values_to_copy=(rates_total-prev_calculated)+1;  }  //— iATRBuffer 配列をATR 指標の値で記入  //— FillArrayFromBuffer が false を返した場合、情報の準備が終わっていないので操作を終了する  if(!FillArrayFromBuffer(iATRBuffer,handle,values_to_copy)) return(0);  //— メッセージを形成する  string comm=StringFormat(“%s ==>  Updated value in the indicator %s: %d”,  TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS),  short_name,  values_to_copy);  //— チャートにサービスメッセージを表示する  Comment(comm);  //— ATR 指標の値の数を覚える  bars_calculated=calculated;  //— prev_calculated 値を次の関数呼び出しのために返す  return(rates_total);  }  //+——————————————————————+  //| iATR 指標から指標バッファを記入する                                       |  //+——————————————————————+  bool FillArrayFromBuffer(double &values[], // ATR 値の指標バッファ  int ind_handle,   // iATR 指標ハンドル  int amount         // 複製された値の数  )  {  //— エラーコードをリセットする  ResetLastError();  //— インデックス0 を持つ指標バッファの値で iATRBuffer 配列の一部を記入するx  if(CopyBuffer(ind_handle,0,0,amount,values)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iATR indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— 全てが成功  return(true);  }  //+——————————————————————+  //| 指標初期化解除関数                                                  |  //+——————————————————————+  void OnDeinit(const int reason)  {  //— 指標の削除後チャートをクリアする  Comment(“”);  }  | 
iBearsPower
この関数は Bears Power (ベアパワー)指標のハンドルを返します。バッファは 1 つです。
int  iBearsPower(  string              symbol,              ENUM_TIMEFRAMES    period,              int                ma_period,          );  | 
パラメータ
symbol
[in] データが指標計算に使用される有価証券の銘柄名(NULL は現在のシンボル)
period
[in] 期間の値は ENUM_TIMEFRAMES 列挙の値の 1 つで、0 は現在の時間軸の意味です。
ma_period
[in]  指標計算の平均期間の値
戻り値
例:
//+——————————————————————+  //|                                             Demo_iBearsPower.mq5 |  //|                        Copyright 2011, MetaQuotes Software Corp. |  //|                                             https://www.MQL5.com |  //+——————————————————————+  #property copyright “Copyright 2011, MetaQuotes Software Corp.”  #property link     “https://www.mql5.com”  #property version   “1.00”  #property description “The indicator demonstrates how to obtain data”  #property description “of indicator buffers for the iBearsPower technical indicator.”  #property description “A symbol and timeframe used for calculation of the indicator,”  #property description “are set by the symbol and period parameters.”  #property description “The method of creation of the handle is set through the ‘type’ parameter (function type).” #property indicator_separate_window  #property indicator_buffers 1  #property indicator_plots   1  //— iBearsPower プロット  #property indicator_label1 “iBearsPower”  #property indicator_type1   DRAW_HISTOGRAM  #property indicator_color1  clrSilver  #property indicator_style1 STYLE_SOLID  #property indicator_width1  1  //+——————————————————————+  //| 作成を処理する方法の列挙                                              |  //+——————————————————————+  enum Creation  {  Call_iBearsPower,       // iBearsPower を使用する  Call_IndicatorCreate   // IndicatorCreateを使用する  };  //— 入力パラメータ  input Creation             type=Call_iBearsPower; // 関数の種類   input int                  ma_period=13;           // 移動平均の期間  input string               symbol=” “;             // シンボル  input ENUM_TIMEFRAMES     period=PERIOD_CURRENT; // 時間軸  //— 指標バッファ  double         iBearsPowerBuffer[];  //— iBearsPower 指標ハンドルを格納する変数  int    handle;  //— 格納に使用される変数  string name=symbol;  //— チャートでの指標名  string short_name;  //— ベアパワー指標に値の数を保存  int    bars_calculated=0;  //+——————————————————————+  //| カスタム指標を初期化する関数                                            |  //+——————————————————————+  int OnInit()  {  //— 配列の指標バッファへの割り当て  SetIndexBuffer(0,iBearsPowerBuffer,INDICATOR_DATA);  //— 指標が描画するシンボルを決める  name=symbol;  //— 左右のスペースを削する  StringTrimRight(name);  StringTrimLeft(name);  //—「name」文字列の長さがゼロになった場合  if(StringLen(name)==0)  {  //— 指標が接続されているチャートのシンボルを取る  name=_Symbol;  }  //— 指標ハンドルを作成する  if(type==Call_iBearsPower)  handle=iBearsPower(name,period,ma_period);  else  {  //— 構造体を指標のパラメータで記入  MqlParam pars[1];  //— ma 期間      pars[0].type=TYPE_INT;  pars[0].integer_value=ma_period;  handle=IndicatorCreate(name,period,IND_BEARS,1,pars);  }  //— ハンドルが作成されなかった場合  if(handle==INVALID_HANDLE)  {  //— 失敗した事実とエラーコードを出力する  PrintFormat(“Failed to create handle of the iBearsPower indicator for the symbol %s/%s, error code %d”,  name,  EnumToString(period),  GetLastError());  //— 指標が早期に中止された  return(INIT_FAILED);  }  //— ベアパワー指標が計算された銘柄/時間軸を表示  short_name=StringFormat(“iBearsPower(%s/%s, period=%d)”,name,EnumToString(period),ma_period);  IndicatorSetString(INDICATOR_SHORTNAME,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[])  {  //— iBearsPower 指標から複製された値の数  int values_to_copy;  //— 指標で計算された値の数を決める  int calculated=BarsCalculated(handle);  if(calculated<=0)  {  PrintFormat(“BarsCalculated() returned %d, error code %d”,calculated,GetLastError());  return(0);  }  //— これが指標計算の初めであるか iBearsPower 指標の値の数が変更した  //—または、2 つ以上のバーの指標の計算が必要である場合(価格履歴で何かが変更された)  if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1)  {  //— もし iBearsPowerBuffer 配列が銘柄/期間で iBearsPower 指標の値の数より大きい場合、全体のコピーはしない  //— 他の場合、指標バッファサイズより少ない量をコピーをする  if(calculated>rates_total) values_to_copy=rates_total;  else                       values_to_copy=calculated;  }  else  {  //— これは初回の計算ではなく、  //— 前回の OnCalculate() から、一以上のバーが加えられてない。  values_to_copy=(rates_total-prev_calculated)+1;  }  //— iBearsPowerBuffer 配列をベアパワー指標の値で記入  //— FillArrayFromBuffer が false を返した場合、情報の準備が終わっていないので操作を終了する  if(!FillArrayFromBuffer(iBearsPowerBuffer,handle,values_to_copy)) return(0);  //— メッセージを形成する  string comm=StringFormat(“%s ==>  Updated value in the indicator %s: %d”,  TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS),  &nbsnbsp;              short_name,  values_to_copy);  //— チャートにサービスメッセージを表示する  Comment(comm);  //— ベアパワー指標の値の数を覚える  bars_calculated=calculated;  //— prev_calculated 値を次の関数呼び出しのために返す  return(rates_total);  }  //+——————————————————————+  //| iBearsPower 指標から指標バッファを記入する                               |  //+——————————————————————+  bool FillArrayFromBuffer(double &values[], // ベアパワー値の指標バッファ  int ind_handle,   // iBearsPower 指標ハンドル  int amount         // 複製された値の数  )  {  //— エラーコードをリセットする  ResetLastError();  //— インデックス0 を持つ指標バッファの値で iBearsPowerBuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,0,0,amount,values)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iBearsPower indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— 全てが成功  return(true);  }  //+——————————————————————+  //| 指標初期化解除関数                                                  |  //+——————————————————————+  void OnDeinit(const int reason)  {  //— 指標の削除後チャートをクリアする  Comment(“”);  }  | 
iBands
この関数は Bollinger Bands® (ボリンジャーバンド®)指標ハンドルを返します。
int  iBands(  string              symbol,              ENUM_TIMEFRAMES    period,              int                bands_period,       int                bands_shift,        double              deviation,          ENUM_APPLIED_PRICE  applied_price        );  | 
パラメータ
symbol
[in] データが指標計算に使用される有価証券の銘柄名(NULL は現在のシンボル)
period
[in] 期間の値は ENUM_TIMEFRAMES 列挙の値の 1 つで、0 は現在の時間軸の意味です。
bands_period
[in]  指標の正中線の平均期間
bands_shift
[in] 価格チャートに相対した指標のシフト
偏差
[in]  正中線からの逸脱
applied_price
[in]  使用される価格。ENUM_APPLIED_PRICE 価格定数のいずれか、または別の指標ハンドル。
戻り値
注意事項
例:
//+——————————————————————+  //|                                                  Demo_iBands.mq5 |  //|                        Copyright 2011, MetaQuotes Software Corp. |  //|                                             https://www.MQL5.com |  //+——————————————————————+  #property copyright “Copyright 2011, MetaQuotes Software Corp.”  #property link     “https://www.mql5.com”  #property version   “1.00”  #property description “The indicator demonstrates how to obtain data”  #property description “of indicator buffers for the iBands technical indicator.”  #property description “A symbol and timeframe used for calculation of the indicator,”  #property description “are set by the symbol and period parameters.”  #property description “The method of creation of the handle is set through the ‘type’ parameter (function type).” #property indicator_chart_window  #property indicator_buffers 3  #property indicator_plots   3  //— 上のプロット  #property indicator_label1 “Upper”  #property indicator_type1   DRAW_LINE  #property indicator_color1  clrMediumSeaGreen  #property indicator_style1 STYLE_SOLID  #property indicator_width1  1  //— 下のプロット  #property indicator_label2 “Lower”  #property indicator_type2   DRAW_LINE  #property indicator_color2  clrMediumSeaGreen  #property indicator_style2 STYLE_SOLID  #property indicator_width2  1  //— 真ん中のプロット  #property indicator_label3 “Middle”  #property indicator_type3   DRAW_LINE  #property indicator_color3  clrMediumSeaGreen  #property indicator_style3 STYLE_SOLID  #property indicator_width3  1  //+——————————————————————+  //| 作成を処理する方法の列挙                                              |  //+——————————————————————+  enum Creation  {  Call_iBands,           // iBands を使用する  Call_IndicatorCreate   // IndicatorCreateを使用する  };  //— 入力パラメータ  input Creation             type=Call_iBands;         // 関数の種類   input int                  bands_period=20;           // 移動平均の期間  input int                  bands_shift=0;             // シフト  input double               deviation=2.0;             // 標準偏差の数  input ENUM_APPLIED_PRICE   applied_price=PRICE_CLOSE; // 価格の種類  input string               symbol=” “;               // シンボル   input ENUM_TIMEFRAMES     period=PERIOD_CURRENT;     // 時間軸  //— 指標バッファ  double         UpperBuffer[];  double         LowerBuffer[];  double         MiddleBuffer[];  //— iBands 指標ハンドルを格納する変数  int    handle;  //— 格納に使用される変数  string name=symbol;  //— チャートでの指標名  string short_name;  //— ボリンジャーバンド指標に値の数を保存  int    bars_calculated=0;  //+——————————————————————+  //| カスタム指標を初期化する関数                                            |  //+——————————————————————+  int OnInit()  {  //— 配列の指標バッファへの割り当て  SetIndexBuffer(0,UpperBuffer,INDICATOR_DATA);  SetIndexBuffer(1,LowerBuffer,INDICATOR_DATA);  SetIndexBuffer(2,MiddleBuffer,INDICATOR_DATA);  //— それぞれの線のシフトを設定  PlotIndexSetInteger(0,PLOT_SHIFT,bands_shift);  PlotIndexSetInteger(1,PLOT_SHIFT,bands_shift);  PlotIndexSetInteger(2,PLOT_SHIFT,bands_shift);  //— 指標が描画するシンボルを決める  name=symbol;  //— 左右のスペースを削する  StringTrimRight(name);  StringTrimLeft(name);  //—「name」文字列の長さがゼロになった場合  if(StringLen(name)==0)  {  //— 指標が接続されているチャートのシンボルを取る  name=_Symbol;  }  //— 指標ハンドルを作成する  if(type==Call_iBands)  handle=iBands(name,period,bands_period,bands_shift,deviation,applied_price);  else  {  //— 構造体を指標のパラメータで記入  MqlParam pars[4];  //— ma の期間  pars[0].type=TYPE_INT;  pars[0].integer_value=bands_period;  //— シフト  pars[1].type=TYPE_INT;  pars[1].integer_value=bands_shift;  //— 標準偏差の数  pars[2].type=TYPE_DOUBLE;  pars[2].double_value=deviation;  //— 価格の種類  pars[3].type=TYPE_INT;  pars[3].integer_value=applied_price;  handle=IndicatorCreate(name,period,IND_BANDS,4,pars);  }  //— ハンドルが作成されなかった場合  if(handle==INVALID_HANDLE)  {  //— 失敗した事実とエラーコードを出力する  PrintFormat(“Failed to create handle of the iBands indicator for the symbol %s/%s, error code %d”,  name,  EnumToString(period),  GetLastError());  //— 指標が早期に中止された  return(INIT_FAILED);  }  //— ボリンジャーバンド指標が計算された銘柄/時間軸を表示  short_name=StringFormat(“iBands(%s/%s, %d,%d,%G,%s)”,name,EnumToString(period),  bands_period,bands_shift,deviation,EnumToString(applied_price));  IndicatorSetString(INDICATOR_SHORTNAME,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[])  {  //— iBands 指標から複製された値の数  int values_to_copy;  //— 指標で計算された値の数を決める  int calculated=BarsCalculated(handle);  if(calculated<=0)  {  PrintFormat(“BarsCalculated() returned %d, error code %d”,calculated,GetLastError());  return(0);  }  //— これが指標計算の初めであるか iBands 指標の値の数が変更した changed  //—または、2 つ以上のバーの指標の計算が必要である場合(価格履歴で何かが変更された)  if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1)  {  //— もし iBands 配列が銘柄/期間で iAC 指標の値の数より大きい場合、全体のコピーはしない   //— 他の場合、指標バッファサイズより少ない量をコピーをする  if(calculated>rates_total) values_to_copy=rates_total;  else                       values_to_copy=calculated;  }  else  {  //— これは初回の計算ではなく、  //— 前回の OnCalculate() から、一以上のバーが加えられてない。  values_to_copy=(rates_total-prev_calculated)+1;  }  //— 配列をボリンジャーバンド指標の値で記入  //— FillArraysFromBuffer が false を返した場合、情報の準備が終わっていないので操作を終了する  if(!FillArraysFromBuffers(MiddleBuffer,UpperBuffer,LowerBuffer,bands_shift,handle,values_to_copy)) return(0);  //— メッセージを形成する  string comm=StringFormat(“%s ==>  Updated value in the indicator %s: %d”,  TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS),  short_name,  values_to_copy);  //— チャートにサービスメッセージを表示する  Comment(comm);  //— ボリンジャーバンド指標の値の数を覚える  bars_calculated=calculated;  //— prev_calculated 値を次の関数呼び出しのために返す  return(rates_total);  }  //+——————————————————————+  //| iBands 指標から指標バッファを記入する                                     |  //+——————————————————————+  bool FillArraysFromBuffers(double &base_values[],     // ボリンジャーバンドの中線の指標バッファ  double &upper_values[],   // 上縁の指標バッファ  double &lower_values[],   // 下縁の指標バッファ  int shift,                 // シフト  int ind_handle,           // iBands 指標ハンドル  int amount                 // 複製された値の数  )  {  //— エラーコードをリセットする  ResetLastError();  //— インデックス0 を持つ指標バッファの値で MiddleBuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,0,-shift,amount,base_values)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iBands indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  } //— インデックス 1 を持つ指標バッファの値で UpperBuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,1,-shift,amount,upper_values)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iBands indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  } //— インデックス 2 を持つ指標バッファの値で LowerBuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,2,-shift,amount,lower_values)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iBands indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— 全てが成功  return(true);  }  //+——————————————————————+  //| 指標初期化解除関数                                                  |  //+——————————————————————+  void OnDeinit(const int reason)  {  //— 指標の削除後チャートをクリアする  Comment(“”);  }  | 
iBullsPower
この関数は Bulls Power (ブルパワー)指標ハンドルを返します。バッファは 1 つです。
int  iBullsPower(  string              symbol,              ENUM_TIMEFRAMES    period,             int                ma_period,          );  | 
パラメータ
symbol
[in] データが指標計算に使用される有価証券の銘柄名(NULL は現在のシンボル)
period
[in] 期間の値は ENUM_TIMEFRAMES 列挙の値の 1 つで、0 は現在の時間軸の意味です。
ma_period
[in]  指標計算の平均期間
戻り値
例:
//+——————————————————————+  //|                                             Demo_iBullsPower.mq5 |  //|                        Copyright 2011, MetaQuotes Software Corp. |  //|                                             https://www.MQL5.com |  //+——————————————————————+  #property copyright “Copyright 2011, MetaQuotes Software Corp.”  #property link     “https://www.mql5.com”  #property version   “1.00”  #property description “The indicator demonstrates how to obtain data”  #property description “of indicator buffers for the iBullsPower technical indicator.”  #property description “A symbol and timeframe used for calculation of the indicator,”  #property description “are set by the symbol and period parameters.”  #property description “The method of creation of the handle is set through the ‘type’ parameter (function type).” #property indicator_separate_window  #property indicator_buffers 1  #property indicator_plots   1  //— ブルパワープロット  #property indicator_label1 “iBullsPower”  #property indicator_type1   DRAW_HISTOGRAM  #property indicator_color1  clrSilver  #property indicator_style1 STYLE_SOLID  #property indicator_width1  1  //+——————————————————————+  //| 作成を処理する方法の列挙                                              |  //+——————————————————————+  enum Creation  {  Call_iBullsPower,       // iBullsPower を使用する  Call_IndicatorCreate   // IndicatorCreateを使用する  };  //— 入力パラメータ  input Creation             type=Call_iBullsPower; // 関数の種類   input int                  ma_period=13;           // 移動平均の期間  input string               symbol=” “;             // シンボル  input ENUM_TIMEFRAMES     period=PERIOD_CURRENT; // 時間軸  //— 指標バッファ  double         iBullsPowerBuffer[];  //— iBullsPower 指標ハンドルを格納する変数  int    handle;  //— 格納に使用される変数  string name=symbol;  //— チャートでの指標名  string short_name;  //— ブルパワー指標に値の数を保存  int    bars_calculated=0;  //+——————————————————————+  //| カスタム指標を初期化する関数                                            |  //+——————————————————————+  int OnInit()  {  //— 配列の指標バッファへの割り当て  SetIndexBuffer(0,iBullsPowerBuffer,INDICATOR_DATA);  //— 指標が描画するシンボルを決める  name=symbol;  //— 左右のスペースを削する  StringTrimRight(name);  StringTrimLeft(name);  //—「name」文字列の長さがゼロになった場合  if(StringLen(name)==0)  {  //— 指標が接続されているチャートのシンボルを取る  name=_Symbol;  }  //— 指標ハンドルを作成する  if(type==Call_iBullsPower)  handle=iBullsPower(name,period,ma_period);  else  {  //— 構造体を指標のパラメータで記入  MqlParam pars[1];  //— ma の期間  pars[0].type=TYPE_INT;  pars[0].integer_value=ma_period;  handle=IndicatorCreate(name,period,IND_BULLS,1,pars);  }  //— ハンドルが作成されなかった場合  if(handle==INVALID_HANDLE)  {  //— 失敗した事実とエラーコードを出力する  PrintFormat(“Failed to create handle of the iBullsPower indicator for the symbol %s/%s, error code %d”,  name,  EnumToString(period),  GetLastError());  //— 指標が早期に中止された  return(INIT_FAILED);  }  //— ブルパワー指標が計算された銘柄/時間軸を表示  short_name=StringFormat(“iBullsPower(%s/%s, period=%d)”,name,EnumToString(period),ma_period);  IndicatorSetString(INDICATOR_SHORTNAME,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[])  {  //— iBullsPower 指標から複製された値の数  int values_to_copy;  //— 指標で計算された値の数を決める  int calculated=BarsCalculated(handle);  if(calculated<=0)  {  PrintFormat(“BarsCalculated() returned %d, error code %d”,calculated,GetLastError());  return(0);  }  //— これが指標計算の初めであるか iBullsPower 指標の値の数が変更した  //—または、2 つ以上のバーの指標の計算が必要である場合(価格履歴で何かが変更された)  if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1)  {  //— もし iBullsPowerBuffer 配列が銘柄/期間で iBullsPower 指標の値の数より大きい場合、全体のコピーはしない   //— 他の場合、指標バッファサイズより少ない量をコピーをする  if(calculated>rates_total) values_to_copy=rates_total;  else                       values_to_copy=calculated;  }  else  {  //— これは初回の計算ではなく、  //— 前回の OnCalculate() から、一以上のバーが加えられてない。  values_to_copy=(rates_total-prev_calculated)+1;  }  //— iBullsPowerBuffer 配列をブルパワー指標の値で記入  //— FillArrayFromBuffer が false を返した場合、情報の準備が終わっていないので操作を終了する  if(!FillArrayFromBuffer(iBullsPowerBuffer,handle,values_to_copy)) return(0);  //— メッセージを形成する  string comm=StringFormat(“%s ==>  Updated value in the indicator %s: %d”,  TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS),  short_name,  values_to_copy);  //— チャートにサービスメッセージを表示する  Comment(comm);  //— ブルパワー指標の値の数を覚える  bars_calculated=calculated;  //— prev_calculated 値を次の関数呼び出しのために返す  return(rates_total);  }  //+——————————————————————+  //| iBullsPower 指標から指標バッファを記入する                                |  //+——————————————————————+  bool FillArrayFromBuffer(double &values[], // ブルパワー値の指標バッファ  int ind_handle,   // iBullsPower 指標ハンドル  int amount         // 複製された値の数  )  {  //— エラーコードをリセットする  ResetLastError();  //— インデックス0 を持つ指標バッファの値で iBullsPowerBuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,0,0,amount,values)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iBullsPower indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— 全てが成功  return(true);  }  //+——————————————————————+  //| 指標初期化解除関数                                                  |  //+——————————————————————+  void OnDeinit(const int reason)  {  //— 指標の削除後チャートをクリアする  Comment(“”);  }  //+——————————————————————+  | 
iCCI
この関数は CCI(Commodity Channel Index、商品チャンネル指数)指標ハンドルを返します。バッファは 1 つです。
int  iCCI(  string              symbol,              ENUM_TIMEFRAMES    period,              int                ma_period,          ENUM_APPLIED_PRICE  applied_price      );  | 
パラメータ
symbol
[in] データが指標計算に使用される有価証券の銘柄名(NULL は現在のシンボル)
period
[in] 期間の値は ENUM_TIMEFRAMES 列挙の値の 1 つで、0 は現在の時間軸の意味です。
ma_period
[in]  指標計算の平均期間
applied_price
[in]  使用される価格。ENUM_APPLIED_PRICE 価格定数のいずれか、または別の指標ハンドル。
戻り値
例:
//+——————————————————————+  //|                                                    Demo_iCCI.mq5 |  //|                        Copyright 2011, MetaQuotes Software Corp. |  //|                                             https://www.MQL5.com |  //+——————————————————————+  #property copyright “Copyright 2011, MetaQuotes Software Corp.”  #property link     “https://www.mql5.com”  #property version   “1.00”  #property description “The indicator demonstrates how to obtain data”  #property description “of indicator buffers for the iCCI technical indicator.”  #property description “A symbol and timeframe used for calculation of the indicator,”  #property description “are set by the symbol and period parameters.”  #property description “The method of creation of the handle is set through the ‘type’ parameter (function type).” #property indicator_separate_window  #property indicator_buffers 1  #property indicator_plots   1  //— iCCI プロット  #property indicator_label1 “iCCI”  #property indicator_type1   DRAW_LINE  #property indicator_color1  clrLightSeaGreen  #property indicator_style1 STYLE_SOLID  #property indicator_width1  1  //— 指標ウィンドウの水平レベル  #property indicator_level1  -100.0  #property indicator_level2  100.0  //+——————————————————————+  //| 作成を処理する方法の列挙                                              |  //+——————————————————————+  enum Creation  {  Call_iCCI,             // iCCI を使用する  Call_IndicatorCreate   // IndicatorCreateを使用する  };  //— 入力パラメータ  input Creation             type=Call_iCCI;               // 関数の種類  input int                  ma_period=14;                 // 移動平均の期間  input ENUM_APPLIED_PRICE   applied_price=PRICE_TYPICAL; // 価格の種類  input string               symbol=” “;                   // シンボル   input ENUM_TIMEFRAMES     period=PERIOD_CURRENT;       // 時間軸  //— 指標バッファ  double         iCCIBuffer[];  //— iCCI 指標ハンドルを格納する変数r  int    handle;  //— 格納に使用される変数  string name=symbol;  //— チャートでの指標名  string short_name;  //— CCI 指標に値の数を保存  int    bars_calculated=0;  //+——————————————————————+  //| カスタム指標を初期化する関数                                            |  //+——————————————————————+  int OnInit()  {  //— 配列の指標バッファへの割り当て  SetIndexBuffer(0,iCCIBuffer,INDICATOR_DATA);  //— 指標が描画するシンボルを決める  name=symbol;  //— 左右のスペースを削する  StringTrimRight(name);  StringTrimLeft(name);  //—「name」文字列の長さがゼロになった場合  if(StringLen(name)==0)  {  //— 指標が接続されているチャートのシンボルを取る  name=_Symbol;  }  //— 指標ハンドルを作成する  if(type==Call_iCCI)  handle=iCCI(name,period,ma_period,applied_price);  else  {  //— 構造体を指標のパラメータで記入  MqlParam pars[2];  //— 移動平均の期間  pars[0].type=TYPE_INT;  pars[0].integer_value=ma_period;  //— 価格の種類  pars[1].type=TYPE_INT;  pars[1].integer_value=applied_price;  handle=IndicatorCreate(name,period,IND_CCI,2,pars);  }  //— ハンドルが作成されなかった場合  if(handle==INVALID_HANDLE)  {  //— 失敗した事実とエラーコードを出力する  PrintFormat(“Failed to create handle of the iCCI indicator for the symbol %s/%s, error code %d”,  name,  EnumToString(period),  GetLastError());  //— 指標が早期に中止された  return(INIT_FAILED);  }  //— CCI 指標が計算された銘柄/時間軸を表示  short_name=StringFormat(“iCCI(%s/%s, %d, %s)”,name,EnumToString(period),  ma_period,EnumToString(applied_price));  IndicatorSetString(INDICATOR_SHORTNAME,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[])  {  //— iCCI 指標から複製された値の数  int values_to_copy;  //— 指標で計算された値の数を決める  int calculated=BarsCalculated(handle);  if(calculated<=0)  {  PrintFormat(“BarsCalculated() returned %d, error code %d”,calculated,GetLastError());  return(0);  }  //— これが指標計算の初めであるか iCCI 指標の値の数が変更した  //—または、2 つ以上のバーの指標の計算が必要である場合(価格履歴で何かが変更された)  if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1)  {  //— もし iCCIBuffer 配列が銘柄/期間で iCCI 指標の値の数より大きい場合、全体のコピーはしない  //— 他の場合、指標バッファサイズより少ない量をコピーをする  if(calculated>rates_total) values_to_copy=rates_total;  else                       values_to_copy=calculated;  }  else  {  //— これは初回の計算ではなく、  //— 前回の OnCalculate() から、一以上のバーが加えられてない。  values_to_copy=(rates_total-prev_calculated)+1;  }  //— iCCIBuffer 配列を CCI 指標の値で記入  //— FillArrayFromBuffer が false を返した場合、情報の準備が終わっていないので操作を終了する  if(!FillArrayFromBuffer(iCCIBuffer,handle,values_to_copy)) return(0);  //— メッセージを形成する  string comm=StringFormat(“%s ==>  Updated value in the indicator %s: %d”,  TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS),  short_name,  values_to_copy);  //— チャートにサービスメッセージを表示する  Comment(comm);  //— CCI 指標の値の数を覚える  bars_calculated=calculated;  //— prev_calculated 値を次の関数呼び出しのために返す  return(rates_total);  }  //+——————————————————————+  //| iCCI 指標から指標バッファを記入する                                       |  //+——————————————————————+  bool FillArrayFromBuffer(double &values[], // CCI 値の指標バッファ  int ind_handle,   // iCCI 指標ハンドル  int amount         // 複製された値の数  )  {  //— エラーコードをリセットする  ResetLastError();  //— インデックス0 を持つ指標バッファの値で iCCIBuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,0,0,amount,values)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iCCI indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— 全てが成功  return(true);  }  //+——————————————————————+  //| 指標初期化解除関数                              |  //+——————————————————————+  void OnDeinit(const int reason)  {  //— 指標の削除後チャートをクリアする  Comment(“”);  }  | 
iChaikin
この関数は Chaikin Oscillator(チャイキンオシレーター)指標のハンドルを返します。バッファは 1 つです。
int  iChaikin(  string              symbol,              ENUM_TIMEFRAMES      period,              int                  fast_ma_period,      int                  slow_ma_period,      ENUM_MA_METHOD      ma_method,            ENUM_APPLIED_VOLUME  applied_volume       );  | 
パラメータ
symbol
[in] データが指標計算に使用される有価証券の銘柄名(NULL は現在のシンボル)
period
[in] 期間の値は ENUM_TIMEFRAMES 列挙の値の 1 つで、0 は現在の時間軸の意味です。
fast_ma_period
[in] 計算の高速平均期間
slow_ma_period
[in] 計算の低速平均期間
ma_method
[in]  平滑化の種類(ENUM_MA_METHOD 定数のいずれか)
applied_volume
[in]  使用されるボリューム(ENUM_APPLIED_VOLUME 定数のいずれか)
戻り値
例:
//+——————————————————————+  //|                                                Demo_iChaikin.mq5 |  //|                        Copyright 2011, MetaQuotes Software Corp. |  //|                                             https://www.MQL5.com |  //+——————————————————————+  #property copyright “Copyright 2011, MetaQuotes Software Corp.”  #property link     “https://www.mql5.com”  #property version   “1.00”  #property description “The indicator demonstrates how to obtain data”  #property description “of indicator buffers for the iChaikin technical indicator.”  #property description “A symbol and timeframe used for calculation of the indicator,”  #property description “are set by the symbol and period parameters.”  #property description “The method of creation of the handle is set through the ‘type’ parameter (function type).” #property indicator_separate_window  #property indicator_buffers 1  #property indicator_plots   1  //— iChaikin プロット  #property indicator_label1 “iChaikin”  #property indicator_type1   DRAW_LINE  #property indicator_color1  clrLightSeaGreen  #property indicator_style1 STYLE_SOLID  #property indicator_width1  1  //+——————————————————————+  //| 作成を処理する方法の列挙                                              |  //+——————————————————————+  enum Creation  {  Call_iChaikin,         // iChaikinを使用する  Call_IndicatorCreate   // IndicatorCreateを使用する  };  //— 入力パラメータ  input Creation             type=Call_iChaikin;           // 関数の種類   input int                  fast_ma_period=3;             // 高速 MA 期間  input int                  slow_ma_period=10;           // 低速 MA 期間  input ENUM_MA_METHOD       ma_method=MODE_EMA;           // 平滑化の種類  input ENUM_APPLIED_VOLUME  applied_volume=VOLUME_TICK;   // ボリュームの種類  input string               symbol=” “;                   // シンボル   input ENUM_TIMEFRAMES     period=PERIOD_CURRENT;       // 時間軸  //— 指標バッファ  double         iChaikinBuffer[];  //— iChaikin 指標ハンドルを格納する変数  int    handle;  //— 格納に使用される変数  string name=symbol;  //— チャートでの指標名  string short_name;  //— チャイキンオシレーター 指標に値の数を保存  int    bars_calculated=0;  //+——————————————————————+  //| カスタム指標を初期化する関数                                            |  //+——————————————————————+  int OnInit()  {  //— 配列の指標バッファへの割り当て  SetIndexBuffer(0,iChaikinBuffer,INDICATOR_DATA);  //— 指標が描画するシンボルを決める  name=symbol;  //— 左右のスペースを削する  StringTrimRight(name);  StringTrimLeft(name);  //—「name」文字列の長さがゼロになった場合  if(StringLen(name)==0)  {  //— 指標が接続されているチャートのシンボルを取る  name=_Symbol;  }  //— 指標ハンドルを作成する  if(type==Call_iChaikin)  handle=iChaikin(name,period,fast_ma_period,slow_ma_period,ma_method,applied_volume);  else  {  //— 構造体を指標のパラメータで記入  MqlParam pars[4];  //— 高速 MA 期間  pars[0].type=TYPE_INT;  pars[0].integer_value=fast_ma_period;  //— 低速 MA 期間  pars[1].type=TYPE_INT;  pars[1].integer_value=slow_ma_period;  //— 平滑化の種類  pars[2].type=TYPE_INT;  pars[2].integer_value=ma_method;  //— ボリュームの種類  pars[3].type=TYPE_INT;  pars[3].integer_value=applied_volume;  handle=IndicatorCreate(name,period,IND_CHAIKIN,4,pars);  }  //— ハンドルが作成されなかった場合  if(handle==INVALID_HANDLE)  {  //— 失敗した事実とエラーコードを出力する  PrintFormat(“Failed to create handle of the iChaikin indicator for the symbol %s/%s, error code %d”,  name,  EnumToString(period),  GetLastError());  //— 指標が早期に中止された  return(INIT_FAILED);  }  //— チャイキンオシレーター 指標が計算された銘柄/時間軸を表示  short_name=StringFormat(“iChaikin(%s/%s, %d, %d, %s, %s)”,name,EnumToString(period),  fast_ma_period,slow_ma_period,  EnumToString(ma_method),EnumToString(applied_volume));  IndicatorSetString(INDICATOR_SHORTNAME,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[])  {  //— iChaikin 指標から複製された値の数r  int values_to_copy;  //— 指標で計算された値の数を決める  int calculated=BarsCalculated(handle);  if(calculated<=0)  {  PrintFormat(“BarsCalculated() returned %d, error code %d”,calculated,GetLastError());  return(0);  }  //— これが指標計算の初めであるか iChaikin 指標の値の数が変更した  //—または、2 つ以上のバーの指標の計算が必要である場合(価格履歴で何かが変更された)  if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1)  {  //— もし iChaikinBuffer 配列が銘柄/期間でiChaikin 指標の値の数より大きい場合、全体のコピーはしない   //— 他の場合、指標バッファサイズより少ない量をコピーをする  if(calculated>rates_total) values_to_copy=rates_total;  else                       values_to_copy=calculated;  }  else  {  //— これは初回の計算ではなく、  //— 前回の OnCalculate() から、一以上のバーが加えられてない。  values_to_copy=(rates_total-prev_calculated)+1;  }  //— iChaikinBuffer 配列を チャイキンオシレーター 指標の値で記入  //— FillArrayFromBuffer が false を返した場合、情報の準備が終わっていないので操作を終了する  if(!FillArrayFromBuffer(iChaikinBuffer,handle,values_to_copy)) return(0);  //— メッセージを形成する  string comm=StringFormat(“%s ==>  Updated value in the indicator %s: %d”,  TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS),  short_name,  values_to_copy);  //— チャートにサービスメッセージを表示する  Comment(comm);  //— チャイキンオシレーター 指標の値の数を覚える  bars_calculated=calculated;  //— prev_calculated 値を次の関数呼び出しのために返す  return(rates_total);  }  //+——————————————————————+  //| iChaikin 指標から指標バッファを記入する                                   |  //+——————————————————————+  bool FillArrayFromBuffer(double &values[], // チャイキンオシレーター 値の指標バッファ  int ind_handle,   // iChaikin 指標ハンドル  int amount         // 複製された値の数  )  {  //— エラーコードをリセットする  ResetLastError();  //— インデックス0 を持つ指標バッファの値で iChaikinBuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,0,0,amount,values)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iChaikin indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— 全てが成功  return(true);  }  //+——————————————————————+  //| 指標初期化解除関数                                                  |  //+——————————————————————+  void OnDeinit(const int reason)  {  //— 指標の削除後チャートをクリアする  Comment(“”);  }  | 
iCustom
この関数は指定されたカスタム指標ハンドルを返します。
int  iCustom(  string          symbol,      ENUM_TIMEFRAMES  period,      string          name             …                            );  | 
パラメータ
symbol
[in] データが指標計算に使用される有価証券の銘柄名(NULL は現在のシンボル)
period
[in] 期間の値は ENUM_TIMEFRAMES 列挙の値の 1 つで、0 は現在の時間軸の意味です。
name
[in]  指標のルートディレクトリ(MQL5/Indicators/)からの相対パスを使用したカスタム指標の名称。指標が、例えば MQL5/Indicators/Examples サブディレクトリに位置する場合、名称は “Examples\indicator_name” (セパレータとして単一のスラッシュの代わりにダブルスラッシュを使用する必要があります)の様に指定される必要があります。
…
[in]  コンマで区切られたカスタム指標の入力パラメータパラメータの種類と順序が一致している必要があります。パラメータの指定がない場合は初期値が使用されます。
戻り値
注意事項
#property tester_indicator “indicator_name.ex5”  | 
MQL5 プログラムからカスタム指標が呼ばれる場合、Applied_Price パラメータまたは別の指標ハンドルは、カスタム指標の他の入力パラメータ全ての後で受け渡しされるべきです。
参照
プログラムプロパティ、時系列と指標へのアクセス、IndicatorCreate()、IndicatorRelease()
例:
#property indicator_separate_window  #property indicator_buffers 1  #property indicator_plots   1  //—- Label1 をプロットする  #property indicator_label1 “Label1”  #property indicator_type1   DRAW_LINE  #property indicator_color1 clrRed  #property indicator_style1 STYLE_SOLID  #property indicator_width1  1  //— 入力パラメータ  input int MA_Period=21;  input int MA_Shift=0;  input ENUM_MA_METHOD MA_Method=MODE_SMA;  //— 指標バッファ  double         Label1Buffer[];  //— Custom Moving Average.mq5 カスタム指標ハンドル  int MA_handle;  //+——————————————————————+  //| カスタム指標を初期化する関数                                            |  //+——————————————————————+  int OnInit()  {  //— 指標バッファマッピング  SetIndexBuffer(0,Label1Buffer,INDICATOR_DATA);  ResetLastError();  MA_handle=iCustom(NULL,0,“Examples\Custom Moving Average”,  MA_Period,  MA_Shift,  MA_Method,  PRICE_CLOSE // 終値の使用  );  Print(“MA_handle = “,MA_handle,”  error = “,GetLastError());  //—  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[])  {  //— 指標 Custom Moving Average の値を指標バッファに複製する  int copy=CopyBuffer(MA_handle,0,0,rates_total,Label1Buffer);  Print(“copy = “,copy,”    rates_total = “,rates_total);  //— I試みが失敗したら報告する  if(copy<=0)  Print(“An attempt to get the values if Custom Moving Average has failed”);  //— 次の呼び出しのために prev_calculated の値を返す  return(rates_total);  }  //+——————————————————————+  | 
iDEMA
この関数は Double Exponential Moving Average( 2 重指数移動平均)指標のハンドルを返します。バッファは 1 つです。
int  iDEMA(  string              symbol,              ENUM_TIMEFRAMES    period,              int                ma_period,          int                ma_shift,            ENUM_APPLIED_PRICE  applied_price        );  | 
パラメータ
symbol
[in] データが指標計算に使用される有価証券の銘柄名(NULL は現在のシンボル)
period
[in] 期間の値は ENUM_TIMEFRAMES 列挙の値の 1 つで、0 は現在の時間軸の意味です。
ma_period
[in] 計算の平均期間(バーの数)
ma_shift
[in]  価格チャートに相対した指標のシフト
applied_price
[in]  使用される価格。ENUM_APPLIED_PRICE 価格定数のいずれか、または別の指標ハンドル。
戻り値
例:
//+——————————————————————+  //|                                                   Demo_iDEMA.mq5 |  //|                        Copyright 2011, MetaQuotes Software Corp. |  //|                                             https://www.MQL5.com |  //+——————————————————————+  #property copyright “Copyright 2011, MetaQuotes Software Corp.”  #property link     “https://www.mql5.com”  #property version   “1.00”  #property description “The indicator demonstrates how to obtain data”  #property description “of indicator buffers for the iDEMA technical indicator.”  #property description “A symbol and timeframe used for calculation of the indicator,”  #property description “are set by the symbol and period parameters.”  #property description “The method of creation of the handle is set through the ‘type’ parameter (function type).” #property indicator_chart_window  #property indicator_buffers 1  #property indicator_plots   1  //— iDEMA プロット  #property indicator_label1 “iDEMA”  #property indicator_type1   DRAW_LINE  #property indicator_color1  clrRed  #property indicator_style1 STYLE_SOLID  #property indicator_width1  1  //+——————————————————————+  //| 作成を処理する方法の列挙                                              |  //+——————————————————————+  enum Creation  {  Call_iDEMA,             // iDEMA を使用する  Call_IndicatorCreate   // IndicatorCreateを使用する  };  //— 入力パラメータ  input Creation             type=Call_iDEMA;           // 関数の種類   input int                  ma_period=14;             // 移動平均の期間  input int                  ma_shift=0;               // シフト  input ENUM_APPLIED_PRICE   applied_price=PRICE_CLOSE; // 価格の種類  input string               symbol=” “;               // シンボル   input ENUM_TIMEFRAMES     period=PERIOD_CURRENT;     // 時間軸  //— 指標バッファ  double         iDEMABuffer[];  //— iDEMA 指標ハンドルを格納する変数  int    handle;  //— 格納に使用される変数  string name=symbol;  //— チャートでの指標名  string short_name;  //— 2 重指数移動平均指標に値の数を保存  int    bars_calculated=0;  //+——————————————————————+  //| カスタム指標を初期化する関数                                            |  //+——————————————————————+  int OnInit()  {  //— 配列の指標バッファへの割り当て  SetIndexBuffer(0,iDEMABuffer,INDICATOR_DATA);  //— シフトを設定  PlotIndexSetInteger(0,PLOT_SHIFT,ma_shift);  //— 指標が描画するシンボルを決める  name=symbol;  //— 左右のスペースを削する  StringTrimRight(name);  StringTrimLeft(name);  //—「name」文字列の長さがゼロになった場合  if(StringLen(name)==0)  {  //— 指標が接続されているチャートのシンボルを取る  name=_Symbol;  }  //— 指標ハンドルを作成する  if(type==Call_iDEMA)  handle=iDEMA(name,period,ma_period,ma_shift,applied_price);  else  {  //— 構造体を指標のパラメータで記入  MqlParam pars[3];  //— 移動平均の期間  pars[0].type=TYPE_INT;  pars[0].integer_value=ma_period;  //— シフト  pars[1].type=TYPE_INT;  pars[1].integer_value=ma_shift;  //— 価格の種類  pars[2].type=TYPE_INT;  pars[2].integer_value=applied_price;  handle=IndicatorCreate(name,period,IND_DEMA,3,pars);  }  //— ハンドルが作成されなかった場合  if(handle==INVALID_HANDLE)  {  //— 失敗した事実とエラーコードを出力する  PrintFormat(“Failed to create handle of the iDEMA indicator for the symbol %s/%s, error code %d”,  name,  EnumToString(period),  GetLastError());  //— 指標が早期に中止された  return(INIT_FAILED);  }  //— 2 重指数移動平均指標が計算された銘柄/時間軸を表示  short_name=StringFormat(“iDEMA(%s/%s, %d, %d, %s)”,name,EnumToString(period),  ma_period,ma_shift,EnumToString(applied_price));  IndicatorSetString(INDICATOR_SHORTNAME,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[])  {  //— iDEMA 指標から複製された値の数  int values_to_copy;  //— 指標で計算された値の数を決める  int calculated=BarsCalculated(handle);  if(calculated<=0)  {  PrintFormat(“BarsCalculated() returned %d, error code %d”,calculated,GetLastError());  return(0);  }  //— これが指標計算の初めであるか iDEMA 指標の値の数が変更した  //—または、2 つ以上のバーの指標の計算が必要である場合(価格履歴で何かが変更された)  if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1)  {  //— もし iDEMABuffer 配列が銘柄/期間で iDEMA 指標の値の数より大きい場合、全体のコピーはしない  //— 他の場合、指標バッファサイズより少ない量をコピーをする  if(calculated>rates_total) values_to_copy=rates_total;  else                       values_to_copy=calculated;  }  else  {  //— これは初回の計算ではなく、  //— 前回の OnCalculate() から、一以上のバーが加えられてない。  values_to_copy=(rates_total-prev_calculated)+1;  }  //— iDEMABuffer 配列を ouble Exponential Moving Average 指標の値で記入  //— FillArrayFromBuffer が false を返した場合、情報の準備が終わっていないので操作を終了する  if(!FillArrayFromBuffer(iDEMABuffer,ma_shift,handle,values_to_copy)) return(0);  //— メッセージを形成する  string comm=StringFormat(“%s ==>  Updated value in the indicator %s: %d”,  TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS),  short_name,  values_to_copy);  //— チャートにサービスメッセージを表示する  Comment(comm);  //— 2 重指数移動平均指標の値の数を覚える  bars_calculated=calculated;  //— prev_calculated 値を次の関数呼び出しのために返す  return(rates_total);  }  //+——————————————————————+  //| iDEMA 指標から指標バッファを記入する                                      |  //+——————————————————————+  bool FillArrayFromBuffer(double &values[], // 2 重指数移動平均 値の指標バッファ  int shift,         // シフト  int ind_handle,   // iDEMA 指標ハンドル  int amount         // 複製された値の数  )  {  //— エラーコードをリセットする  ResetLastError();  //— インデックス0 を持つ指標バッファの値で iDEMABuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,0,-shift,amount,values)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iDEMA indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— 全てが成功  return(true);  }  //+——————————————————————+  //| 指標初期化解除関数                                                  |  //+——————————————————————+  void OnDeinit(const int reason)  {  //— 指標の削除後チャートをクリアする  Comment(“”);  }  | 
iDeMarker
この関数は DeMarker (デマーカー)指標のハンドルを返します。バッファは 1 つです。
int  iDeMarker(  string          symbol,          ENUM_TIMEFRAMES  period,          int              ma_period        );  | 
パラメータ
symbol
[in] データが指標計算に使用される有価証券の銘柄名(NULL は現在のシンボル)
period
[in] 期間の値は ENUM_TIMEFRAMES 列挙の値の 1 つで、0 は現在の時間軸の意味です。
ma_period
[in] 計算の平均期間(バーの数)
戻り値
例:
//+——————————————————————+  //|                                               Demo_iDeMarker.mq5 |  //|                        Copyright 2011, MetaQuotes Software Corp. |  //|                                             https://www.MQL5.com |  //+——————————————————————+  #property copyright “Copyright 2011, MetaQuotes Software Corp.”  #property link     “https://www.mql5.com”  #property version   “1.00”  #property description “The indicator demonstrates how to obtain data”  #property description “of indicator buffers for the iDeMarker technical indicator.”  #property description “A symbol and timeframe used for calculation of the indicator,”  #property description “are set by the symbol and period parameters.”  #property description “The method of creation of the handle is set through the ‘type’ parameter (function type).” #property indicator_separate_window  #property indicator_buffers 1  #property indicator_plots   1  //— iDeMarker プロット  #property indicator_label1 “iDeMarker”  #property indicator_type1   DRAW_LINE  #property indicator_color1  clrLightSeaGreen  #property indicator_style1 STYLE_SOLID  #property indicator_width1  1  //— 指標ウィンドウの水平レベル  #property indicator_level1  0.3  #property indicator_level2  0.7  //+——————————————————————+  //| 作成を処理する方法の列挙                                              |  //+——————————————————————+  enum Creation  {  Call_iDeMarker,         // iDeMarker を使用する  Call_IndicatorCreate   // IndicatorCreateを使用する  };  //— 入力パラメータ  input Creation             type=Call_iDeMarker;       // 関数の種類   input int                  ma_period=14;             // 移動平均の期間  input string               symbol=” “;               // シンボル   input ENUM_TIMEFRAMES     period=PERIOD_CURRENT;     // 時間軸  //— 指標バッファ  double         iDeMarkerBuffer[];  //— iDeMarker 指標ハンドルを格納する変数  int    handle;  //— 格納に使用される変数  string name=symbol;  //— チャートでの指標名  string short_name;  //— DeMarker 指標に値の数を保存  int    bars_calculated=0;  //+——————————————————————+  //| カスタム指標を初期化する関数                                            |  //+——————————————————————+  int OnInit()  {  //— 配列の指標バッファへの割り当て  SetIndexBuffer(0,iDeMarkerBuffer,INDICATOR_DATA);  //— 指標が描画するシンボルを決める  name=symbol;  //— 左右のスペースを削する  StringTrimRight(name);  StringTrimLeft(name);  //—「name」文字列の長さがゼロになった場合  if(StringLen(name)==0)  {  //— 指標が接続されているチャートのシンボルを取る  name=_Symbol;  }  //— 指標ハンドルを作成する  if(type==Call_iDeMarker)  handle=iDeMarker(name,period,ma_period);  else  {  //— 構造体を指標のパラメータで記入  MqlParam pars[1];  //— 移動平均の期間  pars[0].type=TYPE_INT;  pars[0].integer_value=ma_period;  handle=IndicatorCreate(name,period,IND_DEMARKER,1,pars);  }  //— ハンドルが作成されなかった場合  if(handle==INVALID_HANDLE)  {  //— 失敗した事実とエラーコードを出力する  PrintFormat(“Failed to create handle of the iDeMarker indicator for the symbol %s/%s, error code %d”,  name,  EnumToString(period),  GetLastError());  //— 指標が早期に中止された  return(INIT_FAILED);  }  //— DeMarker 指標が計算された銘柄/時間軸を表示  short_name=StringFormat(“iDeMarker(%s/%s, period=%d)”,name,EnumToString(period),ma_period);  IndicatorSetString(INDICATOR_SHORTNAME,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[])  {  //— iDeMarker 指標から複製された値の数  int values_to_copy;  //— 指標で計算された値の数を決める  int calculated=BarsCalculated(handle);  if(calculated<=0)  {  PrintFormat(“BarsCalculated() returned %d, error code %d”,calculated,GetLastError());  return(0);  }  //— これが指標計算の初めであるか iDeMarker 指標の値の数が変更した  //—または、2 つ以上のバーの指標の計算が必要である場合(価格履歴で何かが変更された)  if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1)  {  //— もし iDeMarkerBuffer 配列が銘柄/期間で iDeMarker 指標の値の数より大きい場合、全体のコピーはしない  //— 他の場合、指標バッファサイズより少ない量をコピーをする  if(calculated>rates_total) values_to_copy=rates_total;  else                       values_to_copy=calculated;  }  else  {  //— これは初回の計算ではなく、  //— 前回の OnCalculate() から、一以上のバーが加えられてない。  values_to_copy=(rates_total-prev_calculated)+1;  }  //— iDeMarkerBuffer 配列を DeMarker 指標の値で記入  //— FillArrayFromBuffer が false を返した場合、情報の準備が終わっていないので操作を終了する  if(!FillArrayFromBuffer(iDeMarkerBuffer,handle,values_to_copy)) return(0);  //— メッセージを形成する  string comm=StringFormat(“%s ==>  Updated value in the indicator %s: %d”,  TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS),  short_name,  values_to_copy);  //— チャートにサービスメッセージを表示する  Comment(comm);  //— DeMarker 指標の値の数を覚える  bars_calculated=calculated;  //— prev_calculated 値を次の関数呼び出しのために返す  return(rates_total);  }  //+——————————————————————+  //| iDeMarker 指標から指標バッファを記入する                                  |  //+——————————————————————+  bool FillArrayFromBuffer(double &values[], // DeMarker 値の指標バッファ  int ind_handle,   // iDeMarker 指標ハンドル  int amount         // 複製された値の数  )  {  //— エラーコードをリセットする  ResetLastError();  //— インデックス0 を持つ指標バッファの値で iDeMarkerBuffer 配列の一部を記入するx  if(CopyBuffer(ind_handle,0,0,amount,values)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iDeMarker indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— 全てが成功  return(true);  }  //+——————————————————————+  //| 指標初期化解除関数                                                  |  //+——————————————————————+  void OnDeinit(const int reason)  {  //— 指標の削除後チャートをクリアする  Comment(“”);  }  | 
iEnvelopes
この関数は Envelopes (エンベロープ)指標のハンドルを返します。
int  iEnvelopes(  string              symbol,              ENUM_TIMEFRAMES    period,              int                ma_period,          int                ma_shift,            ENUM_MA_METHOD      ma_method,          ENUM_APPLIED_PRICE  applied_price,      double              deviation            );  | 
パラメータ
symbol
[in] データが指標計算に使用される有価証券の銘柄名(NULL は現在のシンボル)
period
[in] 期間の値は ENUM_TIMEFRAMES 列挙の値の 1 つで、0 は現在の時間軸の意味です。
ma_period
[in] 正中線の平均期間
ma_shift
[in]  価格チャートに相対した指標のシフト
ma_method
[in]  平滑化の種類ENUM_MA_METHOD のいずれかの値
applied_price
[in]  使用される価格。ENUM_APPLIED_PRICE 価格定数のいずれか、または別の指標ハンドル。
偏差
[in]  百分率での正中線からのズレ
戻り値
注意事項
例:
//+——————————————————————+  //|                                              Demo_iEnvelopes.mq5 |  //|                        Copyright 2011, MetaQuotes Software Corp. |  //|                                             https://www.MQL5.com |  //+——————————————————————+  #property copyright “Copyright 2011, MetaQuotes Software Corp.”  #property link     “https://www.mql5.com”  #property version   “1.00”  #property description “The indicator demonstrates how to obtain data”  #property description “of indicator buffers for the iEnvelopes technical indicator.”  #property description “A symbol and timeframe used for calculation of the indicator,”  #property description “are set by the symbol and period parameters.”  #property description “The method of creation of the handle is set through the ‘type’ parameter (function type).” #property indicator_chart_window  #property indicator_buffers 2  #property indicator_plots   2  //— 上のプロット  #property indicator_label1 “Upper”  #property indicator_type1   DRAW_LINE  #property indicator_color1  clrBlue  #property indicator_style1 STYLE_SOLID  #property indicator_width1  1  //— 下のプロット  #property indicator_label2 “Lower”  #property indicator_type2   DRAW_LINE  #property indicator_color2  clrRed  #property indicator_style2 STYLE_SOLID  #property indicator_width2  1  //+——————————————————————+  //| 作成を処理する方法の列挙                                              |  //+——————————————————————+  enum Creation  {  Call_iEnvelopes,       // iEnvelopes を使用する  Call_IndicatorCreate   // IndicatorCreateを使用する  };  //— 入力パラメータ  input Creation             type=Call_iEnvelopes;     // 関数の種類   input int                  ma_period=14;             // 移動平均の期間  input int                  ma_shift=0;               // シフト   input ENUM_MA_METHOD       ma_method=MODE_SMA;       // 平滑化の種類  input ENUM_APPLIED_PRICE   applied_price=PRICE_CLOSE; // 価格の種類  input double               deviation=0.1;             // 堺の移動平均からの偏差  input string               symbol=” “;               // シンボル   input ENUM_TIMEFRAMES     period=PERIOD_CURRENT;     // 時間軸  //— 指標バッファ  double         UpperBuffer[];  double         LowerBuffer[];  //— iEnvelopes 指標ハンドルを格納する変数  int    handle;  //— 格納に使用される変数  string name=symbol;  //— チャートでの指標名  string short_name;  //— Envelopes 指標に値の数を保存  int    bars_calculated=0;  //+——————————————————————+  //| カスタム指標を初期化する関数                                            |  //+——————————————————————+  int OnInit()  {  //— 配列の指標バッファへの割り当て  SetIndexBuffer(0,UpperBuffer,INDICATOR_DATA);  SetIndexBuffer(1,LowerBuffer,INDICATOR_DATA);  //— それぞれの線のシフトを設定  PlotIndexSetInteger(0,PLOT_SHIFT,ma_shift);  PlotIndexSetInteger(1,PLOT_SHIFT,ma_shift);  //— 指標が描画するシンボルを決める  name=symbol;  //— 左右のスペースを削する  StringTrimRight(name);  StringTrimLeft(name);  //—「name」文字列の長さがゼロになった場合  if(StringLen(name)==0)  {  //— 指標が接続されているチャートのシンボルを取る  name=_Symbol;  }  //— 指標ハンドルを作成する  if(type==Call_iEnvelopes)  handle=iEnvelopes(name,period,ma_period,ma_shift,ma_method,applied_price,deviation);  else  {  //— 構造体を指標のパラメータで記入  MqlParam pars[5];  //— 移動平均の期間  pars[0].type=TYPE_INT;  pars[0].integer_value=ma_period;  //— シフト  pars[1].type=TYPE_INT;  pars[1].integer_value=ma_shift;  //— 平滑化の種類  pars[2].type=TYPE_INT;  pars[2].integer_value=ma_method;  //— 価格の種類  pars[3].type=TYPE_INT;  pars[3].integer_value=applied_price;  //— 価格の種類  pars[4].type=TYPE_DOUBLE;  pars[4].double_value=deviation;  handle=IndicatorCreate(name,period,IND_ENVELOPES,5,pars);  }  //— ハンドルが作成されなかった場合  if(handle==INVALID_HANDLE)  {  //— 失敗した事実とエラーコードを出力する  PrintFormat(“Failed to create handle of the iEnvelopes indicator for the symbol %s/%s, error code %d”,  name,  EnumToString(period),  GetLastError());  //— 指標が早期に中止された  return(INIT_FAILED);  }  //— Envelopes 指標が計算された銘柄/時間軸を表示  short_name=StringFormat(“iEnvelopes(%s/%s, %d, %d, %s,%s, %G)”,name,EnumToString(period),  ma_period,ma_shift,EnumToString(ma_method),EnumToString(applied_price),deviation);  IndicatorSetString(INDICATOR_SHORTNAME,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[])  {  //— iEnvelopes 指標から複製された値の数  int values_to_copy;  //— 指標で計算された値の数を決める  int calculated=BarsCalculated(handle);  if(calculated<=0)  {  PrintFormat(“BarsCalculated() returned %d, error code %d”,calculated,GetLastError());  return(0);  }  //— これが指標計算の初めであるか iEnvelopes 指標の値の数が変更した  //—または、2 つ以上のバーの指標の計算が必要である場合(価格履歴で何かが変更された)  if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1)  {  //— もし UpperBuffer 配列が銘柄/期間で iEnvelopes 指標の値の数より大きい場合、全体のコピーはしない   //— 他の場合、指標バッファサイズより少ない量をコピーをする  if(calculated>rates_total) values_to_copy=rates_total;  else                       values_to_copy=calculated;  }  else  {  //— これは初回の計算ではなく、  //— 前回の OnCalculate() から、一以上のバーが加えられてない。  values_to_copy=(rates_total-prev_calculated)+1;  }  //— エンベロープ指標の値で UpperBuffer 及び LowerBuffer 配列を記入する  //— FillArrayFromBuffer が false を返した場合、情報の準備が終わっていないので操作を終了する  if(!FillArraysFromBuffers(UpperBuffer,LowerBuffer,ma_shift,handle,values_to_copy)) return(0);  //— メッセージを形成する  string comm=StringFormat(“%s ==>  Updated value in the indicator %s: %d”,  TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS),  short_name,  values_to_copy);  //— チャートにサービスメッセージを表示する  Comment(comm);  //— エンベロープ指標の値の数を覚える  bars_calculated=calculated;  //— prev_calculated 値を次の関数呼び出しのために返す  return(rates_total);  }  //+——————————————————————+  //| iEnvelopes 指標から指標バッファを記入する                                 |  //+——————————————————————+  bool FillArraysFromBuffers(double &upper_values[],   // 上縁の指標バッファ  double &lower_values[],   // 下縁の指標バッファ  int shift,                 // シフト  int ind_handle,           // iEnvelopes 指標ハンドル  int amount                 // 複製された値の数  )  {  //— エラーコードをリセットする  ResetLastError();  //— インデックス0 を持つ指標バッファの値で UpperBuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,0,-shift,amount,upper_values)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iEnvelopes indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— インデックス 1 を持つ指標バッファの値で LowerBuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,1,-shift,amount,lower_values)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iEnvelopes indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— 全てが成功  return(true);  }  //+——————————————————————+  //| 指標初期化解除関数                                                  |  //+——————————————————————+  void OnDeinit(const int reason)  {  //— 指標の削除後チャートをクリアする  Comment(“”);  }  | 
iForce
この関数は Force Index (勢力指数)指標のハンドルを返します。バッファは 1 つです。
int  iForce(  string              symbol,              ENUM_TIMEFRAMES    period,              int                ma_period,          ENUM_MA_METHOD      ma_method,          ENUM_APPLIED_VOLUME applied_volume       );  | 
パラメータ
symbol
[in] データが指標計算に使用される有価証券の銘柄名(NULL は現在のシンボル)
period
[in] 期間の値は ENUM_TIMEFRAMES 列挙の値の 1 つで、0 は現在の時間軸の意味です。
ma_period
[in] 指標計算の平均期間
ma_method
[in]  平滑化の種類ENUM_MA_METHOD のいずれかの値
applied_volume
[in]  使用されるボリューム(ENUM_APPLIED_VOLUME のいずれかの値)
戻り値
例:
//+——————————————————————+  //|                                                  Demo_iForce.mq5 |  //|                        Copyright 2011, MetaQuotes Software Corp. |  //|                                             https://www.MQL5.com |  //+——————————————————————+  #property copyright “Copyright 2011, MetaQuotes Software Corp.”  #property link     “https://www.mql5.com”  #property version   “1.00”  #property description “The indicator demonstrates how to obtain data”  #property description “of indicator buffers for the iForce technical indicator.”  #property description “A symbol and timeframe used for calculation of the indicator,”  #property description “are set by the symbol and period parameters.”  #property description “The method of creation of the handle is set through the ‘type’ parameter (function type).” #property indicator_separate_window  #property indicator_buffers 1  #property indicator_plots   1  //— iForce の描画  #property indicator_label1 “iForce”  #property indicator_type1   DRAW_LINE  #property indicator_color1  clrLightSeaGreen  #property indicator_style1 STYLE_SOLID  #property indicator_width1  1  //+——————————————————————+  //| 作成を処理する方法の列挙                                              |  //+——————————————————————+  enum Creation  {  Call_iForce,           // iForce を使用する  Call_IndicatorCreate   // IndicatorCreateを使用する  };  //— 入力パラメータ  input Creation             type=Call_iForce;             // 関数の種類   input int                  ma_period=13;                 // 平均期間  input ENUM_MA_METHOD       ma_method=MODE_SMA;           // 平滑化の種類  input ENUM_APPLIED_VOLUME  applied_volume=VOLUME_TICK;   // ボリュームの種類  input string               symbol=” “;                   // シンボル   input ENUM_TIMEFRAMES     period=PERIOD_CURRENT;       // 時間軸  //— 指標バッファ  double         iForceBuffer[];  //— iForce 指標ハンドルを格納する変数  int    handle;  //— 格納に使用される変数  string name=symbol;  //— チャートでの指標名  string short_name;  //— フォース指標に値の数を保存  int    bars_calculated=0;  //+——————————————————————+  //| カスタム指標を初期化する関数                                            |  //+——————————————————————+  int OnInit()  {  //— 配列の指標バッファへの割り当て  SetIndexBuffer(0,iForceBuffer,INDICATOR_DATA);  //— 指標が描画するシンボルを決める  name=symbol;  //— 左右のスペースを削する  StringTrimRight(name);  StringTrimLeft(name);  //—「name」文字列の長さがゼロになった場合  if(StringLen(name)==0)  {  //— 指標が接続されているチャートのシンボルを取る  name=_Symbol;  }  //— 指標ハンドルを作成する  if(type==Call_iForce)  handle=iForce(name,period,ma_period,ma_method,applied_volume);  else  {  //— 構造体を指標のパラメータで記入  MqlParam pars[3];  //— 移動平均の期間  pars[0].type=TYPE_INT;  pars[0].integer_value=ma_period;  //— 平滑化の種類  pars[1].type=TYPE_INT;  pars[1].integer_value=ma_method;  //— ボリュームの種類  pars[2].type=TYPE_INT;  pars[2].integer_value=applied_volume;  //— 価格の種類  handle=IndicatorCreate(name,period,IND_FORCE,3,pars);  }  //— ハンドルが作成されなかった場合  if(handle==INVALID_HANDLE)  {  //— 失敗した事実とエラーコードを出力する  PrintFormat(“Failed to create handle of the iForce indicator for the symbol %s/%s, error code %d”,  name,  EnumToString(period),  GetLastError());  //— 指標が早期に中止された  return(INIT_FAILED);  }  //— フォース指標が計算された銘柄/時間軸を表示  short_name=StringFormat(“iForce(%s/%s, %d, %s, %s)”,name,EnumToString(period),  ma_period,EnumToString(ma_method),EnumToString(applied_volume));  IndicatorSetString(INDICATOR_SHORTNAME,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[])  {  //— iForce 指標から複製された値の数  int values_to_copy;  //— 指標で計算された値の数を決める  int calculated=BarsCalculated(handle);  if(calculated<=0)  {  PrintFormat(“BarsCalculated() returned %d, error code %d”,calculated,GetLastError());  return(0);  }  //— これが指標計算の初めであるか iForce 指標の値の数が変更した  //—または、2 つ以上のバーの指標の計算が必要である場合(価格履歴で何かが変更された)  if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1)  {  //— もし iForceBuffer 配列が銘柄/期間で iForce 指標の値の数より大きい場合、全体のコピーはしない   //— 他の場合、指標バッファサイズより少ない量をコピーをする  if(calculated>rates_total) values_to_copy=rates_total;  else                       values_to_copy=calculated;  }  else  {  //— これは初回の計算ではなく、  //— 前回の OnCalculate() から、一以上のバーが加えられてない。  values_to_copy=(rates_total-prev_calculated)+1;  }  //— iForceBuffer 配列をフォース指標の値で記入  //— FillArrayFromBuffer が false を返した場合、情報の準備が終わっていないので操作を終了する  if(!FillArrayFromBuffer(iForceBuffer,handle,values_to_copy)) return(0);  //— メッセージを形成する  string comm=StringFormat(“%s ==>  Updated value in the indicator %s: %d”,  TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS),  short_name,  values_to_copy);  //— チャートにサービスメッセージを表示する  Comment(comm);  //— フォース指標の値の数を覚える  bars_calculated=calculated;  //— prev_calculated 値を次の関数呼び出しのために返す  return(rates_total);  }  //+——————————————————————+  //| iForce 指標から指標バッファを記入する                                     |  //+——————————————————————+  bool FillArrayFromBuffer(double &values[], // フォース指標バッファ values  int ind_handle,   // iForce 指標ハンドル  int amount         // 複製された値の数  )  {  //— エラーコードをリセットする  ResetLastError();  //— インデックス0 を持つ指標バッファの値で iForceBuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,0,0,amount,values)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iForce indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— 全てが成功  return(true);  }  //+——————————————————————+  //| 指標初期化解除関数                                                  |  //+——————————————————————+  void OnDeinit(const int reason)  {  //— 指標の削除後チャートをクリアする  Comment(“”);  }  | 
iFractals
この関数は Fractals (フラクタル)指標ハンドルを返します。 
int  iFractals(  string          symbol,      ENUM_TIMEFRAMES  period        );  | 
パラメータ
symbol
[in] データが指標計算に使用される有価証券の銘柄名(NULL は現在のシンボル)
period
[in] 期間の値は ENUM_TIMEFRAMES 列挙の値の 1 つで、0 は現在の時間軸の意味です。
戻り値
注意事項
例:
//+——————————————————————+  //|                                               Demo_iFractals.mq5 |  //|                        Copyright 2011, MetaQuotes Software Corp. |  //|                                             https://www.MQL5.com |  //+——————————————————————+  #property copyright “Copyright 2011, MetaQuotes Software Corp.”  #property link     “https://www.mql5.com”  #property version   “1.00”  #property description “The indicator demonstrates how to obtain data”  #property description “of indicator buffers for the iFractals technical indicator.”  #property description “A symbol and timeframe used for calculation of the indicator,”  #property description “are set by the symbol and period parameters.”  #property description “The method of creation of the handle is set through the ‘type’ parameter (function type).” #property indicator_chart_window  #property indicator_buffers 1  #property indicator_plots   1  #property indicator_chart_window  #property indicator_buffers 2  #property indicator_plots   2  //— FractalUp プロット  #property indicator_label1 “FractalUp”  #property indicator_type1   DRAW_ARROW  #property indicator_color1  clrBlue  //— FractalDown プロット  #property indicator_label2 “FractalDown”  #property indicator_type2   DRAW_ARROW  #property indicator_color2  clrRed  //+——————————————————————+  //| 作成を処理する方法の列挙                                              |  //+——————————————————————+  enum Creation  {  Call_iFractals,         // iFractals を使用する  Call_IndicatorCreate   // IndicatorCreateを使用する  };  //— 入力パラメータ  input Creation             type=Call_iFractals;         // 関数の種類  input string               symbol=” “;                   // シンボル   input ENUM_TIMEFRAMES     period=PERIOD_CURRENT;       // 時間軸  //— 指標バッファ  double         FractalUpBuffer[];  double         FractalDownBuffer[];  //— iFractals 指標ハンドルを格納する変数  int    handle;  //— 格納に使用される変数  string name=symbol;  //— チャートでの指標名  string short_name;  //— フラクタル指標に値の数を保存  int    bars_calculated=0;  //+——————————————————————+  //| カスタム指標を初期化する関数                                            |  //+——————————————————————+  int OnInit()  {  //— 配列の指標バッファへの割り当て  SetIndexBuffer(0,FractalUpBuffer,INDICATOR_DATA);  SetIndexBuffer(1,FractalDownBuffer,INDICATOR_DATA);  //— PLOT_ARROWプロパティのコードを Wingdings 文字セットからの記号を使用して設定  PlotIndexSetInteger(0,PLOT_ARROW,217); // 上矢印   PlotIndexSetInteger(1,PLOT_ARROW,218); // 下矢印  //— 指標が描画するシンボルを決める  name=symbol;  //— 左右のスペースを削する  StringTrimRight(name);  StringTrimLeft(name);  //—「name」文字列の長さがゼロになった場合  if(StringLen(name)==0)  {  //— 指標が接続されているチャートのシンボルを取る  name=_Symbol;  }  //— 指標ハンドルを作成する  if(type==Call_iFractals)  handle=iFractals(name,period);  else  handle=IndicatorCreate(name,period,IND_FRACTALS);  //— ハンドルが作成されなかった場合  if(handle==INVALID_HANDLE)  {  //— 失敗した事実とエラーコードを出力する  PrintFormat(“Failed to create handle of the iFractals indicator for the symbol %s/%s, error code %d”,  name,  EnumToString(period),  GetLastError());  //— 指標が早期に中止された  return(INIT_FAILED);  }  //— フラクタル指標が計算された銘柄/時間軸を表示  short_name=StringFormat(“iFractals(%s/%s)”,name,EnumToString(period));  IndicatorSetString(INDICATOR_SHORTNAME,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[])  {  //— iFractals 指標から複製された値の数  int values_to_copy;  //— 指標で計算された値の数を決める  int calculated=BarsCalculated(handle);  if(calculated<=0)  {  PrintFormat(“BarsCalculated() returned %d, error code %d”,calculated,GetLastError());  return(0);  }  //— これが指標計算の初めであるか iFractals 指標の値の数が変更した  //—または、2 つ以上のバーの指標の計算が必要である場合(価格履歴で何かが変更された)  if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1)  {  //— もし FractalUpBuffer 配列が銘柄/期間で iFractals指標の値の数より大きい場合、全体のコピーはしない   //— 他の場合、指標バッファサイズより少ない量をコピーをする  if(calculated>rates_total) values_to_copy=rates_total;  else                       values_to_copy=calculated;  }  else  {  //— これは初回の計算ではなく、  //— 前回の OnCalculate() から、一以上のバーが加えられてない。  values_to_copy=(rates_total-prev_calculated)+1;  }  //— フラクタル指標の値で FractalUpBuffer 及び FractalDownBuffer 配列を記入する  //— FillArrayFromBuffer が false を返した場合、情報の準備が終わっていないので操作を終了する  if(!FillArraysFromBuffers(FractalUpBuffer,FractalDownBuffer,handle,values_to_copy)) return(0);  //— メッセージを形成する  string comm=StringFormat(“%s ==>  Updated value in the indicator %s: %d”,  TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS),  short_name,  values_to_copy);  //— チャートにサービスメッセージを表示する  Comment(comm);  //— フラクタル指標の値の数を覚える  bars_calculated=calculated;  //— prev_calculated 値を次の関数呼び出しのために返す  return(rates_total);  }  //+——————————————————————+  //| iFractals 指標から指標バッファを記入する                                  |  //+——————————————————————+  bool FillArraysFromBuffers(double &up_arrows[],       // 上矢印の指標バッファ  double &down_arrows[],     // 上矢印の指標バッファ  int ind_handle,             // iFractals 指標ハンドル  int amount                 // 複製された値の数  )  {  //— エラーコードをリセットする  ResetLastError();  //— インデックス0 を持つ指標バッファの値で FractalUpBuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,0,0,amount,up_arrows)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iFractals indicator to the FractalUpBuffer array, error code %d”,  GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— インデックス 1 を持つ指標バッファの値で FractalDownBuffer 配列の一部を記入する1  if(CopyBuffer(ind_handle,1,0,amount,down_arrows)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iFractals indicator to the FractalDownBuffer array, error code %d”,  GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— 全てが成功  return(true);  }  //+——————————————————————+  //| 指標初期化解除関数                                                  |  //+——————————————————————+  void OnDeinit(const int reason)  {  //— 指標の削除後チャートをクリアする  Comment(“”);  }  | 
iFrAMA
この関数は Fractal Adaptive Moving Average(フラクタル適応型移動平均)指標のハンドルを返します。バッファは 1 つです。
int  iFrAMA(  string              symbol,              ENUM_TIMEFRAMES    period,              int                ma_period,          int                ma_shift,            ENUM_APPLIED_PRICE  applied_price        );  | 
パラメータ
symbol
[in] データが指標計算に使用される有価証券の銘柄名(NULL は現在のシンボル)
period
[in] 期間の値は ENUM_TIMEFRAMES 列挙の値の 1 つで、0 は現在の時間軸の意味です。
ma_period
[in] 指標計算の平均期間(バーの数)
ma_shift
[in]  価格チャートでの指標のシフト
applied_price
[in]  使用される価格。ENUM_APPLIED_PRICE 価格定数のいずれか、または別の指標ハンドル。
戻り値
例:
//+——————————————————————+  //|                                                  Demo_iFrAMA.mq5 |  //|                        Copyright 2011, MetaQuotes Software Corp. |  //|                                             https://www.MQL5.com |  //+——————————————————————+  #property copyright “Copyright 2011, MetaQuotes Software Corp.”  #property link     “https://www.mql5.com”  #property version   “1.00”  #property description “The indicator demonstrates how to obtain data”  #property description “of indicator buffers for the iFrAMA technical indicator.”  #property description “A symbol and timeframe used for calculation of the indicator,”  #property description “are set by the symbol and period parameters.”  #property description “The method of creation of the handle is set through the ‘type’ parameter (function type).” #property indicator_chart_window  #property indicator_buffers 1  #property indicator_plots   1  //— iFrAMA の描画  #property indicator_label1 “iFrAMA”  #property indicator_type1   DRAW_LINE  #property indicator_color1  clrBlue  #property indicator_style1 STYLE_SOLID  #property indicator_width1  1  //+——————————————————————+  //| 作成を処理する方法の列挙                                              |  //+——————————————————————+  enum Creation  {  Call_iFrAMA,           // iFrAMA を使用する  Call_IndicatorCreate   // IndicatorCreateを使用する  };  //— 入力パラメータ  input Creation             type=Call_iFrAMA;             // 関数の種類   input int                  ma_period=14;                 // 平均期間  input int                  ma_shift=0;                   // シフト  input ENUM_APPLIED_PRICE   applied_price=PRICE_CLOSE;   // 価格の種類  input string               symbol=” “;                   // シンボル   input ENUM_TIMEFRAMES     period=PERIOD_CURRENT;       // 時間軸  //— 指標バッファ  double         iFrAMABuffer[];  //— iFrAMA 指標ハンドルを格納する変数  int    handle;  //— 格納に使用される変数  string name=symbol;  //— チャートでの指標名  string short_name;  //— フラクタル適応型移動平均指標に値の数を保存  int    bars_calculated=0;  //+——————————————————————+  //| カスタム指標を初期化する関数                                            |  //+——————————————————————+  int OnInit()  {  //— 配列の指標バッファへの割り当て  SetIndexBuffer(0,iFrAMABuffer,INDICATOR_DATA);  //— シフトを設定  PlotIndexSetInteger(0,PLOT_SHIFT,ma_shift);  //— 指標が描画するシンボルを決める  name=symbol;  //— 左右のスペースを削する  StringTrimRight(name);  StringTrimLeft(name);  //—「name」文字列の長さがゼロになった場合  if(StringLen(name)==0)  {  //— 指標が接続されているチャートのシンボルを取る  name=_Symbol;  }  //— 指標ハンドルを作成する  if(type==Call_iFrAMA)  handle=iFrAMA(name,period,ma_period,ma_shift,applied_price);  else  {  //— 構造体を指標のパラメータで記入  MqlParam pars[3];  //— 移動平均の期間  pars[0].type=TYPE_INT;  pars[0].integer_value=ma_period;  //— シフト  pars[1].type=TYPE_INT;  pars[1].integer_value=ma_shift;  //— 価格の種類  pars[2].type=TYPE_INT;  pars[2].integer_value=applied_price;  //— 価格の種類  handle=IndicatorCreate(name,period,IND_FRAMA,3,pars);  }  //— ハンドルが作成されなかった場合  if(handle==INVALID_HANDLE)  {  //— 失敗した事実とエラーコードを出力する  PrintFormat(“Failed to create handle of the iFrAMA indicator for the symbol %s/%s, error code %d”,  name,  EnumToString(period),  GetLastError());  //— 指標が早期に中止された  return(INIT_FAILED);  }  //— iFrAMA 指標が計算された銘柄/時間軸を表示  short_name=StringFormat(“iFrAMA(%s/%s, %d, %d, %s)”,name,EnumToString(period),  ma_period,ma_shift,EnumToString(applied_price));  IndicatorSetString(INDICATOR_SHORTNAME,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[])  {  //— iFrAMA 指標から複製された値の数  int values_to_copy;  //— 指標で計算された値の数を決める  int calculated=BarsCalculated(handle);  if(calculated<=0)  {  PrintFormat(“BarsCalculated() returned %d, error code %d”,calculated,GetLastError());  return(0);  }  //— これが指標計算の初めであるか iFrAMA 指標の値の数が変更した  //—または、2 つ以上のバーの指標の計算が必要である場合(価格履歴で何かが変更された)  if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1)  {  //— もし iFrAMABuffer 配列が銘柄/期間で iFrAMA 指標の値の数より大きい場合、全体のコピーはしない   //— 他の場合、指標バッファサイズより少ない量をコピーをする  if(calculated>rates_total) values_to_copy=rates_total;  else                       values_to_copy=calculated;  }  else  {  //— これは初回の計算ではなく、  //— 前回の OnCalculate() から、一以上のバーが加えられてない。  values_to_copy=(rates_total-prev_calculated)+1;  }  //— iFrAMABuffer 配列を フラクタル適応型移動平均指標の値で記入  //— FillArrayFromBuffer が false を返した場合、情報の準備が終わっていないので操作を終了する  if(!FillArrayFromBuffer(iFrAMABuffer,ma_shift,handle,values_to_copy)) return(0);  //— メッセージを形成する  string comm=StringFormat(“%s ==>  Updated value in the indicator %s: %d”,  TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS),  short_name,  values_to_copy);  //— チャートにサービスメッセージを表示する  Comment(comm);  //— フラクタル適応型移動平均指標の値の数を覚える  bars_calculated=calculated;  //— prev_calculated 値を次の関数呼び出しのために返す  return(rates_total);  }  //+——————————————————————+  //| iFrAMA 指標から指標バッファを記入する                                     |  //+——————————————————————+  bool FillArrayFromBuffer(double &values[], // フラクタル適応型移動平均 値の指標バッファ  int shift,         // シフト  int ind_handle,   // iFrAMA 指標ハンドル  int amount         // 複製された値の数  )  {  //— エラーコードをリセットする  ResetLastError();  //— インデックス0 を持つ指標バッファの値で iFrAMABuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,0,-shift,amount,values)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iFrAMA indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— 全てが成功  return(true);  }  //+——————————————————————+  //| 指標初期化解除関数                                                  |  //+——————————————————————+  void OnDeinit(const int reason)  {  //— 指標の削除後チャートをクリアする  Comment(“”);  }  | 
iGator
この関数は Gator (ゲーター)指標のハンドルを返します。 オシレーターは、アリゲーターの青線と赤線の差(上ヒストグラム)と、赤線と緑線の差(下ヒストグラム)を示します。
int  iGator(  string              symbol,              ENUM_TIMEFRAMES    period,              int                jaw_period,          int                jaw_shift,          int                teeth_period,        int                teeth_shift,        int                lips_period,        int                lips_shift,          ENUM_MA_METHOD      ma_method,          ENUM_APPLIED_PRICE  applied_price        );  | 
パラメータ
symbol
[in] データが指標計算に使用される有価証券の銘柄名(NULL は現在のシンボル)
period
[in] 期間の値は ENUM_TIMEFRAMES 列挙の値の 1 つで、0 は現在の時間軸の意味です。
jaw_period
[in]  青線の平均期間(アリゲーターの顎)
jaw_shift
[in] 価格チャートに相対した青線のシフト(指標ヒストグラムの視覚的なズレとは直接関係しません)。
teeth_period
[in]  赤線の平均期間(アリゲーターの歯)
teeth_shift
[in] 価格チャートに相対した赤線のシフト(指標ヒストグラムの視覚的なズレとは直接関係しません)。
lips_period
[in]  緑線の平均期間(アリゲーターの口)
lips_shift
[in] 価格チャートに相対した緑線のシフト(指標ヒストグラムの視覚的なズレとは直接関係しません)。
ma_method
[in]  平滑化の種類ENUM_MA_METHOD のいずれかの値
applied_price
[in]  使用される価格。ENUM_APPLIED_PRICE 価格定数のいずれか、または別の指標ハンドル。
戻り値
注意事項
例:
//+——————————————————————+  //|                                                  Demo_iGator.mq5 |  //|                        Copyright 2011, MetaQuotes Software Corp. |  //|                                             https://www.MQL5.com |  //+——————————————————————+  #property copyright “Copyright 2011, MetaQuotes Software Corp.”  #property link     “https://www.mql5.com”  #property version   “1.00”  #property description “The indicator demonstrates how to obtain data”  #property description “of indicator buffers for the iGator technical indicator.”  #property description “A symbol and timeframe used for calculation of the indicator,”  #property description “are set by the symbol and period parameters.”  #property description “The method of creation of the handle is set through the ‘type’ parameter (function type).”  #property description “All other parameters are as in a standard Gator Oscillator.” #property indicator_separate_window  #property indicator_buffers 4  #property indicator_plots   2  //— GatorUp の描画  #property indicator_label1 “GatorUp”  #property indicator_type1   DRAW_COLOR_HISTOGRAM  #property indicator_color1  clrGreen, clrRed  #property indicator_style1 STYLE_SOLID  #property indicator_width1  1  //— GatorDown の描画  #property indicator_label2 “GatorDown”  #property indicator_type2   DRAW_COLOR_HISTOGRAM  #property indicator_color2  clrGreen, clrRed  #property indicator_style2 STYLE_SOLID  #property indicator_width2  1  //+——————————————————————+  //| 作成を処理する方法の列挙                                              |  //+——————————————————————+  enum Creation  {  Call_iGator,           // iGator を使用する  Call_IndicatorCreate   // IndicatorCreateを使用する  };  //— 入力パラメータ  input Creation             type=Call_iGator;       // 関数の種類   input string               symbol=” “;             // シンボル  input ENUM_TIMEFRAMES     period=PERIOD_CURRENT; // 時間軸  input int                  jaw_period=13;         // 顎線の期間  input int                  jaw_shift=8;           // 顎線のシフト  input int                  teeth_period=8;         // 歯線の期間  input int                  teeth_shift=5;         // 歯線のシフト  input int                  lips_period=5;         // 口線の期間  input int                  lips_shift=3;           // 口線のシフト  input ENUM_MA_METHOD       MA_method=MODE_SMMA;   // アリゲーター線の平均化の方法  input ENUM_APPLIED_PRICE   applied_price=PRICE_MEDIAN;// アリゲーター計算に使用される価格の種類  //— 指標バッファ  double         GatorUpBuffer[];  double         GatorUpColors[];  double         GatorDownBuffer[];  double         GatorDownColors[];  //— iGator 指標ハンドルを格納する変数  int    handle;  //— 格納に使用される変数  string name=symbol;  //— チャートでの指標名  string short_name;  //— 上下ヒストグラムのシフト値  int shift;  //— ゲーターオシレーター指標に値の数を保存  int    bars_calculated=0;  //+——————————————————————+  //| カスタム指標を初期化する関数                                            |  //+——————————————————————+  int OnInit()  {  //— 配列の指標バッファへの割り当て  SetIndexBuffer(0,GatorUpBuffer,INDICATOR_DATA);  SetIndexBuffer(1,GatorUpColors,INDICATOR_COLOR_INDEX);  SetIndexBuffer(2,GatorDownBuffer,INDICATOR_DATA);  SetIndexBuffer(3,GatorDownColors,INDICATOR_COLOR_INDEX);  /*    パラメータで指定された全てのシフトは、ゲーターオシレーターが描画されているアリゲーター指標を参照します。    これが、ゲーター指標自体は動数にアリゲーター線を動かし、    ゲーターオシレーター値の計算に使用される理由です。  */  //— 顎線と歯線との差に等しい上下のヒストグラムのシフトを計算してみる  shift=MathMin(jaw_shift,teeth_shift);  PlotIndexSetInteger(0,PLOT_SHIFT,shift);  //— 指標の 2 つのヒストグラムに同じシフトを使用されるのが iGator 指標の実装の仕方  PlotIndexSetInteger(1,PLOT_SHIFT,shift); //— 指標が描画するシンボルを決める  name=symbol;  //— 左右のスペースを削する  StringTrimRight(name);  StringTrimLeft(name);  //—「name」文字列の長さがゼロになった場合  if(StringLen(name)==0)  {  //— 指標が接続されているチャートのシンボルを取る  name=_Symbol;  }  //— 指標ハンドルを作成する  if(type==Call_iGator)  handle=iGator(name,period,jaw_period,jaw_shift,teeth_period,teeth_shift,  lips_period,lips_shift,MA_method,applied_price);  else  {  //— 構造体を指標のパラメータで記入  MqlParam pars[8];  //— アリゲーター線の期間とシフト  pars[0].type=TYPE_INT;  pars[0].integer_value=jaw_period;  pars[1].type=TYPE_INT;  pars[1].integer_value=jaw_shift;  pars[2].type=TYPE_INT;  pars[2].integer_value=teeth_period;  pars[3].type=TYPE_INT;  pars[3].integer_value=teeth_shift;  pars[4].type=TYPE_INT;  pars[4].integer_value=lips_period;  pars[5].type=TYPE_INT;  pars[5].integer_value=lips_shift;  //— 平滑化の種類  pars[6].type=TYPE_INT;  pars[6].integer_value=MA_method;  //— 価格の種類  pars[7].type=TYPE_INT;  pars[7].integer_value=applied_price;  //— ハンドルを作成  handle=IndicatorCreate(name,period,IND_GATOR,8,pars);  }  //— ハンドルが作成されなかった場合  if(handle==INVALID_HANDLE)  {  //— 失敗した事実とエラーコードを出力する  PrintFormat(“Failed to create handle of the iGator indicator for the symbol %s/%s, error code %d”,  name,  EnumToString(period),  GetLastError());  //— 指標が早期に中止された  return(INIT_FAILED);  }  //— ゲーターオシレーターが計算された銘柄/時間軸を表示  short_name=StringFormat(“iGator(%s/%s, %d, %d ,%d, %d, %d, %d)”,name,EnumToString(period),  jaw_period,jaw_shift,teeth_period,teeth_shift,lips_period,lips_shift);  IndicatorSetString(INDICATOR_SHORTNAME,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[])  {  //— iGator 指標から複製された値の数  int values_to_copy;  //— 指標で計算された値の数を決める  int calculated=BarsCalculated(handle);  if(calculated<=0)  {  PrintFormat(“BarsCalculated() returned %d, error code %d”,calculated,GetLastError());  return(0);  }  //— これが指標計算の初めであるか iGator 指標の値の数が変更した  //—または、2 つ以上のバーの指標の計算が必要である場合(価格履歴で何かが変更された)  if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1)  {  //— もし GatorUpBuffer 配列が銘柄/期間で iGator 指標の値の数より大きい場合、全体のコピーはしない   //— 他の場合、指標バッファサイズより少ない量をコピーをする  if(calculated>rates_total) values_to_copy=rates_total;  else                       values_to_copy=calculated;  }  else  {  //— これは初回の計算ではなく、  //— 前回の OnCalculate() から、一以上のバーが加えられてない。  values_to_copy=(rates_total-prev_calculated)+1;  }  //— 配列をゲーターオシレーター指標の値で記入  //— FillArraysFromBuffer が false を返した場合、情報の準備が終わっていないので操作を終了する  if(!FillArraysFromBuffers(GatorUpBuffer,GatorUpColors,GatorDownBuffer,GatorDownColors,  shift,handle,values_to_copy)) return(0);  //— メッセージを形成する  string comm=StringFormat(“%s ==>  Updated value in the indicator %s: %d”,  TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS),  short_name,  values_to_copy);  //— チャートにサービスメッセージを表示する  Comment(comm);  //— ゲーターオシレーター指標の値の数を覚える  bars_calculated=calculated;  //— prev_calculated 値を次の関数呼び出しのために返す  return(rates_total);  }  //+——————————————————————+  //| iGator 指標から指標バッファを記入する                                     |  //+——————————————————————+  bool FillArraysFromBuffers(double &ups_buffer[],         // 上ヒストグラムの指標バッファ  double &up_color_buffer[],   // 上ヒストグラムの価格インデックスの指標バッファ  double &downs_buffer[],       // 下ヒストグラムの指標バッファ  double &downs_color_buffer[], // 下ヒストグラムの価格インデックスの指標バッファ  int u_shift,                 // 上下ヒストグラムのシフト  int ind_handle,               // iGator 指標ハンドル  int amount                   // 複製された値の数  )  {  //— エラーコードをリセットする  ResetLastError();  //— インデックス0 を持つ指標バッファの値で GatorUpBuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,0,-u_shift,amount,ups_buffer)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iGator indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  } //— インデックス 1 を持つ指標バッファの値で GatorUpColors 配列の一部を記入する  if(CopyBuffer(ind_handle,1,-u_shift,amount,up_color_buffer)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iGator indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  } //— インデックス 2 を持つ指標バッファの値で GatorDownBuffer 配列の一部を記入する GatorDownColors   if(CopyBuffer(ind_handle,2,-u_shift,amount,downs_buffer)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iGator indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  } //— インデックス3 を持つ指標バッファの値でGatorDownColors 配列の一部を記入する  if(CopyBuffer(ind_handle,3,-u_shift,amount,downs_color_buffer)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iGator indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— 全てが成功  return(true);  }  //+——————————————————————+  //| 指標初期化解除関数                                                  |  //+——————————————————————+  void OnDeinit(const int reason)  {  //— 指標の削除後チャートをクリアする  Comment(“”);  }  | 
iIchimoku
この関数は一目均衡表指標ハンドルを返します。
int  iIchimoku(  string          symbol,              ENUM_TIMEFRAMES  period,              int              tenkan_sen,          int              kijun_sen,          int              senkou_span_b        );  | 
パラメータ
symbol
[in] データが指標計算に使用される有価証券の銘柄名(NULL は現在のシンボル)
period
[in] 期間の値は ENUM_TIMEFRAMES 列挙の値の 1 つで、0 は現在の時間軸の意味です。
tenkan_sen
[in] 転換線の平均期間
kijun_sen
[in] 基準線の平均期間
senkou_span_b
[in] 先行スパンBの平均期間
戻り値
注意事項
例:
//+——————————————————————+  //|                                               Demo_iIchimoku.mq5 |  //|                        Copyright 2011, MetaQuotes Software Corp. |  //|                                             https://www.MQL5.com |  //+——————————————————————+  #property copyright “Copyright 2011, MetaQuotes Software Corp.”  #property link     “https://www.mql5.com”  #property version   “1.00”  #property description “The indicator demonstrates how to obtain data”  #property description “of indicator buffers for the iIchimoku technical indicator.”  #property description “A symbol and timeframe used for calculation of the indicator,”  #property description “are set by the symbol and period parameters.”  #property description “The method of creation of the handle is set through the ‘type’ parameter (function type).”  #property description “All other parameters just like in the standard Ichimoku Kinko Hyo.” #property indicator_chart_window  #property indicator_buffers 5  #property indicator_plots   4  //— Tenkan_sen プロット  #property indicator_label1 “Tenkan_sen”  #property indicator_type1   DRAW_LINE  #property indicator_color1  clrRed  #property indicator_style1 STYLE_SOLID  #property indicator_width1  1  //— Kijun_sen プロット  #property indicator_label2 “Kijun_sen”  #property indicator_type2   DRAW_LINE  #property indicator_color2  clrBlue  #property indicator_style2 STYLE_SOLID  #property indicator_width2  1  //— Senkou_Span プロット  #property indicator_label3 “Senkou Span A;Senkou Span B” // 2 つのフィールドはデータウィンドウに表示される  #property indicator_type3   DRAW_FILLING  #property indicator_color3  clrSandyBrown, clrThistle  #property indicator_style3 STYLE_SOLID  #property indicator_width3  1  //— Chikou_Span プロット  #property indicator_label4 “Chinkou_Span”  #property indicator_type4   DRAW_LINE  #property indicator_color4  clrLime  #property indicator_style4 STYLE_SOLID  #property indicator_width4  1  //+——————————————————————+  //| 作成を処理する方法の列挙                                              |  //+——————————————————————+  enum Creation  {  Call_iIchimoku,         // iIchimoku を使用する  Call_IndicatorCreate   // IndicatorCreateを使用する  };  //— 入力パラメータ  input Creation             type=Call_iIchimoku;       // 関数の種類   input int                  tenkan_sen=9;             // 転換線の期間  input int                  kijun_sen=26;             // 基準線の期間  input int                  senkou_span_b=52;         // 先行スパンBの期間  input string               symbol=” “;               // シンボル   input ENUM_TIMEFRAMES     period=PERIOD_CURRENT;     // 時間軸  //— 指標バッファ  double         Tenkan_sen_Buffer[];  double         Kijun_sen_Buffer[];  double         Senkou_Span_A_Buffer[];  double         Senkou_Span_B_Buffer[];  double         Chinkou_Span_Buffer[];  //— 一目指標ハンドルを格納する変数  int    handle;  //— 格納に使用される変数  string name=symbol;  //— チャートでの指標名  string short_name;  //— 一目均衡表指標に値の数を保存  int    bars_calculated=0;  //+——————————————————————+  //| カスタム指標を初期化する関数                                            |  //+——————————————————————+  int OnInit()  {  //— 配列の指標バッファへの割り当て  SetIndexBuffer(0,Tenkan_sen_Buffer,INDICATOR_DATA);  SetIndexBuffer(1,Kijun_sen_Buffer,INDICATOR_DATA);  SetIndexBuffer(2,Senkou_Span_A_Buffer,INDICATOR_DATA);  SetIndexBuffer(3,Senkou_Span_B_Buffer,INDICATOR_DATA);  SetIndexBuffer(4,Chinkou_Span_Buffer,INDICATOR_DATA);  //— 基準線バーの先行スパンチャンネルのシフトを将来に向けて設定する  PlotIndexSetInteger(2,PLOT_SHIFT,kijun_sen);  //— 遅行データスパンはすでに一目のシフトに保存されているので  //— 遅行スパン線のシフトは設定する必要がない  //— 指標が描画するシンボルを決める  name=symbol;  //— 左右のスペースを削する  StringTrimRight(name);  StringTrimLeft(name);  //—「name」文字列の長さがゼロになった場合  if(StringLen(name)==0)  {  //— 指標が接続されているチャートのシンボルを取る  name=_Symbol;  }  //— 指標ハンドルを作成する  if(type==Call_iIchimoku)  handle=iIchimoku(name,period,tenkan_sen,kijun_sen,senkou_span_b);  else  {  //— 構造体を指標のパラメータで記入  MqlParam pars[3];  //— アリゲーター線の期間とシフト  pars[0].type=TYPE_INT;  pars[0].integer_value=tenkan_sen;  pars[1].type=TYPE_INT;  pars[1].integer_value=kijun_sen;  pars[2].type=TYPE_INT;  pars[2].integer_value=senkou_span_b;  //— ハンドルを作成  handle=IndicatorCreate(name,period,IND_ICHIMOKU,3,pars);  }  //— ハンドルが作成されなかった場合  if(handle==INVALID_HANDLE)  {  //— 失敗した事実とエラーコードを出力する  PrintFormat(“Failed to create handle of the iIchimoku indicator for the symbol %s/%s, error code %d”,  name,  EnumToString(period),  GetLastError());  //— 指標が早期に中止された  return(INIT_FAILED);  }  //— 一目均衡表指標が計算された銘柄/時間軸を表示  short_name=StringFormat(“iIchimoku(%s/%s, %d, %d ,%d)”,name,EnumToString(period),  tenkan_sen,kijun_sen,senkou_span_b);  IndicatorSetString(INDICATOR_SHORTNAME,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[])  {  //— 一目均衡表指標から複製された値の数  int values_to_copy;  //— 指標で計算された値の数を決める  int calculated=BarsCalculated(handle);  if(calculated<=0)  {  PrintFormat(“BarsCalculated() returned %d, error code %d”,calculated,GetLastError());  return(0);  }  //— これが指標計算の初めであるか一目均衡表指標の値の数が変更した  //—または、2 つ以上のバーの指標の計算が必要である場合(価格履歴で何かが変更された)  if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1)  {  //— Tenkan_sen_Buffer 配列が銘柄/期間で一目指標の値の数より大きい場合、全体のコピーはしない   //— 他の場合、指標バッファサイズより少ない量をコピーをする  if(calculated>rates_total) values_to_copy=rates_total;  else                       values_to_copy=calculated;  }  else  {  //— これは初回の計算ではなく、  //— 前回の OnCalculate() から、一以上のバーが加えられてない。  values_to_copy=(rates_total-prev_calculated)+1;  }  //— 配列を一目均衡表指標の値で記入  //— FillArraysFromBuffer が false を返した場合、情報の準備が終わっていないので操作を終了する  if(!FillArraysFromBuffers(Tenkan_sen_Buffer,Kijun_sen_Buffer,Senkou_Span_A_Buffer,Senkou_Span_B_Buffer,Chinkou_Span_Buffer,  kijun_sen,handle,values_to_copy)) return(0);  //— メッセージを形成する  string comm=StringFormat(“%s ==>  Updated value in the indicator %s: %d”,  TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS),  short_name,  values_to_copy);  //— チャートにサービスメッセージを表示する  Comment(comm);  //— 一目均衡表指標の値の数を覚える  bars_calculated=calculated;  //— prev_calculated 値を次の関数呼び出しのために返す  return(rates_total);  }  //+——————————————————————+  //| 一目指標から指標バッファを記入する                                        |  //+——————————————————————+  bool FillArraysFromBuffers(double &tenkan_sen_buffer[],     // 転換線の指標バッファ  double &kijun_sen_buffer[],     // 基準線の指標バッファ  double &senkou_span_A_buffer[], // 選考スパンA線の指標バッファ  double &senkou_span_B_buffer[], // 選考スパンB線の指標バッファ  double &chinkou_span_buffer[],   // 遅行スパン線の指標バッファ  int senkou_span_shift,           // 選考スパン線を将来に向けてシフト  int ind_handle,                 // 一目指標ハンドル  &nnbsp;                   int amount                       // 複製された値の数  )  {  //— エラーコードをリセットする  ResetLastError();  //— インデックス0 を持つ指標バッファの値で Tenkan_sen_Buffer 配列の一部を記入する  if(CopyBuffer(ind_handle,0,0,amount,tenkan_sen_buffer)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“1.Failed to copy data from the iIchimoku indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  } //— インデックス 1 を持つ指標バッファの値で Kijun_sen_Buffer 配列の一部を記入する  if(CopyBuffer(ind_handle,1,0,amount,kijun_sen_buffer)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“2.Failed to copy data from the iIchimoku indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  } //— インデックス 2 を持つ指標バッファの値で Chinkou_Span_Buffer 配列の一部を記入する  //— senkou_span_shift>0 の場合、線はsenkou_span_shift バーの数だけ将来に向けてシフトされる  if(CopyBuffer(ind_handle,2,-senkou_span_shift,amount,senkou_span_A_buffer)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“3.Failed to copy data from the iIchimoku indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  } //— インデックス3 を持つ指標バッファの値で Senkou_Span_A_Buffer 配列の一部を記入する  //— senkou_span_shift>0 の場合、線はsenkou_span_shift バーの数だけ将来に向けてシフトされる  if(CopyBuffer(ind_handle,3,-senkou_span_shift,amount,senkou_span_B_buffer)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“4.Failed to copy data from the iIchimoku indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  } //— インデックス0 を持つ指標バッファの値で Senkou_Span_B_Buffer 配列の一部を記入する  //— 遅行スパンデータは既に一目シフトに保存されているので、遅行スパンの複製時に  //— 遅行スパン線のシフトは設定する必要がない    if(CopyBuffer(ind_handle,4,0,amount,chinkou_span_buffer)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“5.Failed to copy data from the iIchimoku indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— 全てが成功  return(true);  }  //+——————————————————————+  //| 指標初期化解除関数                                                 |  //+——————————————————————+  void OnDeinit(const int reason)  {  //— 指標の削除後チャートをクリアする  Comment(“”);  }  | 
iBWMFI
この関数は Market Facilitation Index 指標ハンドルを返します。バッファは 1 つです。
int  iBWMFI(  string              symbol,              ENUM_TIMEFRAMES      period,              ENUM_APPLIED_VOLUME  applied_volume        );  | 
パラメータ
symbol
[in] データが指標計算に使用される有価証券の銘柄名(NULL は現在のシンボル)
period
[in] 期間の値は ENUM_TIMEFRAMES 列挙の値の 1 つで、0 は現在の時間軸の意味です。
applied_volume
[in]  使用されるボリューム(ENUM_APPLIED_VOLUME 定数のいずれか)
戻り値
例:
//+——————————————————————+  //|                                                  Demo_iBWMFI.mq5 |  //|                        Copyright 2011, MetaQuotes Software Corp. |  //|                                             https://www.MQL5.com |  //+——————————————————————+  #property copyright “Copyright 2011, MetaQuotes Software Corp.”  #property link     “https://www.mql5.com”  #property version   “1.00”  #property description “The indicator demonstrates how to obtain data”  #property description “of indicator buffers for the iBWMFI technical indicator.”  #property description “A symbol and timeframe used for calculation of the indicator,”  #property description “are set by the symbol and period parameters.”  #property description “The method of creation of the handle is set through the ‘type’ parameter (function type).” #property indicator_separate_window  #property indicator_buffers 2  #property indicator_plots   1  //— iBWMFI プロット  #property indicator_label1 “iBWMFI”  #property indicator_type1   DRAW_COLOR_HISTOGRAM  #property indicator_color1  clrLime,clrSaddleBrown,clrBlue,clrPink  #property indicator_style1 STYLE_SOLID  #property indicator_width1  1  //+——————————————————————+  //| 作成を処理する方法の列挙                                              |  //+——————————————————————+  enum Creation  {  Call_iBWMFI,           // use iBWMFI を使用する  Call_IndicatorCreate   // IndicatorCreateを使用する  };  //— 入力パラメータ  input Creation             type=Call_iBWMFI;         // 関数の種類  input ENUM_APPLIED_VOLUME  applied_volume=VOLUME_TICK;// ボリュームの種類  input string               symbol=” “;               // シンボル   input ENUM_TIMEFRAMES     period=PERIOD_CURRENT;     // 時間軸  //— 指標バッファ  double         iBWMFIBuffer[];  double         iBWMFIColors[];  //— iBWMFI 指標ハンドルを格納する変数  int    handle;  //— 格納に使用される変数  string name=symbol;  //— チャートでの指標名  string short_name;  //— BW MFI (ビルウィリアムズのマーケットファシリテーションインデックス)指標に値の数を保存  int    bars_calculated=0;  //+——————————————————————+  //| カスタム指標を初期化する関数                                            |  //+——————————————————————+  int OnInit()  {  //— 配列の指標バッファへの割り当て  SetIndexBuffer(0,iBWMFIBuffer,INDICATOR_DATA);  SetIndexBuffer(1,iBWMFIColors,INDICATOR_COLOR_INDEX);  //— 指標が描画するシンボルを決める  name=symbol;  //— 左右のスペースを削する  StringTrimRight(name);  StringTrimLeft(name);  //—「name」文字列の長さがゼロになった場合  if(StringLen(name)==0)  {  //— 指標が接続されているチャートのシンボルを取る  name=_Symbol;  }  //— 指標ハンドルを作成する  if(type==Call_iBWMFI)  handle=iBWMFI(name,period,applied_volume);  else  {  //— 構造体を指標のパラメータで記入  MqlParam pars[1];  //— ボリュームの種類  pars[0].type=TYPE_INT;  pars[0].integer_value=applied_volume;  handle=IndicatorCreate(name,period,IND_BWMFI,1,pars);  }  //— ハンドルが作成されなかった場合  if(handle==INVALID_HANDLE)  {  //— 失敗した事実とエラーコードを出力する  PrintFormat(“Failed to create handle of the iBWMFI indicator for the symbol %s/%s, error code %d”,  name,  EnumToString(period),  GetLastError());  //— 指標が早期に中止された  return(INIT_FAILED);  }  //— BW MFI (ビルウィリアムズのマーケットファシリテーションインデックス)指標が計算された銘柄/時間軸を表示  short_name=StringFormat(“iBWMFI(%s/%s, %s)”,name,EnumToString(period),  EnumToString(applied_volume));  IndicatorSetString(INDICATOR_SHORTNAME,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[])  {  //— iBWMFI 指標から複製された値の数  int values_to_copy;  //— 指標で計算された値の数を決める  int calculated=BarsCalculated(handle);  if(calculated<=0)  {  PrintFormat(“BarsCalculated() returned %d, error code %d”,calculated,GetLastError());  return(0);  }  //— これが指標計算の初めであるか iBWMFI 指標の値の数が変更した  //—または、2 つ以上のバーの指標の計算が必要である場合(価格履歴で何かが変更された)  if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1)  {  //— もしiBWMFIBuffer 配列が銘柄/期間で iBWMFI 指標の値の数より大きい場合、全体のコピーはしない   //— 他の場合、指標バッファサイズより少ない量をコピーをする  if(calculated>rates_total) values_to_copy=rates_total;  else                       values_to_copy=calculated;  }  else  {  //— これは初回の計算ではなく、  //— 前回の OnCalculate() から、一以上のバーが加えられてない。  values_to_copy=(rates_total-prev_calculated)+1;  }  //— 配列を BW MFI (ビルウィリアムズのマーケットファシリテーションインデックス)指標の値で記入  //— FillArraysFromBuffer が false を返した場合、情報の準備が終わっていないので操作を終了する  if(!FillArraysFromBuffers(iBWMFIBuffer,iBWMFIColors,handle,values_to_copy)) return(0);  //— メッセージを形成する  string comm=StringFormat(“%s ==>  Updated value in the indicator %s: %d”,  TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS),  short_name,  values_to_copy);  //— チャートにサービスメッセージを表示する  Comment(comm);  //— BW MFI (ビルウィリアムズのマーケットファシリテーションインデックス)指標の値の数を覚える  bars_calculated=calculated;  //— prev_calculated 値を次の関数呼び出しのために返す  return(rates_total);  }  //+——————————————————————+  //| iBWMFI 指標から指標バッファを記入する                                     |  //+——————————————————————+  bool FillArraysFromBuffers(double &values[],   // ヒストグラム値の指標バッファ  double &colors[],   // ヒストグラムの色の指標バッファ colors  int ind_handle,     // iBWMFI 指標ハンドル  int amount           // 複製された値の数  )  {  //— エラーコードをリセットする  ResetLastError();  //— インデックス0 を持つ指標バッファの値で iBWMFIBuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,0,0,amount,values)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iBWMFI indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— インデックス 1 を持つ指標バッファの値で iBWMFIColors 配列の一部を記入する  if(CopyBuffer(ind_handle,1,0,amount,colors)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iBWMFI indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— 全てが成功  return(true);  }  //+——————————————————————+  //| 指標初期化解除関数                                                  |  //+——————————————————————+  void OnDeinit(const int reason)  {  //— 指標の削除後チャートをクリアする  Comment(“”);  }  | 
iMomentum
この関数は Momentum(モメンタム)指標のハンドルを返します。バッファは 1 つです。
int  iMomentum(  string              symbol,              ENUM_TIMEFRAMES      period,              int                  mom_period,         ENUM_APPLIED_PRICE   applied_price        );  | 
パラメータ
symbol
[in] データが指標計算に使用される有価証券の銘柄名(NULL は現在のシンボル)
period
[in] 期間の値は ENUM_TIMEFRAMES 列挙の値の 1 つで、0 は現在の時間軸の意味です。
mom_period
[in]  価格変化計算の平均期間(バーの数
applied_price
[in]  使用される価格。ENUM_APPLIED_PRICE 価格定数のいずれか、または別の指標ハンドル。
戻り値
例:
//+——————————————————————+  //|                                               Demo_iMomentum.mq5 |  //|                        Copyright 2011, MetaQuotes Software Corp. |  //|                                             https://www.MQL5.com |  //+——————————————————————+  #property copyright “Copyright 2011, MetaQuotes Software Corp.”  #property link     “https://www.mql5.com”  #property version   “1.00”  #property description “The indicator demonstrates how to obtain data”  #property description “of indicator buffers for the iMomentum technical indicator.”  #property description “A symbol and timeframe used for calculation of the indicator,”  #property description “are set by the symbol and period parameters.”  #property description “The method of creation of the handle is set through the ‘type’ parameter (function type).”  #property description “All the other parameters are similar to the standard Momentum.” #property indicator_separate_window  #property indicator_buffers 1  #property indicator_plots   1  //— モメンタムをプロット  #property indicator_label1 “iMomentum”  #property indicator_type1   DRAW_LINE  #property indicator_color1  clrDodgerBlue  #property indicator_style1 STYLE_SOLID  #property indicator_width1  1  //+——————————————————————+  //| 作成を処理する方法の列挙                                              |  //+——————————————————————+  enum Creation  {  Call_iMomentum,         // iMomentum を使用する  Call_IndicatorCreate   // IndicatorCreateを使用する  };  //— 入力パラメータ  input Creation             type=Call_iMomentum;       // 関数の種類   input int                  mom_period=14;             // モメンタムの期間  input ENUM_APPLIED_PRICE   applied_price=PRICE_CLOSE; // 価格の種類  input string               symbol=” “;               // シンボル   input ENUM_TIMEFRAMES     period=PERIOD_CURRENT;     // 時間軸  //— 指標バッファ  double         iMomentumBuffer[];  //— iMomentum 指標ハンドルを格納する変数  int    handle;  //— 格納に使用される変数  string name=symbol;  //— チャートでの指標名  string short_name;  //— モメンタム指標に値の数を保存  int    bars_calculated=0;  //+——————————————————————+  //| カスタム指標を初期化する関数                                            |  //+——————————————————————+  int OnInit()  {  //— 配列の指標バッファへの割り当て  SetIndexBuffer(0,iMomentumBuffer,INDICATOR_DATA);  //— 指標が描画するシンボルを決める  name=symbol;  //— 左右のスペースを削する  StringTrimRight(name);  StringTrimLeft(name);  //—「name」文字列の長さがゼロになった場合  if(StringLen(name)==0)  {  //— 指標が接続されているチャートのシンボルを取る  name=_Symbol;  }  //— 指標ハンドルを作成する  if(type==Call_iMomentum)  handle=iMomentum(name,period,mom_period,applied_price);  else  {  //— 構造体を指標のパラメータで記入  MqlParam pars[2];  //— 期間  pars[0].type=TYPE_INT;  pars[0].integer_value=mom_period;  //— 価格の種類  pars[1].type=TYPE_INT;  pars[1].integer_value=applied_price;  handle=IndicatorCreate(name,period,IND_MOMENTUM,2,pars);  }  //— ハンドルが作成されなかった場合  if(handle==INVALID_HANDLE)  {  //— 失敗した事実とエラーコードを出力する  PrintFormat(“Failed to create handle of the iMomentum indicator for the symbol %s/%s, error code %d”,  name,  EnumToString(period),  GetLastError());  //— 指標が早期に中止された  return(INIT_FAILED);  }  //— モメンタム指標が計算された銘柄/時間軸を表示  short_name=StringFormat(“iMomentum(%s/%s, %d, %s)”,name,EnumToString(period),  mom_period, EnumToString(applied_price));  IndicatorSetString(INDICATOR_SHORTNAME,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[])  {  //— iMomentum 指標から複製された値の数  int values_to_copy;  //— 指標で計算された値の数を決める  int calculated=BarsCalculated(handle);  if(calculated<=0)  {  PrintFormat(“BarsCalculated() returned %d, error code %d”,calculated,GetLastError());  return(0);  }  //— これが指標計算の初めであるか iMomentum 指標の値の数が変更した  //—または、2 つ以上のバーの指標の計算が必要である場合(価格履歴で何かが変更された)  if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1)  {  //— iMomentumBuffer 配列が銘柄/期間で iMomentum 指標の値の数より大きい場合、全体のコピーはしない  //— 他の場合、指標バッファサイズより少ない量をコピーをする  if(calculated>rates_total) values_to_copy=rates_total;  else                       values_to_copy=calculated;  }  else  {  //— これは初回の計算ではなく、  //— 前回の OnCalculate() から、一以上のバーが加えられてない。  values_to_copy=(rates_total-prev_calculated)+1;  }  //— iMomentumBuffer 配列をモメンタム指標の値で記入  //— FillArrayFromBuffer が false を返した場合、情報の準備が終わっていないので操作を終了する  if(!FillArrayFromBuffer(iMomentumBuffer,handle,values_to_copy)) return(0);  //— メッセージを形成する  string comm=StringFormat(“%s ==>  Updated value in the indicator %s: %d”,  TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS),  short_name,  values_to_copy);  //— チャートにサービスメッセージを表示する  Comment(comm);  //— モメンタム指標の値の数を覚える  bars_calculated=calculated;  //— prev_calculated 値を次の関数呼び出しのために返す  return(rates_total);  }  //+——————————————————————+  //| iMomentum 指標から指標バッファを記入する                                  |  //+——————————————————————+  bool FillArrayFromBuffer(double &values[], // モメンタム値の指標バッファ  int ind_handle,   // iMomentum 指標ハンドル  int amount         // 複製された値の数  )  {  //— エラーコードをリセットする  ResetLastError();  //— インデックス0 を持つ指標バッファの値で iMomentumBuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,0,0,amount,values)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iMomentum indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— 全てが成功  return(true);  }  //+——————————————————————+  //| 指標初期化解除関数                                                  |  //+——————————————————————+  void OnDeinit(const int reason)  {  //— 指標の削除後チャートをクリアする  Comment(“”);  }  | 
iMFI
この関数は MFI(Money Flow Index)指標ハンドルを返します。
int  iMFI(  string              symbol,              ENUM_TIMEFRAMES      period,              int                  ma_period,            ENUM_APPLIED_VOLUME  applied_volume        );  | 
パラメータ
symbol
[in] データが指標計算に使用される有価証券の銘柄名(NULL は現在のシンボル)
period
[in] 期間の値は ENUM_TIMEFRAMES 列挙の値の 1 つで、0 は現在の時間軸の意味です。
ma_period
[in] 計算の平均期間(バーの数)
applied_volume
[in]  使用されるボリューム(ENUM_APPLIED_VOLUME 値のいずれか)
戻り値
例:
//+——————————————————————+  //|                                                    Demo_iMFI.mq5 |  //|                        Copyright 2011, MetaQuotes Software Corp. |  //|                                             https://www.MQL5.com |  //+——————————————————————+  #property copyright “Copyright 2011, MetaQuotes Software Corp.”  #property link     “https://www.mql5.com”  #property version   “1.00”  #property description “The indicator demonstrates how to obtain data”  #property description “of indicator buffers for the iMFI technical indicator.”  #property description “A symbol and timeframe used for calculation of the indicator,”  #property description “are set by the symbol and period parameters.”  #property description “The method of creation of the handle is set through the ‘type’ parameter (function type).”  #property description “All the other parameters are similar to the standard Money Flow Index.” #property indicator_separate_window  #property indicator_buffers 1  #property indicator_plots   1  //— iMFI プロット  #property indicator_label1 “iMFI”  #property indicator_type1   DRAW_LINE  #property indicator_color1  clrDodgerBlue  #property indicator_style1 STYLE_SOLID  #property indicator_width1  1  //— 指標ウィンドウの水平レベル  #property indicator_level1  20  #property indicator_level2  80  //+——————————————————————+  //| 作成を処理する方法の列挙                                              |  //+——————————————————————+  enum Creation  {  Call_iMFI,             // iMFI を使用する  Call_IndicatorCreate   // IndicatorCreateを使用する  };  //— 入力パラメータ  input Creation             type=Call_iMFI;               // 関数の種類   input int                  ma_period=14;                 // 期間  input ENUM_APPLIED_VOLUME  applied_volume=VOLUME_TICK;   // ボリュームの種類  input string               symbol=” “;                   // シンボル   input ENUM_TIMEFRAMES     period=PERIOD_CURRENT;       // 時間軸  //— 指標バッファ  double         iMFIBuffer[];  //— iMFI 指標ハンドルを格納する変数r  int    handle;  //— 格納に使用される変数  string name=symbol;  //— チャートでの指標名  string short_name;  //— MFI 指標に値の数を保存  int    bars_calculated=0;  //+——————————————————————+  //| カスタム指標を初期化する関数                                            |  //+——————————————————————+  int OnInit()  {  //— 配列の指標バッファへの割り当て  SetIndexBuffer(0,iMFIBuffer,INDICATOR_DATA);  //— 指標が描画するシンボルを決める    name=symbol;  //— 左右のスペースを削する  StringTrimRight(name);  StringTrimLeft(name);  //—「name」文字列の長さがゼロになった場合  if(StringLen(name)==0)  {  //— 指標が接続されているチャートのシンボルを取る  name=_Symbol;  }  //— 指標ハンドルを作成する  if(type==Call_iMFI)  handle=iMFI(name,period,ma_period,applied_volume);  else  {  //— 構造体を指標のパラメータで記入  MqlParam pars[2];  //— 期間  pars[0].type=TYPE_INT;  pars[0].integer_value=ma_period;  //— ボリュームの種類  pars[1].type=TYPE_INT;  pars[1].integer_value=applied_volume;  handle=IndicatorCreate(name,period,IND_MFI,2,pars);  }  //— ハンドルが作成されなかった場合  if(handle==INVALID_HANDLE)  {  //— 失敗した事実とエラーコードを出力する  PrintFormat(“Failed to create handle of the iMFI indicator for the symbol %s/%s, error code %d”,  name,  EnumToString(period),  GetLastError());  //— 指標が早期に中止された  return(INIT_FAILED);  }  //— MFI 指標が計算された銘柄/時間軸を表示  short_name=StringFormat(“iMFI(%s/%s, %d, %s)”,name,EnumToString(period),  ma_period, EnumToString(applied_volume));  IndicatorSetString(INDICATOR_SHORTNAME,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[])  {  //— iMFI 指標から複製された値の数  int values_to_copy;  //— 指標で計算された値の数を決める  int calculated=BarsCalculated(handle);  if(calculated<=0)  {  PrintFormat(“BarsCalculated() returned %d, error code %d”,calculated,GetLastError());  return(0);  }  //— これが指標計算の初めであるか iMFI 指標の値の数が変更した  //—または、2 つ以上のバーの指標の計算が必要である場合(価格履歴で何かが変更された)  if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1)  {  //— iMFIBuffer 配列が銘柄/期間で iMFI 指標の値の数より大きい場合、全体のコピーはしない  //— 他の場合、指標バッファサイズより少ない量をコピーをする  if(calculated>rates_total) values_to_copy=rates_total;  else                       values_to_copy=calculated;  }  else  {  //— これは初回の計算ではなく、  //— 前回の OnCalculate() から、一以上のバーが加えられてない。  values_to_copy=(rates_total-prev_calculated)+1;  }  //— iMFIBuffer 配列をMFI 指標の値で記入  //— FillArrayFromBuffer が false を返した場合、情報の準備が終わっていないので操作を終了する  if(!FillArrayFromBuffer(iMFIBuffer,handle,values_to_copy)) return(0);  //— メッセージを形成する  string comm=StringFormat(“%s ==>  Updated value in the indicator %s: %d”,  TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS),  short_name,  values_to_copy);  //— チャートにサービスメッセージを表示する  Comment(comm);  //— MFI 指標に値の数を覚える  bars_calculated=calculated;  //— prev_calculated 値を次の関数呼び出しのために返す  return(rates_total);  }  //+——————————————————————+  //| iMFI 指標から指標バッファを記入する                                       |  //+——————————————————————+  bool FillArrayFromBuffer(double &values[], // MFI 値の指標バッファ  int ind_handle,   // iMFI 指標ハンドル  int amount         // 複製された値の数  )  {  //— エラーコードをリセットする  ResetLastError();  //— インデックス0 を持つ指標バッファの値で iMFIBuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,0,0,amount,values)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iMFI indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— 全てが成功  return(true);  }  //+——————————————————————+  //| 指標初期化解除関数                                                  |  //+——————————————————————+  void OnDeinit(const int reason)  {  //— 指標の削除後チャートをクリアする  Comment(“”);  }  | 
iMA
この関数は Moving Average(移動平均線)指標のハンドルを返します。バッファは 1 つです。
int  iMA(  string              symbol,              ENUM_TIMEFRAMES      period,              int                  ma_period,          int                  ma_shift,            ENUM_MA_METHOD      ma_method,          ENUM_APPLIED_PRICE   applied_price        );  | 
パラメータ
symbol
[in] データが指標計算に使用される有価証券の銘柄名(NULL は現在のシンボル)
period
[in] 期間の値は ENUM_TIMEFRAMES 列挙の値の 1 つで、0 は現在の時間軸の意味です。
ma_period
[in] 移動平均計算の期間
ma_shift
[in]  価格チャートに相対した指標のシフト
ma_method
[in]  平滑化の種類ENUM_MA_METHOD 値のいずれか
applied_price
[in]  使用される価格。ENUM_APPLIED_PRICE 価格定数のいずれか、または別の指標ハンドル。
戻り値
例:
//+——————————————————————+  //|                                                     Demo_iMA.mq5 |  //|                        Copyright 2011, MetaQuotes Software Corp. |  //|                                             https://www.MQL5.com |  //+——————————————————————+  #property copyright “Copyright 2011, MetaQuotes Software Corp.”  #property link     “https://www.mql5.com”  #property version   “1.00”  #property description “The indicator demonstrates how to obtain data”  #property description “of indicator buffers for the iMA technical indicator.”  #property description “A symbol and timeframe used for calculation of the indicator,”  #property description “are set by the symbol and period parameters.”  #property description “The method of creation of the handle is set through the ‘type’ parameter (function type).”  #property description “All other parameters like in the standard Moving Average.” #property indicator_chart_window  #property indicator_buffers 1  #property indicator_plots   1  //— iMA プロット  #property indicator_label1 “iMA”  #property indicator_type1   DRAW_LINE  #property indicator_color1  clrRed  #property indicator_style1 STYLE_SOLID  #property indicator_width1  1  //+——————————————————————+  //| 作成を処理する方法の列挙                                              |  //+——————————————————————+  enum Creation  {  Call_iMA,               // iMA を使用  Call_IndicatorCreate   // IndicatorCreateを使用する  };  //— 入力パラメータ  input Creation             type=Call_iMA;               // 関数の種類   input int                  ma_period=10;                 // MA 期間  input int                  ma_shift=0;                   // シフト  input ENUM_MA_METHOD       ma_method=MODE_SMA;           // 平滑化の種類  input ENUM_APPLIED_PRICE   applied_price=PRICE_CLOSE;   // 価格の種類  input string               symbol=” “;                   // シンボル   input ENUM_TIMEFRAMES     period=PERIOD_CURRENT;       // 時間軸  //— 指標バッファ  double         iMABuffer[];  //— iMA 指標ハンドルを格納する変数  int    handle;  //— 格納に使用される変数  string name=symbol;  //— チャートでの指標名  string short_name;  //— 移動平均線指標に値の数を保存  int    bars_calculated=0;  //+——————————————————————+  //| カスタム指標を初期化する関数                                            |  //+——————————————————————+  int OnInit()  {  //— 配列の指標バッファへの割り当て  SetIndexBuffer(0,iMABuffer,INDICATOR_DATA);  //— シフトを設定  PlotIndexSetInteger(0,PLOT_SHIFT,ma_shift);  //— 指標が描画するシンボルを決める    name=symbol;  //— 左右のスペースを削する  StringTrimRight(name);  StringTrimLeft(name);  //—「name」文字列の長さがゼロになった場合  if(StringLen(name)==0)  {  //— 指標が接続されているチャートのシンボルを取る  name=_Symbol;  }  //— 指標ハンドルを作成する  if(type==Call_iMA)  handle=iMA(name,period,ma_period,ma_shift,ma_method,applied_price);  else  {  //— 構造体を指標のパラメータで記入  MqlParam pars[4];  //— 期間  pars[0].type=TYPE_INT;  pars[0].integer_value=ma_period;  //— シフト  pars[1].type=TYPE_INT;  pars[1].integer_value=ma_shift;  //— 平滑化の種類  pars[2].type=TYPE_INT;  pars[2].integer_value=ma_method;  //— 価格の種類  pars[3].type=TYPE_INT;  pars[3].integer_value=applied_price;  handle=IndicatorCreate(name,period,IND_MA,4,pars);  }  //— ハンドルが作成されなかった場合  if(handle==INVALID_HANDLE)  {  //— 失敗した事実とエラーコードを出力する  PrintFormat(“Failed to create handle of the iMA indicator for the symbol %s/%s, error code %d”,  name,  EnumToString(period),  GetLastError());  //— 指標が早期に中止された  return(INIT_FAILED);  }  //— 移動平均線が計算された銘柄/時間軸を表示  short_name=StringFormat(“iMA(%s/%s, %d, %d, %s, %s)”,name,EnumToString(period),  ma_period, ma_shift,EnumToString(ma_method),EnumToString(applied_price));  IndicatorSetString(INDICATOR_SHORTNAME,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[])  {  //— iMA 指標から複製された値の数  int values_to_copy;  //— 指標で計算された値の数を決める  int calculated=BarsCalculated(handle);  if(calculated<=0)  {  PrintFormat(“BarsCalculated() returned %d, error code %d”,calculated,GetLastError());  return(0);  }  //— これが指標計算の初めであるか iMA 指標の値の数が変更した  //—または、2 つ以上のバーの指標の計算が必要である場合(価格履歴で何かが変更された)  if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1)  {  //— iMABuffer 配列が銘柄/期間で iMA 指標の値の数より大きい場合、全体のコピーはしない  //— 他の場合、指標バッファサイズより少ない量をコピーをする  if(calculated>rates_total) values_to_copy=rates_total;  else                       values_to_copy=calculated;  }  else  {  //— これは初回の計算ではなく、  //— 前回の OnCalculate() から、一以上のバーが加えられてない。  values_to_copy=(rates_total-prev_calculated)+1;  }  //— iMABuffer 配列を適応型移動平均線指標の値で記入する  //— FillArrayFromBuffer が false を返した場合、情報の準備が終わっていないので操作を終了する  if(!FillArrayFromBuffer(iMABuffer,ma_shift,handle,values_to_copy)) return(0);  //— メッセージを形成する  string comm=StringFormat(“%s ==>  Updated value in the indicator %s: %d”,  TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS),  short_name,  values_to_copy);  //— チャートにサービスメッセージを表示する  Comment(comm);  //— 移動平均線指標の値の数を覚える  bars_calculated=calculated;  //— prev_calculated 値を次の関数呼び出しのために返す  return(rates_total);  }  //+——————————————————————+  //| 移動平均線指標から指標バッファを記入する                                   |  //+——————————————————————+  bool FillArrayFromBuffer(double &values[],   // 移動平均線値の指標バッファ—  int shift,         // シフト  int ind_handle,     // iMA 指標ハンドル  int amount         // 複製された値の数  )  {  //— エラーコードをリセットする  ResetLastError();  //— インデックス0 を持つ指標バッファの値で iMABuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,0,-shift,amount,values)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iMA indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— 全てが成功  return(true);  }  //+——————————————————————+  //| 指標初期化解除関数                                                  |  //+——————————————————————+  void OnDeinit(const int reason)  {  //— 指標の削除後チャートをクリアする  Comment(“”);  }  | 
iOsMA
この関数は Moving Average of Oscillator(移動平均オシレーター)指標のハンドルを返します。OsMA オシレーターは MACD とシグナル線の差を表示します。バッファは 1 つです。
int  iOsMA(  string              symbol,                ENUM_TIMEFRAMES    period,                int                fast_ema_period,      int                slow_ema_period,      int                signal_period,        ENUM_APPLIED_PRICE  applied_price          );  | 
パラメータ
symbol
[in] データが指標計算に使用される有価証券の銘柄名(NULL は現在のシンボル)
period
[in] 期間の値は ENUM_TIMEFRAMES 列挙の値の 1 つで、0 は現在の時間軸の意味です。
fast_ema_period
[in]  高速移動平均計算の期間
slow_ema_period
[in]  低速移動平均計算の期間
signal_period
[in]  シグナル線計算の平均期間
applied_price
[in]  使用される価格。ENUM_APPLIED_PRICE 価格定数のいずれか、または別の指標ハンドル。
戻り値
注意事項
例:
//+——————————————————————+  //|                                                   Demo_iOsMA.mq5 |  //|                        Copyright 2011, MetaQuotes Software Corp. |  //|                                             https://www.MQL5.com |  //+——————————————————————+  #property copyright “Copyright 2011, MetaQuotes Software Corp.”  #property link     “https://www.mql5.com”  #property version   “1.00”  #property description “The indicator demonstrates how to obtain data”  #property description “of indicator buffers for the iOsMA technical indicator.”  #property description “A symbol and timeframe used for calculation of the indicator,”  #property description “are set by the symbol and period parameters.”  #property description “The method of creation of the handle is set through the ‘type’ parameter (function type).”  #property description “All the other parameters are similar to the standard Moving Average of Oscillator.” #property indicator_separate_window  #property indicator_buffers 1  #property indicator_plots   1  //— iOsMA プロット  #property indicator_label1 “iOsMA”  #property indicator_type1   DRAW_HISTOGRAM  #property indicator_color1  clrSilver  #property indicator_style1 STYLE_SOLID  #property indicator_width1  1  //+——————————————————————+  //| 作成を処理する方法の列挙                                              |  //+——————————————————————+  enum Creation  {  Call_iOsMA,             // iOsMA を使用する  Call_IndicatorCreate   // IndicatorCreateを使用する  };  //— 入力パラメータ  input Creation             type=Call_iOsMA;           // 関数の種類   input int                  fast_ema_period=12;       // 高速 MA 期間  input int                  slow_ema_period=26;       // 低速 MA 期間  input int                  signal_period=9;           // 差の平均期間  input ENUM_APPLIED_PRICE   applied_price=PRICE_CLOSE; // 価格の種類  input string               symbol=” “;               // シンボル   input ENUM_TIMEFRAMES     period=PERIOD_CURRENT;     // 時間軸  //— 指標バッファ  double         iOsMABuffer[];  //— iAMA 指標ハンドルを格納する変数  int    handle;  //— 格納に使用される変数  string name=symbol;  //— チャートでの指標名  string short_name;  //— 移動平均線指標に値の数を保存  int    bars_calculated=0;  //+——————————————————————+  //| カスタム指標を初期化する関数                                            |  //+——————————————————————+  int OnInit()  {  //— 配列の指標バッファへの割り当て  SetIndexBuffer(0,iOsMABuffer,INDICATOR_DATA);  //— 指標が描画するシンボルを決める  name=symbol;  //— 左右のスペースを削する  StringTrimRight(name);  StringTrimLeft(name);  //—「name」文字列の長さがゼロになった場合  if(StringLen(name)==0)  {  //— 指標が接続されているチャートのシンボルを取る  name=_Symbol;  }  //— 指標ハンドルを作成する  if(type==Call_iOsMA)  handle=iOsMA(name,period,fast_ema_period,slow_ema_period,signal_period,applied_price);  else  {  //— 構造体を指標のパラメータで記入       MqlParam pars[4];  //— 高速 MA 期間  pars[0].type=TYPE_INT;  pars[0].integer_value=fast_ema_period;  //— 低速 MA 期間  pars[1].type=TYPE_INT;  pars[1].integer_value=slow_ema_period;  //— 高速移動平均と低速移動平均の差の平均期間  pars[2].type=TYPE_INT;  pars[2].integer_value=signal_period;  //— 価格の種類  pars[3].type=TYPE_INT;  pars[3].integer_value=applied_price;  handle=IndicatorCreate(name,period,IND_OSMA,4,pars);  }  //— ハンドルが作成されなかった場合  if(handle==INVALID_HANDLE)  {  //— 失敗した事実とエラーコードを出力する  PrintFormat(“Failed to create a handle of iOsMA for the pair %s/%s, error code is %d”,  name,  EnumToString(period),  GetLastError());  //— 指標が早期に中止された  return(INIT_FAILED);  }  //— 移動平均オシレーター指標が計算された銘柄/時間軸を表示  short_name=StringFormat(“iOsMA(%s/%s,%d,%d,%d,%s)”,name,EnumToString(period),  fast_ema_period,slow_ema_period,signal_period,EnumToString(applied_price));  IndicatorSetString(INDICATOR_SHORTNAME,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[])  {  //— iOsMA 指標から複製された値の数  int values_to_copy;  //— 指標で計算された値の数を決める  int calculated=BarsCalculated(handle);  if(calculated<=0)  {  PrintFormat(“BarsCalculated() returned %d, error code %d”,calculated,GetLastError());  return(0);  }  //— これが指標計算の初めであるか iOsMA 指標の値の数が変更した changed  //—または、2 つ以上のバーの指標の計算が必要である場合(価格履歴で何かが変更された)  if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1)  {  //— iOsMABuffer 配列が銘柄/期間で iOsMA 指標の値の数より大きい場合、全体のコピーはしない   //— 他の場合、指標バッファサイズより少ない量をコピーをする  if(calculated>rates_total) values_to_copy=rates_total;  else                       values_to_copy=calculated;  }  else  {  //— これは初回の計算ではなく、  //— 前回の OnCalculate() から、一以上のバーが加えられてない。  values_to_copy=(rates_total-prev_calculated)+1;  }  //— 配列をiOsMA 指標の値で記入  //— FillArrayFromBuffer が false を返した場合、情報の準備が終わっていないので操作を終了する  if(!FillArrayFromBuffer(iOsMABuffer,handle,values_to_copy)) return(0);  //— メッセージを形成する  string comm=StringFormat(“%s ==>  Updated value in the indicator %s: %d”,  TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS),  short_name,  values_to_copy);  //— チャートにサービスメッセージを表示する  Comment(comm);  //— 移動平均オシレーター指標の値の数を覚える  bars_calculated=calculated;  //— prev_calculated 値を次の関数呼び出しのために返す  return(rates_total);  }  //+——————————————————————+  //| iOsMA 指標から指標バッファを記入する                                      |  //+——————————————————————+  bool FillArrayFromBuffer(double &ama_buffer[], // OsMA 値の指標バッファ  int ind_handle,       // iOsMA 指標ハンドル  int amount             // 複製された値の数  )  {  //— エラーコードをリセットする  ResetLastError();  //— インデックス0 を持つ指標バッファの値で iOsMABuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,0,0,amount,ama_buffer)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iOsMA indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— 全てが成功  return(true);  }  //+——————————————————————+  //| 指標初期化解除関数                                                  |  //+——————————————————————+  void OnDeinit(const int reason)  {  //— 指標の削除後チャートをクリアする  Comment(“”);  }  | 
iMACD
この関数は MACD(Moving Averages Convergence/Divergence)指標ハンドルを返します。OsMA が MACD ヒストグラムと呼ばれるシステムでは、この指標は 2 本の線として表示されます。クライアント端末では MACD はヒストグラムのように見えます。
int  iMACD(  string              symbol,                ENUM_TIMEFRAMES    period,                int                fast_ema_period,      int                slow_ema_period,      int                signal_period,        ENUM_APPLIED_PRICE  applied_price          );  | 
パラメータ
symbol
[in] データが指標計算に使用される有価証券の銘柄名(NULL は現在のシンボル)
period
[in] 期間の値は ENUM_TIMEFRAMES 列挙の値の 1 つで、0 は現在の時間軸の意味です。
fast_ema_period
[in]  高速移動平均計算の期間
slow_ema_period
[in]  低速移動平均計算の期間
signal_period
[in]  シグナル線の計算期間
applied_price
[in]  使用される価格。ENUM_APPLIED_PRICE 価格定数のいずれか、または別の指標ハンドル。
戻り値
注意事項
例:
//+——————————————————————+  //|                                                   Demo_iMACD.mq5 |  //|                        Copyright 2011, MetaQuotes Software Corp. |  //|                                             https://www.MQL5.com |  //+——————————————————————+  #property copyright “Copyright 2011, MetaQuotes Software Corp.”  #property link     “https://www.mql5.com”  #property version   “1.00”  #property description “The indicator demonstrates how to obtain data”  #property description “of indicator buffers for the iMACD technical indicator.”  #property description “A symbol and timeframe used for calculation of the indicator,”  #property description “are set by the symbol and period parameters.”  #property description “The method of creation of the handle is set through the ‘type’ parameter (function type).”  #property description “All other parameters like in the standard MACD.” #property indicator_separate_window  #property indicator_buffers 2  #property indicator_plots   2  //— MACD プロット  #property indicator_label1 “MACD”  #property indicator_type1   DRAW_HISTOGRAM  #property indicator_color1  clrSilver  #property indicator_style1 STYLE_SOLID  #property indicator_width1  1  //— シグナルプロット  #property indicator_label2 “Signal”  #property indicator_type2   DRAW_LINE  #property indicator_color2  clrRed  #property indicator_style2 STYLE_DOT  #property indicator_width2  1  //+——————————————————————+  //| 作成を処理する方法の列挙                                              |  //+——————————————————————+  enum Creation  {  Call_iMACD,             // iMACD を使用する  Call_IndicatorCreate   // IndicatorCreateを使用する  };  //— 入力パラメータ  input Creation             type=Call_iMACD;           // 関数の種類   input int                  fast_ema_period=12;       // 高速 MA 期間  input int                  slow_ema_period=26;       // 低速 MA 期間  input int                  signal_period=9;           // 差の平均期間  input ENUM_APPLIED_PRICE   applied_price=PRICE_CLOSE; // 価格の種類  input string               symbol=” “;               // シンボル   input ENUM_TIMEFRAMES     period=PERIOD_CURRENT;     // 時間軸  //— 指標バッファ  double         MACDBuffer[];  double         SignalBuffer[];  //— iMACD 指標ハンドルを格納する変数  int    handle;  //— 格納に使用される変数  string name=symbol;  //— チャートでの指標名  string short_name;  //— MACD 指標に値の数を保存  int    bars_calculated=0;  //+——————————————————————+  //| カスタム指標を初期化する関数                                            |  //+——————————————————————+  int OnInit()  {  //— 配列の指標バッファへの割り当て  SetIndexBuffer(0,MACDBuffer,INDICATOR_DATA);  SetIndexBuffer(1,SignalBuffer,INDICATOR_DATA);  //— 指標が描画するシンボルを決める  name=symbol;  //— 左右のスペースを削する  StringTrimRight(name);  StringTrimLeft(name);  //—「name」文字列の長さがゼロになった場合  if(StringLen(name)==0)  {  //— 指標が接続されているチャートのシンボルを取る  name=_Symbol;  }  //— 指標ハンドルを作成する  if(type==Call_iMACD)  handle=iMACD(name,period,fast_ema_period,slow_ema_period,signal_period,applied_price);  else  {  //— 構造体を指標のパラメータで記入       MqlParam pars[4];  //— 高速 MA 期間  pars[0].type=TYPE_INT;  pars[0].integer_value=fast_ema_period;  //— 低速 MA 期間  pars[1].type=TYPE_INT;  pars[1].integer_value=slow_ema_period;  //— 高速移動平均と低速移動平均の差の平均期間  pars[2].type=TYPE_INT;  pars[2].integer_value=signal_period;  //— 価格の種類  pars[3].type=TYPE_INT;  pars[3].integer_value=applied_price;  handle=IndicatorCreate(name,period,IND_MACD,4,pars);  }  //— ハンドルが作成されなかった場合  if(handle==INVALID_HANDLE)  {  //— 失敗した事実とエラーコードを出力する  PrintFormat(“Failed to create handle of the iMACD indicator for the symbol %s/%s, error code %d”,  name,  EnumToString(period),  GetLastError());  //— 指標が早期に中止された  return(INIT_FAILED);  }  //— MACD が計算された銘柄/時間軸を表示  short_name=StringFormat(“iMACD(%s/%s,%d,%d,%d,%s)”,name,EnumToString(period),  fast_ema_period,slow_ema_period,signal_period,EnumToString(applied_price));  IndicatorSetString(INDICATOR_SHORTNAME,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[])  {  //— iMACD 指標から複製された値の数  int values_to_copy;  //— 指標で計算された値の数を決める  int calculated=BarsCalculated(handle);  if(calculated<=0)  {  PrintFormat(“BarsCalculated() returned %d, error code %d”,calculated,GetLastError());  return(0);  }  //— これが指標計算の初めであるか iMACD 指標の値の数が変更した  //—または、2 つ以上のバーの指標の計算が必要である場合(価格履歴で何かが変更された)  if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1)  {  //— MACDBuffer 配列が銘柄/期間でiMACD 指標の値の数より大きい場合、全体のコピーはしない   //— 他の場合、指標バッファサイズより少ない量をコピーをする  if(calculated>rates_total) values_to_copy=rates_total;  else                       values_to_copy=calculated;  }  else  {  //— これは初回の計算ではなく、  //— 前回の OnCalculate() から、一以上のバーが加えられてない。  values_to_copy=(rates_total-prev_calculated)+1;  }  //— 配列を iMACD 指標の値で記入  //— FillArraysFromBuffer が false を返した場合、情報の準備が終わっていないので操作を終了する  if(!FillArraysFromBuffers(MACDBuffer,SignalBuffer,handle,values_to_copy)) return(0);  //— メッセージを形成する  string comm=StringFormat(“%s ==>  Updated value in the indicator %s: %d”,  TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS),  short_name,  values_to_copy);  //— チャートにサービスメッセージを表示する  Comment(comm);  //— MACD 指標の値の数を覚える  bars_calculated=calculated;  //— prev_calculated 値を次の関数呼び出しのために返す  return(rates_total);  }  //+——————————————————————+  //| iMACD 指標から指標バッファを記入する                                      |  //+——————————————————————+  bool FillArraysFromBuffers(double &macd_buffer[],   // MACD 値の指標バッファ  double &signal_buffer[], // MACD シグナル線の指標バッファ   int ind_handle,           // iMACD 指標ハンドル  int amount               // 複製された値の数  )  {  //— エラーコードをリセットする  ResetLastError();  //— インデックス0 を持つ指標バッファの値で iMACDBuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,0,0,amount,macd_buffer)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iMACD indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  } //— インデックス 1 を持つ指標バッファの値で SignalBuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,1,0,amount,signal_buffer)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iMACD indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— 全てが成功  return(true);  }  //+——————————————————————+  //| 指標初期化解除関数                                                  |  //+——————————————————————+  void OnDeinit(const int reason)  {  //— 指標の削除後チャートをクリアする  Comment(“”);  }  | 
iOBV
この関数は On Balance Volume (オンバランスボリューム)指標のハンドルを返します。バッファは 1 つです。
int  iOBV(  string                symbol,              ENUM_TIMEFRAMES      period,              ENUM_APPLIED_VOLUME   applied_volume        );  | 
パラメータ
symbol
[in] データが指標計算に使用される有価証券の銘柄名(NULL は現在のシンボル)
period
[in] 期間の値は ENUM_TIMEFRAMES 列挙の値の 1 つで、0 は現在の時間軸の意味です。
applied_volume
[in]  使用されるボリューム(ENUM_APPLIED_VOLUME 値のいずれか)
戻り値
例:
//+——————————————————————+  //|                                                    Demo_iOBV.mq5 |  //|                        Copyright 2011, MetaQuotes Software Corp. |  //|                                             https://www.MQL5.com |  //+——————————————————————+  #property copyright “Copyright 2011, MetaQuotes Software Corp.”  #property link     “https://www.mql5.com”  #property version   “1.00”  #property description “The indicator demonstrates how to obtain data”  #property description “of indicator buffers for the iOBV technical indicator.”  #property description “A symbol and timeframe used for calculation of the indicator,”  #property description “are set by the symbol and period parameters.”  #property description “The method of creation of the handle is set through the ‘type’ parameter (function type).” #property indicator_separate_window  #property indicator_buffers 1  #property indicator_plots   1  //—  iOBV  #property indicator_label1 “iOBV”  #property indicator_type1   DRAW_LINE  #property indicator_color1  clrLightSeaGreen  #property indicator_style1 STYLE_SOLID  #property indicator_width1  1  //+——————————————————————+  //| 作成を処理する方法の列挙                                              |  //+——————————————————————+  enum Creation  {  Call_iOBV ,             // iOBV を使用する  Call_IndicatorCreate   // IndicatorCreateを使用する  };  //— 入力パラメータ  input Creation             type=Call_iOBV;               // 関数の種類   input ENUM_APPLIED_VOLUME  applied_volume=VOLUME_TICK;   // ボリュームの種類  input string               symbol=” “;                   // シンボル   input ENUM_TIMEFRAMES &nnbsp;   period=PERIOD_CURRENT;       // 時間軸  //— 指標バッファ  double         iOBVBuffer[];  //— iOBV 指標ハンドルを格納する変数  int    handle;  //— 格納に使用される変数  string name=symbol;  //— チャートでの指標名  string short_name;  //— オンバランスボリューム指標に値の数を保存  int    bars_calculated=0;  //+——————————————————————+  //| カスタム指標を初期化する関数                                            |  //+——————————————————————+  int OnInit()  {  //— 配列の指標バッファへの割り当て  SetIndexBuffer(0,iOBVBuffer,INDICATOR_DATA);  //— 指標が描画するシンボルを決める  name=symbol;  //— 左右のスペースを削する  StringTrimRight(name);  StringTrimLeft(name);  //—「name」文字列の長さがゼロになった場合  if(StringLen(name)==0)  {  //— 指標が接続されているチャートのシンボルを取る  name=_Symbol;  }  //— 指標ハンドルを作成する  if(type==Call_iOBV)  handle=iOBV(name,period,applied_volume);  else  {  //— 構造体を指標のパラメータで記入       MqlParam pars[1];  //— ボリュームの種類  pars[0].type=TYPE_INT;  pars[0].integer_value=applied_volume;  handle=IndicatorCreate(name,period,IND_OBV,1,pars);  }  //— ハンドルが作成されなかった場合  if(handle==INVALID_HANDLE)  {  //— 失敗した事実とエラーコードを出力する  PrintFormat(“Failed to create handle of the iOBV indicator for the symbol %s/%s, error code %d”,  name,  EnumToString(period),  GetLastError());  //— 指標が早期に中止された  return(INIT_FAILED);  }  //— オンバランスボリューム指標が計算された銘柄/時間軸を表示  short_name=StringFormat(“iOBV(%s/%s, %s)”,name,EnumToString(period),  EnumToString(applied_volume));  IndicatorSetString(INDICATOR_SHORTNAME,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[])  {  //— iOBV 指標から複製された値の数  int values_to_copy;  //— 指標で計算された値の数を決める  int calculated=BarsCalculated(handle);  if(calculated<=0)  {  PrintFormat(“BarsCalculated() returned %d, error code %d”,calculated,GetLastError());  return(0);  }  //— これが指標計算の初めであるか iOBV 指標の値の数が変更した  //—または、2 つ以上のバーの指標の計算が必要である場合(価格履歴で何かが変更された)  if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1)  {  //— iOBVBuffer 配列が銘柄/期間で iOBV 指標の値の数より大きい場合、全体のコピーはしない  //— 他の場合、指標バッファサイズより少ない量をコピーをする  if(calculated>rates_total) values_to_copy=rates_total;  else                       values_to_copy=calculated;  }  else  {  //— これは初回の計算ではなく、  //— 前回の OnCalculate() から、一以上のバーが加えられてない。  values_to_copy=(rates_total-prev_calculated)+1;  }  //— 配列を iOBV 指標の値で記入  //— FillArrayFromBuffer が false を返した場合、情報の準備が終わっていないので操作を終了する  if(!FillArrayFromBuffer(iOBVBuffer,handle,values_to_copy)) return(0);  //— メッセージを形成する  string comm=StringFormat(“%s ==>  Updated value in the indicator %s: %d”,  TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS),  short_name,  values_to_copy);  //— チャートにサービスメッセージを表示する  Comment(comm);  //— オンバランスボリューム指標値の数を覚える  bars_calculated=calculated;  //— prev_calculated 値を次の関数呼び出しのために返す  return(rates_total);  }  //+——————————————————————+  //| iOBV 指標から指標バッファを記入する                                       |  //+——————————————————————+  bool FillArrayFromBuffer(double &obv_buffer[], // OBV 値の指標バッファ  int ind_handle,       // iOBV 指標ハンドル  int amount             // 複製された値の数  )  {  //— エラーコードをリセットする  ResetLastError();  //— インデックス0 を持つ指標バッファの値で iOBVBuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,0,0,amount,obv_buffer)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iOBV indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— 全てが成功  return(true);  }  //+——————————————————————+  //| 指標初期化解除関数                                                  |  //+——————————————————————+  void OnDeinit(const int reason)  {  //— 指標の削除後チャートをクリアする  Comment(“”);  }  | 
iSAR
この関数は Parabolic Stop and Reverse system(パラボリック SAR )の指標ハンドルを返します。バッファは 1 つです。
int  iSAR(  string          symbol,        ENUM_TIMEFRAMES  period,        double          step,          double          maximum      ステップの最大値  );  | 
パラメータ
symbol
[in] データが指標計算に使用される有価証券の銘柄名(NULL は現在のシンボル)
period
[in] 期間の値は ENUM_TIMEFRAMES 列挙の値の 1 つで、0 は現在の時間軸の意味です。
step
[in]  価格増分ステップ(通常  0.02 )
maximum
[in]  ステップの最大値(通常 0.2 )
戻り値
例:
//+——————————————————————+  //|                                                    Demo_iSAR.mq5 |  //|                        Copyright 2011, MetaQuotes Software Corp. |  //|                                             https://www.MQL5.com |  //+——————————————————————+  #property copyright “Copyright 2011, MetaQuotes Software Corp.”  #property link     “https://www.mql5.com”  #property version   “1.00”  #property description “The indicator demonstrates how to obtain data”  #property description “of indicator buffers for the iSAR technical indicator.”  #property description “A symbol and timeframe used for calculation of the indicator,”  #property description “are set by the symbol and period parameters.”  #property description “The method of creation of the handle is set through the ‘type’ parameter (function type).”  #property description “All the other parameters are similar to the standard Parabolic Stop and Reverse.” #property indicator_chart_window  #property indicator_buffers 1  #property indicator_plots   1  //— iSAR の描画  #property indicator_label1 “iSAR”  #property indicator_type1   DRAW_ARROW  #property indicator_color1  clrBlue  #property indicator_style1 STYLE_SOLID  #property indicator_width1  1  //+——————————————————————+  //| 作成を処理する方法の列挙                                              |  //+——————————————————————+  enum Creation  {  Call_iSAR,             // iSAR を使用する  Call_IndicatorCreate   // IndicatorCreateを使用する  };  //— 入力パラメータ  input Creation             type=Call_iSAR;               // 関数の種類   input double               step=0.02;                   // ストップトレイリングの加速因子  input double               maximum=0.2;                 // ステップの最大値  input string               symbol=” “;                   // シンボル   input ENUM_TIMEFRAMES     period=PERIOD_CURRENT;       // 時間軸  //— 指標バッファ  double         iSARBuffer[];  //— iSAR 指標ハンドルを格納する変数  int    handle;  //— 格納に使用される変数  string name=symbol;  //— チャートでの指標名  string short_name;  //— パラボリックSAR 指標に値の数を保存  int    bars_calculated=0;  //+——————————————————————+  //| カスタム指標を初期化する関数                                            |  //+——————————————————————+  int OnInit()  {  //— 配列の指標バッファへの割り当て  SetIndexBuffer(0,iSARBuffer,INDICATOR_DATA);  //— シャーとに表示する PLOT_ARROW プロパティのコードを Wingdings 文字セットからの記号を使用して設定  PlotIndexSetInteger(0,PLOT_ARROW,159);  //— 指標が描画するシンボルを決める  name=symbol;  //— 左右のスペースを削する  StringTrimRight(name);  StringTrimLeft(name);  //—「name」文字列の長さがゼロになった場合  if(StringLen(name)==0)  {  //— 指標が接続されているチャートのシンボルを取る  name=_Symbol;  }  //— 指標ハンドルを作成する  if(type==Call_iSAR)  handle=iSAR(name,period,step,maximum);  else  {  //— 構造体を指標のパラメータで記入       MqlParam pars[2];  //— ステップ値  pars[0].type=TYPE_DOUBLE;  pars[0].double_value=step;  //— 計算に使用するステップ値の制限  pars[1].type=TYPE_DOUBLE;  pars[1].double_value=maximum;  handle=IndicatorCreate(name,period,IND_SAR,2,pars);  }  //— ハンドルが作成されなかった場合  if(handle==INVALID_HANDLE)  {  //— 失敗した事実とエラーコードを出力する  PrintFormat(“Failed to create handle of the iSAR indicator for the symbol %s/%s, error code %d”,  name,  EnumToString(period),  GetLastError());  //— 指標が早期に中止された  return(INIT_FAILED);  }  //— パラボリック SAR 指標が計算された銘柄/時間軸を表示する  short_name=StringFormat(“iSAR(%s/%s, %G, %G)”,name,EnumToString(period),  step,maximum);  IndicatorSetString(INDICATOR_SHORTNAME,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[])  {  //— iSAR 指標から複製された値の数  int values_to_copy;  //— 指標で計算された値の数を決める  int calculated=BarsCalculated(handle);  if(calculated<=0)  {  PrintFormat(“BarsCalculated() returned %d, error code %d”,calculated,GetLastError());  return(0);  }  //— これが指標計算の初めであるか iSAR 指標の値の数が変更した  //—または、2 つ以上のバーの指標の計算が必要である場合(価格履歴で何かが変更された)  if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1)  {  //— iSARBuffer 配列が銘柄/期間でiSAR 指標の値の数より大きい場合、全体のコピーはしない   //— 他の場合、指標バッファサイズより少ない量をコピーをする  if(calculated>rates_total) values_to_copy=rates_total;  else                       values_to_copy=calculated;  }  else  {  //— これは初回の計算ではなく、  //— 前回の OnCalculate() から、一以上のバーが加えられてない。  values_to_copy=(rates_total-prev_calculated)+1;  }  //— 配列をiSAR 指標の値で記入  //— FillArrayFromBuffer が false を返した場合、情報の準備が終わっていないので操作を終了する  if(!FillArrayFromBuffer(iSARBuffer,handle,values_to_copy)) return(0);  //— メッセージを形成する  string comm=StringFormat(“%s ==>  Updated value in the indicator %s: %d”,  TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS),  short_name,  values_to_copy);  //— チャートにサービスメッセージを表示する  Comment(comm);  //— パラボリックSAR 指標の値の数を覚える  bars_calculated=calculated;  //— prev_calculated 値を次の関数呼び出しのために返す  return(rates_total);  }  //+——————————————————————+  //| iSAR 指標から指標バッファを記入する                                       |  //+——————————————————————+  bool FillArrayFromBuffer(double &sar_buffer[], // パラボリック SAR 値の指標バッファ  int ind_handle,       // iSAR 指標ハンドル  int amount             // 複製された値の数  )  {  //— エラーコードをリセットする  ResetLastError();  //— インデックス0 を持つ指標バッファの値で iSARBuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,0,0,amount,sar_buffer)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iSAR indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— 全てが成功  return(true);  }  //+——————————————————————+  //| 指標初期化解除関数                                                  |  //+——————————————————————+  void OnDeinit(const int reason)  {  //— 指標の削除後チャートをクリアする  Comment(“”);  }  | 
iRSI
この関数は Relative Strength Index(相対力指数)指標のハンドルを返します。バッファは 1 つです。
int  iRSI(  string              symbol,              ENUM_TIMEFRAMES    period,              int                ma_period,          ENUM_APPLIED_PRICE  applied_price        );  | 
パラメータ
symbol
[in] データが指標計算に使用される有価証券の銘柄名(NULL は現在のシンボル)
period
[in] 期間の値は ENUM_TIMEFRAMES 列挙の値の 1 つで、0 は現在の時間軸の意味です。
ma_period
[in]  RSI 計算の平均期間
applied_price
[in]  使用される価格。ENUM_APPLIED_PRICE 価格定数のいずれか、または別の指標ハンドル。
戻り値
例:
//+——————————————————————+  //|                                                    Demo_iRSI.mq5 |  //|                        Copyright 2011, MetaQuotes Software Corp. |  //|                                             https://www.MQL5.com |  //+——————————————————————+  #property copyright “Copyright 2011, MetaQuotes Software Corp.”  #property link     “https://www.mql5.com”  #property version   “1.00”  #property description “The indicator demonstrates how to obtain data”  #property description “of indicator buffers for the iRSI technical indicator.”  #property description “A symbol and timeframe used for calculation of the indicator,”  #property description “are set by the symbol and period parameters.”  #property description “The method of creation of the handle is set through the ‘type’ parameter (function type).”  #property description “All the other parameters are similar to the standard Relative Strength Index.” #property indicator_separate_window  #property indicator_buffers 1  #property indicator_plots   1  //— iRSI の描画  #property indicator_label1 “iRSI”  #property indicator_type1   DRAW_LINE  #property indicator_color1  clrDodgerBlue  #property indicator_style1 STYLE_SOLID  #property indicator_width1  1  //— 指標ウィンドウでの値の表示の制限  #property indicator_maximum 100  #property indicator_minimum 0  //— 指標ウィンドウの水平レベル  #property indicator_level1  70.0  #property indicator_level2  30.0  //+——————————————————————+  //| 作成を処理する方法の列挙                                              |  //+——————————————————————+  enum Creation  {  Call_iRSI,             // iRSI を使用する  Call_IndicatorCreate   // IndicatorCreateを使用する  };  //— 入力パラメータ  input Creation             type=Call_iRSI;               // 関数の種類   input int                  ma_period=14;                 // 平均期間  input ENUM_APPLIED_PRICE   applied_price=PRICE_CLOSE;   // 価格の種類  input string               symbol=” “;                   // シンボル   input ENUM_TIMEFRAMES     period=PERIOD_CURRENT;       // 時間軸  //— 指標バッファ  double         iRSIBuffer[];  //— iRSI 指標ハンドルを格納する変数  int    handle;  //— 格納に使用される変数  string name=symbol;  //— チャートでの指標名  string short_name;  //— 相対力指数指標に値の数を保存  int    bars_calculated=0;  //+——————————————————————+  //| カスタム指標を初期化する関数                                            |  //+——————————————————————+  int OnInit()  {  //— 配列の指標バッファへの割り当て  SetIndexBuffer(0,iRSIBuffer,INDICATOR_DATA);  //— 指標が描画するシンボルを決める  name=symbol;  //— 左右のスペースを削する  StringTrimRight(name);  StringTrimLeft(name);  //—「name」文字列の長さがゼロになった場合  if(StringLen(name)==0)  {  //— 指標が接続されているチャートのシンボルを取る  name=_Symbol;  }  //— 指標ハンドルを作成する  if(type==Call_iRSI)  handle=iRSI(name,period,ma_period,applied_price);  else  {  //— 構造体を指標のパラメータで記入       MqlParam pars[2];  //— 移動平均の期間  pars[0].type=TYPE_INT;  pars[0].integer_value=ma_period;  //— 計算に使用するステップ値の制限  pars[1].type=TYPE_INT;  pars[1].integer_value=applied_price;  handle=IndicatorCreate(name,period,IND_RSI,2,pars);  }  //— ハンドルが作成されなかった場合  if(handle==INVALID_HANDLE)  {  //— 失敗した事実とエラーコードを出力する  PrintFormat(“Failed to create handle of the iRSI indicator for the symbol %s/%s, error code %d”,  name,  EnumToString(period),  GetLastError());  //— 指標が早期に中止された  return(INIT_FAILED);  }  //— 相対力指数指標が計算された銘柄/時間軸を表示  short_name=StringFormat(“iRSI(%s/%s, %d, %d)”,name,EnumToString(period),  ma_period,applied_price);  IndicatorSetString(INDICATOR_SHORTNAME,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[])  {  //— iRSI 指標から複製された値の数  int values_to_copy;  //— 指標で計算された値の数を決める  int calculated=BarsCalculated(handle);  if(calculated<=0)  {  PrintFormat(“BarsCalculated() returned %d, error code %d”,calculated,GetLastError());  return(0);  }  //— これが指標計算の初めであるか iRSI 指標の値の数が変更した  //—または、2 つ以上のバーの指標の計算が必要である場合(価格履歴で何かが変更された)  if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1)  {  //— iRSIBuffer 配列が銘柄/期間で iRSI 指標の値の数より大きい場合、全体のコピーはしない  //— 他の場合、指標バッファサイズより少ない量をコピーをする  if(calculated>rates_total) values_to_copy=rates_total;  else                       values_to_copy=calculated;  }  else  {  //— これは初回の計算ではなく、  //— 前回の OnCalculate() から、一以上のバーが加えられてない。  values_to_copy=(rates_total-prev_calculated)+1;  }  //— 配列をiRSI 指標の値で記入  //— FillArrayFromBuffer が false を返した場合、情報の準備が終わっていないので操作を終了する  if(!FillArrayFromBuffer(iRSIBuffer,handle,values_to_copy)) return(0);  //— メッセージを形成する  string comm=StringFormat(“%s ==>  Updated value in the indicator %s: %d”,  TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS),  short_name,  values_to_copy);  //— チャートにサービスメッセージを表示する  Comment(comm);  //— 相対力指数指標の値の数を覚える  bars_calculated=calculated;  //— prev_calculated 値を次の関数呼び出しのために返す  return(rates_total);  }  //+——————————————————————+  //| iRSI 指標から指標バッファを記入する                                       |  //+——————————————————————+  bool FillArrayFromBuffer(double &rsi_buffer[], // 相対力指数値の指標バッファ  int ind_handle,       // iRSI 指標ハンドル  int amount             // 複製された値の数  )  {  //— エラーコードをリセットする  ResetLastError();  //— インデックス0 を持つ指標バッファの値で iRSIBuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,0,0,amount,rsi_buffer)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iRSI indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— 全てが成功  return(true);  }  //+——————————————————————+  //| 指標初期化解除関数                                                  |  //+——————————————————————+  void OnDeinit(const int reason)  {  //— 指標の削除後チャートをクリアする  Comment(“”);  }  | 
iRVI
この関数は Relative Vigor Index(相対活力指数)指標ハンドルを返します。
int  iRVI(  string          symbol,          ENUM_TIMEFRAMES  period,          int              ma_period        );  | 
パラメータ
symbol
[in] データが指標計算に使用される有価証券の銘柄名(NULL は現在のシンボル)
period
[in] 期間の値は ENUM_TIMEFRAMES 列挙の値の 1 つで、0 は現在の時間軸の意味です。
ma_period
[in]  RVI 計算の平均期間
戻り値
注意事項
例:
//+——————————————————————+  //|                                                    Demo_iRVI.mq5 |  //|                        Copyright 2011, MetaQuotes Software Corp. |  //|                                             https://www.MQL5.com |  //+——————————————————————+  #property copyright “Copyright 2011, MetaQuotes Software Corp.”  #property link     “https://www.mql5.com”  #property version   “1.00”  #property description “The indicator demonstrates how to obtain data”  #property description “of indicator buffers for the iRVI technical indicator.”  #property description “A symbol and timeframe used for calculation of the indicator,”  #property description “are set by the symbol and period parameters.”  #property description “The method of creation of the handle is set through the ‘type’ parameter (function type).”  #property description “All the other parameters are similar to the standard Relative Vigor Index.” #property indicator_separate_window  #property indicator_buffers 2  #property indicator_plots   2  //— RVI プロット  #property indicator_label1 “RVI”  #property indicator_type1   DRAW_LINE  #property indicator_color1  clrGreen  #property indicator_style1 STYLE_SOLID  #property indicator_width1  1  //— シグナルプロット  #property indicator_label2 “Signal”  #property indicator_type2   DRAW_LINE  #property indicator_color2  clrRed  #property indicator_style2 STYLE_SOLID  #property indicator_width2  1  //+——————————————————————+  //| 作成を処理する方法の列挙                                              |  //+——————————————————————+  enum Creation  {  Call_iRVI,             // iRVI を使用する  Call_IndicatorCreate   // IndicatorCreateを使用する  };  //— 入力パラメータ  input Creation             type=Call_iRVI;               // 関数の種類   input int                  ma_period=10;                 // 計算期間  input string               symbol=” “;                   // シンボル   input ENUM_TIMEFRAMES     period=PERIOD_CURRENT;       // 時間軸  //— 指標バッファ  double         RVIBuffer[];  double         SignalBuffer[];  //— iRVI 指標ハンドルを格納する変数  int    handle;  //— 格納に使用される変数  string name=symbol;  //— チャートでの指標名  string short_name;  //— 相対活力指数指標に値の数を保存  int    bars_calculated=0;  //+——————————————————————+  //| カスタム指標を初期化する関数                                            |  //+——————————————————————+  int OnInit()  {  //— 配列の指標バッファへの割り当て  SetIndexBuffer(0,RVIBuffer,INDICATOR_DATA);  SetIndexBuffer(1,SignalBuffer,INDICATOR_DATA);  //— 指標が描画するシンボルを決める  name=symbol;  //— 左右のスペースを削する  StringTrimRight(name);  StringTrimLeft(name);  //—「name」文字列の長さがゼロになった場合  if(StringLen(name)==0)  {  //— 指標が接続されているチャートのシンボルを取る  name=_Symbol;  }  //— 指標ハンドルを作成する  if(type==Call_iRVI)  handle=iRVI(name,period,ma_period);  else  {  //— 構造体を指標のパラメータで記入       MqlParam pars[1];  //— 計算期間  pars[0].type=TYPE_INT;  pars[0].integer_value=ma_period;  handle=IndicatorCreate(name,period,IND_RVI,1,pars);  }  //— ハンドルが作成されなかった場合  if(handle==INVALID_HANDLE)  {  //— 失敗した事実とエラーコードを出力する  PrintFormat(“Failed to create handle of the iRVI indicator for the symbol %s/%s, error code %d”,  name,  EnumToString(period),  GetLastError());  //— 指標が早期に中止された  return(INIT_FAILED);  }  //— 相対活力指数指標が計算された銘柄/時間軸を表示  short_name=StringFormat(“iRVI(%s/%s, %d, %d)”,name,EnumToString(period),ma_period);  IndicatorSetString(INDICATOR_SHORTNAME,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[])  {  //— iRVI 指標から複製された値の数  int values_to_copy;  //— 指標で計算された値の数を決める  int calculated=BarsCalculated(handle);  if(calculated<=0)  {  PrintFormat(“BarsCalculated() returned %d, error code %d”,calculated,GetLastError());  return(0);  }  //— これが指標計算の初めであるか iRVI 指標の値の数が変更した  //—または、2 つ以上のバーの指標の計算が必要である場合(価格履歴で何かが変更された)  if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1)  {  //— RVIBuffer 配列が銘柄/期間で iRVI 指標の値の数より大きい場合、全体のコピーはしない  //— 他の場合、指標バッファサイズより少ない量をコピーをする  if(calculated>rates_total) values_to_copy=rates_total;  else                       values_to_copy=calculated;  }  else  {  //— これは初回の計算ではなく、  //— 前回の OnCalculate() から、一以上のバーが加えられてない。  values_to_copy=(rates_total-prev_calculated)+1;  }  //— 配列を iRVI 指標の値で記入  //— FillArrayFromBuffer が false を返した場合、情報の準備が終わっていないので操作を終了する  if(!FillArrayFromBuffer(RVIBuffer,SignalBuffer,handle,values_to_copy)) return(0);  //— メッセージを形成する  string comm=StringFormat(“%s ==>  Updated value in the indicator %s: %d”,  TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS),  short_name,  values_to_copy);  //— チャートにサービスメッセージを表示する  Comment(comm);  //— 相対活力指数指標の値の数を覚える  bars_calculated=calculated;  //— prev_calculated 値を次の関数呼び出しのために返す  return(rates_total);  }  //+——————————————————————+  //| iRVI 指標から指標バッファを記入する                                       |  //+——————————————————————+  bool FillArrayFromBuffer(double &rvi_buffer[],     // 相対活力指数値の指標バッファ  double &signal_buffer[], // シグナル線の指標バッファ  int ind_handle,           // iRVI 指標ハンドルr  int amount               // 複製された値の数  )  {  //— エラーコードをリセットする  ResetLastError();  //— インデックス0 を持つ指標バッファの値で iRVIBuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,0,0,amount,rvi_buffer)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iRVI indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— インデックス 1 を持つ指標バッファの値で SignalBuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,1,0,amount,signal_buffer)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iRVI indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— 全てが成功  return(true);  }  //+——————————————————————+  //| 指標初期化解除関数                                                  |  //+——————————————————————+  void OnDeinit(const int reason)  {  //— 指標の削除後チャートをクリアする  Comment(“”);  }  | 
iStdDev
この関数は Standard Deviation(標準偏差)指標のハンドルを返します。バッファは 1 つです。
int  iStdDev(  string              symbol,              ENUM_TIMEFRAMES    period,              int                ma_period,          int                ma_shift,            ENUM_MA_METHOD      ma_method,          ENUM_APPLIED_PRICE  applied_price        );  | 
パラメータ
symbol
[in] データが指標計算に使用される有価証券の銘柄名(NULL は現在のシンボル)
period
[in] 期間の値は ENUM_TIMEFRAMES 列挙の値の 1 つで、0 は現在の時間軸の意味です。
ma_period
[in]  指標計算の平均期間
ma_shift
[in]  価格チャートに相対した指標のシフト
ma_method
[in]  平均化の方法ENUM_MA_METHOD 値のいずれか
applied_price
[in]  使用される価格。ENUM_APPLIED_PRICE 価格定数のいずれか、または別の指標ハンドル。
戻り値
例:
//+——————————————————————+  //|                                                 Demo_iStdDev.mq5 |  //|                        Copyright 2011, MetaQuotes Software Corp. |  //|                                             https://www.MQL5.com |  //+——————————————————————+  #property copyright “Copyright 2011, MetaQuotes Software Corp.”  #property link     “https://www.mql5.com”  #property version   “1.00”  #property description “The indicator demonstrates how to obtain data”  #property description “of indicator buffers for the iStdDev technical indicator.”  #property description “A symbol and timeframe used for calculation of the indicator,”  #property description “are set by the symbol and period parameters.”  #property description “The method of creation of the handle is set through the ‘type’ parameter (function type).”  #property description “All the other parameters are similar to the normal Standard Deviation.” #property indicator_separate_window  #property indicator_buffers 1  #property indicator_plots   1  //— iStdDev プロット  #property indicator_label1 “iStdDev”  #property indicator_type1   DRAW_LINE  #property indicator_color1  clrMediumSeaGreen  #property indicator_style1 STYLE_SOLID  #property indicator_width1  1  //+——————————————————————+  //| 作成を処理する方法の列挙                                              |  //+——————————————————————+  enum Creation  {  Call_iStdDev,           // iStdDev を使用  Call_IndicatorCreate   // IndicatorCreateを使用する  };  //— 入力パラメータ  input Creation             type=Call_iStdDev;         // 関数の種類   input int                  ma_period=20;             // 平均期間  input int                  ma_shift=0;               // シフト  input ENUM_MA_METHOD       ma_method=MODE_SMA;       // 平滑化の種類  input ENUM_APPLIED_PRICE   applied_price=PRICE_CLOSE; // 価格の種類  input string               symbol=” “;               // シンボル   input ENUM_TIMEFRAMES     period=PERIOD_CURRENT;     // 時間軸  //— 指標バッファ  double         iStdDevBuffer[];  //— iStdDev 指標ハンドルを格納する変数  int    handle;  //— 格納に使用される変数  string name=symbol;  //— チャートでの指標名  string short_name;  //— 標準偏差指標に値の数を保存  int    bars_calculated=0;  //+——————————————————————+  //| カスタム指標を初期化する関数                                            |  //+——————————————————————+  int OnInit()  {  //— 配列の指標バッファへの割り当て  SetIndexBuffer(0,iStdDevBuffer,INDICATOR_DATA);  //— シフトを設定  PlotIndexSetInteger(0,PLOT_SHIFT,ma_shift);  //— 指標が描画するシンボルを決める  name=symbol;  //— 左右のスペースを削する  StringTrimRight(name);  StringTrimLeft(name);  //—「name」文字列の長さがゼロになった場合  if(StringLen(name)==0)  {  //— 指標が接続されているチャートのシンボルを取る  name=_Symbol;  }  //— 指標ハンドルを作成する  if(type==Call_iStdDev)  handle=iStdDev(name,period,ma_period,ma_shift,ma_method,applied_price);  else  {  //— 構造体を指標のパラメータで記入       MqlParam pars[4];  //— 期間  pars[0].type=TYPE_INT;  pars[0].integer_value=ma_period;  //— シフト  pars[1].type=TYPE_INT;  pars[1].integer_value=ma_shift;  //— 平滑化の種類  pars[2].type=TYPE_INT;  pars[2].integer_value=ma_method;  //— 価格の種類  pars[3].type=TYPE_INT;  pars[3].integer_value=applied_price;  handle=IndicatorCreate(name,period,IND_STDDEV,4,pars);  }  //— ハンドルが作成されなかった場合  if(handle==INVALID_HANDLE)  {  //— 失敗した事実とエラーコードを出力する  PrintFormat(“Failed to create handle of the iStdDev indicator for the symbol %s/%s, error code %d”,  name,  EnumToString(period),  GetLastError());  //— 指標が早期に中止された  return(INIT_FAILED);  }  //— 標準偏差指標が計算された銘柄/時間軸を表示  short_name=StringFormat(“iStdDev(%s/%s, %d, %d, %s, %s)”,name,EnumToString(period),  ma_period,ma_shift,EnumToString(ma_method),EnumToString(applied_price));  IndicatorSetString(INDICATOR_SHORTNAME,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[])  {  //— iStdDev 指標から複製された値の数  int values_to_copy;  //— 指標で計算された値の数を決める  int calculated=BarsCalculated(handle);  if(calculated<=0)  {  PrintFormat(“BarsCalculated() returned %d, error code %d”,calculated,GetLastError());  return(0);  }  //— これが指標計算の初めであるか iStdDev 指標の値の数が変更した  //—または、2 つ以上のバーの指標の計算が必要である場合(価格履歴で何かが変更された)  if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1)  {  //— iStdDevBuffer 配列が銘柄/期間で iStdDev 指標の値の数より大きい場合、全体のコピーはしない   //— 他の場合、指標バッファサイズより少ない量をコピーをする  if(calculated>rates_total) values_to_copy=rates_total;  else                       values_to_copy=calculated;  }  else  {  //— これは初回の計算ではなく、  //— 前回の OnCalculate() から、一以上のバーが加えられてない。  values_to_copy=(rates_total-prev_calculated)+1;  }  //— 配列を標準偏差指標の値で記入  //— FillArrayFromBuffer が false を返した場合、情報の準備が終わっていないので操作を終了する  if(!FillArrayFromBuffer(iStdDevBuffer,ma_shift,handle,values_to_copy)) return(0);  //— メッセージを形成する  string comm=StringFormat(“%s ==>  Updated value in the indicator %s: %d”,  TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS),  short_name,  values_to_copy);  //— チャートにサービスメッセージを表示する  Comment(comm);  //— 標準偏差指標の値の数を覚える  bars_calculated=calculated;  //— prev_calculated 値を次の関数呼び出しのために返す  return(rates_total);  }  //+——————————————————————+  //| iStdDev 指標から指標バッファを記入する                                    |  //+——————————————————————+  bool FillArrayFromBuffer(double &std_buffer[], // 標準偏差線の指標バッファ  int std_shift,         // 標準偏差線のシフト  int ind_handle,       // iStdDev 指標ハンドル  int amount             // 複製された値の数  )  {  //— エラーコードをリセットする  ResetLastError();  //— インデックス0 を持つ指標バッファの値で iStdDevBuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,0,-std_shift,amount,std_buffer)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iStdDev indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— 全てが成功  return(true);  }  //+——————————————————————+  //| 指標初期化解除関数                                                  |  //+——————————————————————+  void OnDeinit(const int reason)  {  //— 指標の削除後チャートをクリアする  Comment(“”);  }  | 
iStochastic
この関数は Stochastic Oscillator(ストキャスティックス)指標のハンドルを返します。
int  iStochastic(  string          symbol,            ENUM_TIMEFRAMES  period,            int              Kperiod,          int              Dperiod,          int              slowing,          ENUM_MA_METHOD  ma_method,        ENUM_STO_PRICE  price_field        );  | 
パラメータ
symbol
[in] データが指標計算に使用される有価証券の銘柄名(NULL は現在のシンボル)
period
[in] 期間の値は ENUM_TIMEFRAMES 列挙の値の 1 つで、0 は現在の時間軸の意味です。
Kperiod
[in]  %K 線計算の平均期間(バーの数)
Dperiod
[in]  %D 線計算の平均期間(バーの数)
slowing
[in]  スロー値
ma_method
[in]  平均化の方法ENUM_MA_METHOD 値のいずれか
price_field
[in]  計算に使用される価格選択のパラメータENUM_STO_PRICE 値のいずれか
戻り値
注意事項
例:
//+——————————————————————+  //|                                             Demo_iStochastic.mq5 |  //|                        Copyright 2011, MetaQuotes Software Corp. |  //|                                             https://www.MQL5.com |  //+——————————————————————+  #property copyright “Copyright 2011, MetaQuotes Software Corp.”  #property link     “https://www.mql5.com”  #property version   “1.00”  #property description “The indicator demonstrates how to obtain data”  #property description “of indicator buffers for the iStochastic technical indicator.”  #property description “A symbol and timeframe used for calculation of the indicator,”  #property description “are set by the symbol and period parameters.”  #property description “The method of creation of the handle is set through the ‘type’ parameter (function type).”  #property description “All the other parameters are similar to the standard Stochastic Oscillator.” #property indicator_separate_window  #property indicator_buffers 2  #property indicator_plots   2  //— ストキャスティックスプロット  #property indicator_label1 “Stochastic”  #property indicator_type1   DRAW_LINE  #property indicator_color1  clrLightSeaGreen  #property indicator_style1 STYLE_SOLID  #property indicator_width1  1  //— シグナルプロット  #property indicator_label2 “Signal”  #property indicator_type2   DRAW_LINE  #property indicator_color2  clrRed  #property indicator_style2 STYLE_SOLID  #property indicator_width2  1  //— 指標値を制限する  #property indicator_minimum 0  #property indicator_maximum 100  //— 指標ウィンドウの水平レベル  #property indicator_level1  -100.0  #property indicator_level2  100.0  //+——————————————————————+  //| 作成を処理する方法の列挙                                              |  //+——————————————————————+  enum Creation  {  Call_iStochastic,       // use iStochastic を使用する  Call_IndicatorCreate   // IndicatorCreateを使用する  };  //— 入力パラメータ  input Creation             type=Call_iStochastic;     // 関数の種類   input int                  Kperiod=5;                 // K 期間(計算に使用されるバーの数)  input int                  Dperiod=3;                 // D 期間(主要な平滑化の期間)  input int                  slowing=3;                 // 最終平滑化期間   input ENUM_MA_METHOD       ma_method=MODE_SMA;       // 平滑化の種類     input ENUM_STO_PRICE       price_field=STO_LOWHIGH;   // 確率の計算方法  input string               symbol=” “;               // シンボル   input ENUM_TIMEFRAMES     period=PERIOD_CURRENT;     // 時間軸  //— 指標バッファ  double         StochasticBuffer[];  double         SignalBuffer[];  //— iStochastic 指標ハンドルを格納する変数  int    handle;  //— 格納に使用される変数  string name=symbol;  //— チャートでの指標名  string short_name;  //— ストキャスティックスー指標に値の数を保存  int    bars_calculated=0;  //+——————————————————————+  //| カスタム指標を初期化する関数                                            |  //+——————————————————————+  int OnInit()  {  //— 配列の指標バッファへの割り当て  SetIndexBuffer(0,StochasticBuffer,INDICATOR_DATA);  SetIndexBuffer(1,SignalBuffer,INDICATOR_DATA);  //— 指標が描画するシンボルを決める  name=symbol;  //— 左右のスペースを削する  StringTrimRight(name);  StringTrimLeft(name);  //—「name」文字列の長さがゼロになった場合  if(StringLen(name)==0)  {  //— 指標が接続されているチャートのシンボルを取る  name=_Symbol;  }  //— 指標ハンドルを作成する  if(type==Call_iStochastic)  handle=iStochastic(name,period,Kperiod,Dperiod,slowing,ma_method,price_field);  else  {  //— 構造体を指標のパラメータで記入       MqlParam pars[5];  //— 計算の K 期間  pars[0].type=TYPE_INT;  pars[0].integer_value=Kperiod;  //— 主要な平滑化の D 期間  pars[1].type=TYPE_INT;  pars[1].integer_value=Dperiod;  //— 最後の平滑化の K 期間  pars[2].type=TYPE_INT;  pars[2].integer_value=slowing;  //— 平滑化の種類  pars[3].type=TYPE_INT;  pars[3].integer_value=ma_method;  //— 確率の計算方法  pars[4].type=TYPE_INT;  pars[4].integer_value=price_field;  handle=IndicatorCreate(name,period,IND_STOCHASTIC,5,pars);  }  //— ハンドルが作成されなかった場合  if(handle==INVALID_HANDLE)  {  //— 失敗した事実とエラーコードを出力する  PrintFormat(“Failed to create handle of the iStochastic indicator for the symbol %s/%s, error code %d”,  name,  EnumToString(period),  GetLastError());  //— 指標が早期に中止された  return(INIT_FAILED);  }  //— ストキャスティックスーが計算された銘柄/時間軸を表示  short_name=StringFormat(“iStochastic(%s/%s, %d, %d, %d, %s, %s)”,name,EnumToString(period),  Kperiod,Dperiod,slowing,EnumToString(ma_method),EnumToString(price_field));  IndicatorSetString(INDICATOR_SHORTNAME,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[])  {  //— iStochastic 指標から複製された値の数  int values_to_copy;  //— 指標で計算された値の数を決める  int calculated=BarsCalculated(handle);  if(calculated<=0)  {  PrintFormat(“BarsCalculated() returned %d, error code %d”,calculated,GetLastError());  return(0);  }  //— これが指標計算の初めであるか iStochastic 指標の値の数が変更した  //—または、2 つ以上のバーの指標の計算が必要である場合(価格履歴で何かが変更された)  if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1)  {  //— StochasticBuffer 配列が銘柄/期間で iStochastic 指標の値の数より大きい場合、全体のコピーはしない   //— 他の場合、指標バッファサイズより少ない量をコピーをする  if(calculated>rates_total) values_to_copy=rates_total;  else                       values_to_copy=calculated;  }  else  {  //— これは初回の計算ではなく、  //— 前回の OnCalculate() から、一以上のバーが加えられてない。  values_to_copy=(rates_total-prev_calculated)+1;  }  //— f配列を iStochastic 指標の値で記入  //— FillArraysFromBuffer が false を返した場合、情報の準備が終わっていないので操作を終了する  if(!FillArraysFromBuffers(StochasticBuffer,SignalBuffer,handle,values_to_copy)) return(0);  //— メッセージを形成する  string comm=StringFormat(“%s ==>  Updated value in the indicator %s: %d”,  TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS),  short_name,  values_to_copy);  //— チャートにサービスメッセージを表示する  Comment(comm);  //— ストキャスティックスー指標の値の数を覚える  bars_calculated=calculated;  //— prev_calculated 値を次の関数呼び出しのために返す  return(rates_total);  }  //+——————————————————————+  //| iStochastic 指標から指標バッファを記入する                               |  //+——————————————————————+  bool FillArraysFromBuffers(double &main_buffer[],   // ストキャスティックスー値の指標バッファ  double &signal_buffer[], // シグナル線の指標バッファ  int ind_handle,           // iStochastic 指標ハンドル  int amount               // 複製された値の数  )  {  //— エラーコードをリセットする  ResetLastError();  //— インデックス0 を持つ指標バッファの値で StochasticBuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,MAIN_LINE,0,amount,main_buffer)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iStochastic indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— インデックス 1 を持つ指標バッファの値で SignalBuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,SIGNAL_LINE,0,amount,signal_buffer)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iStochastic indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— 全てが成功  return(true);  }  //+——————————————————————+  //| 指標初期化解除関数                                                  |  //+——————————————————————+  void OnDeinit(const int reason)  {  //— 指標の削除後チャートをクリアする  Comment(“”);  }  | 
iTEMA
この関数は Triple Exponential Moving Average 指標ハンドルを返します。バッファは 1 つです。
int  iTEMA(  string              symbol,              ENUM_TIMEFRAMES    period,              int                ma_period,          int                ma_shift,            ENUM_APPLIED_PRICE  applied_price        );  | 
パラメータ
symbol
[in] データが指標計算に使用される有価証券の銘柄名(NULL は現在のシンボル)
period
[in] 期間の値は ENUM_TIMEFRAMES 列挙の値の 1 つで、0 は現在の時間軸の意味です。
ma_period
[in]  計算の平均期間(バーの数)
ma_shift
[in]  価格チャートに相対した指標のシフト
applied_price
[in]  使用される価格。ENUM_APPLIED_PRICE 価格定数のいずれか、または別の指標ハンドル。
戻り値
例:
//+——————————————————————+  //|                                                   Demo_iTEMA.mq5 |  //|                        Copyright 2011, MetaQuotes Software Corp. |  //|                                             https://www.MQL5.com |  //+——————————————————————+  #property copyright “Copyright 2011, MetaQuotes Software Corp.”  #property link     “https://www.mql5.com”  #property version   “1.00”  #property description “The indicator demonstrates how to obtain data”  #property description “of indicator buffers for the iTEMA technical indicator.”  #property description “A symbol and timeframe used for calculation of the indicator,”  #property description “are set by the symbol and period parameters.”  #property description “The method of creation of the handle is set through the ‘type’ parameter (function type).”  #property description “All the other parameters are similar to the standard Triple Exponential Moving Average.” #property indicator_chart_window  #property indicator_buffers 1  #property indicator_plots   1  //— iTEMA プロット  #property indicator_label1 “iTEMA”  #property indicator_type1   DRAW_LINE  #property indicator_color1  clrRed  #property indicator_style1 STYLE_SOLID  #property indicator_width1  1  //+——————————————————————+  //| 作成を処理する方法の列挙                                              |  //+——————————————————————+  enum Creation  {  Call_iTEMA,             // iTEMA を使用する  Call_IndicatorCreate   // IndicatorCreateを使用する  };  //— 入力パラメータ  input Creation             type=Call_iTEMA;           // 関数の種類   input int                  ma_period=14;             // 平均期間  input int                  ma_shift=0;               // シフト  input ENUM_APPLIED_PRICE   applied_price=PRICE_CLOSE; // 価格の種類  input string               symbol=” “;               // シンボル   input ENUM_TIMEFRAMES     period=PERIOD_CURRENT;     // 時間軸  //— 指標バッファ  double         iTEMABuffer[];  //— iTEMA 指標ハンドルを格納する変数  int    handle;  //— 格納に使用される変数  string name=symbol;  //— チャートでの指標名  string short_name;  //— Triple Exponential Moving Average 指標に値の数を保存  int    bars_calculated=0;  //+——————————————————————+  //| カスタム指標を初期化する関数                                            |  //+——————————————————————+  int OnInit()  {  //— 配列の指標バッファへの割り当て  SetIndexBuffer(0,iTEMABuffer,INDICATOR_DATA);  //— シフトを設定  PlotIndexSetInteger(0,PLOT_SHIFT,ma_shift);  //— 指標が描画するシンボルを決める  name=symbol;  //— 左右のスペースを削する  StringTrimRight(name);  StringTrimLeft(name);  //—「name」文字列の長さがゼロになった場合  if(StringLen(name)==0)  {  //— 指標が接続されているチャートのシンボルを取る  name=_Symbol;  }  //— 指標ハンドルを作成する  if(type==Call_iTEMA)  handle=iTEMA(name,period,ma_period,ma_shift,applied_price);  else  {  //— 構造体を指標のパラメータで記入       MqlParam pars[3];  //— 期間  pars[0].type=TYPE_INT;  pars[0].integer_value=ma_period;  //— シフト  pars[1].type=TYPE_INT;  pars[1].integer_value=ma_shift;  //— 価格の種類  pars[2].type=TYPE_INT;  pars[2].integer_value=applied_price;  handle=IndicatorCreate(name,period,IND_TEMA,3,pars);  }  //— ハンドルが作成されなかった場合  if(handle==INVALID_HANDLE)  {  //— 失敗した事実とエラーコードを出力する  PrintFormat(“Failed to create handle of the iTEMA indicator for the symbol %s/%s, error code %d”,  name,  EnumToString(period),  GetLastError());  //— 指標が早期に中止された  return(INIT_FAILED);  }  //— Triple Exponential Moving Average 指標が計算された銘柄/時間軸を表示  short_name=StringFormat(“iTEMA(%s/%s, %d, %d, %s)”,name,EnumToString(period),  ma_period,ma_shift,EnumToString(applied_price));  IndicatorSetString(INDICATOR_SHORTNAME,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[])  {  //— iTEMA 指標から複製された値の数r  int values_to_copy;  //— 指標で計算された値の数を決める  int calculated=BarsCalculated(handle);  if(calculated<=0)  {  PrintFormat(“BarsCalculated() returned %d, error code %d”,calculated,GetLastError());  return(0);  }  //— これが指標計算の初めであるか iTEMA 指標の値の数が変更した  //—または、2 つ以上のバーの指標の計算が必要である場合(価格履歴で何かが変更された)  if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1)  {  //— iTEMABuffer 配列が銘柄/期間で iTEMA 指標の値の数より大きい場合、全体のコピーはしない   //— 他の場合、指標バッファサイズより少ない量をコピーをする  if(calculated>rates_total) values_to_copy=rates_total;  else                       values_to_copy=calculated;  }  else  {  //— これは初回の計算ではなく、  //— 前回の OnCalculate() から、一以上のバーが加えられてない。  values_to_copy=(rates_total-prev_calculated)+1;  }  //— 配列をTriple Exponential Moving Average 指標の値で記入  //— FillArrayFromBuffer が false を返した場合、情報の準備が終わっていないので操作を終了する  if(!FillArrayFromBuffer(iTEMABuffer,ma_shift,handle,values_to_copy)) return(0);  //— メッセージを形成する  string comm=StringFormat(“%s ==>  Updated value in the indicator %s: %d”,  TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS),  short_name,  values_to_copy);  //— チャートにサービスメッセージを表示する  Comment(comm);  //— Triple Exponential Moving Average 指標の値の数を覚える  bars_calculated=calculated;  //— prev_calculated 値を次の関数呼び出しのために返す  return(rates_total);  }  //+——————————————————————+  //| iTEMA 指標から指標バッファを記入する                                      |  //+——————————————————————+  bool FillArrayFromBuffer(double &tema_buffer[], // Triple Exponential Moving Average 値の指標バッファ  int t_shift,           // 線のシフト  int ind_handle,       // iTEMA 指標ハンドル  int amount             // 複製された値の数  &nbnbsp;                     )  {  //— エラーコードをリセットする  ResetLastError();  //— インデックス0 を持つ指標バッファの値で iTEMABuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,0,-t_shift,amount,tema_buffer)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iTEMA indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— 全てが成功  return(true);  }  //+——————————————————————+  //| 指標初期化解除関数                                                  |  //+——————————————————————+  void OnDeinit(const int reason)  {  //— 指標の削除後チャートをクリアする  Comment(“”);  }  | 
iTriX
この関数はTriple Exponential Moving Averages Oscillator 指標ハンドルを返します。バッファは 1 つです。
int  iTriX(  string              symbol,              ENUM_TIMEFRAMES    period,              int                ma_period,          ENUM_APPLIED_PRICE  applied_price        );  | 
パラメータ
symbol
[in] データが指標計算に使用される有価証券の銘柄名(NULL は現在のシンボル)
period
[in] 期間の値は ENUM_TIMEFRAMES 列挙の値の 1 つで、0 は現在の時間軸の意味です。
ma_period
[in]  計算の平均期間(バーの数)
applied_price
[in]  使用される価格。ENUM_APPLIED_PRICE 価格定数のいずれか、または別の指標ハンドル。
戻り値
例:
//+——————————————————————+  //|                                                   Demo_iTriX.mq5 |  //|                        Copyright 2011, MetaQuotes Software Corp. |  //|                                             https://www.MQL5.com |  //+——————————————————————+  #property copyright “Copyright 2011, MetaQuotes Software Corp.”  #property link     “https://www.mql5.com”  #property version   “1.00”  #property description “The indicator demonstrates how to obtain data”  #property description “of indicator buffers for the iTriX technical indicator.”  #property description “A symbol and timeframe used for calculation of the indicator,”  #property description “are set by the symbol and period parameters.”  #property description “The method of creation of the handle is set through the ‘type’ parameter (function type).” #property indicator_separate_window  #property indicator_buffers 1  #property indicator_plots   1  //— iTriX プロット  #property indicator_label1 “iTriX”  #property indicator_type1   DRAW_LINE  #property indicator_color1  clrRed  #property indicator_style1 STYLE_SOLID  #property indicator_width1  1  //+——————————————————————+  //| 作成を処理する方法の列挙                                              |  //+——————————————————————+  enum Creation  {  Call_iTriX,             // iTriX を使用する  Call_IndicatorCreate   // IndicatorCreateを使用する  };  //— 入力パラメータ  input Creation             type=Call_iTriX;           // 関数の種類   input int                  ma_period=14;             // 期間  input ENUM_APPLIED_PRICE   applied_price=PRICE_CLOSE; // 価格の種類  input string               symbol=” “;               // シンボル   input ENUM_TIMEFRAMES     period=PERIOD_CURRENT;     // 時間軸  //— 指標バッファ  double         iTriXBuffer[];  //— iTriX 指標ハンドルを格納する変数  int    handle;  //— 格納に使用される変数  string name=symbol;  //— チャートでの指標名  string short_name;  //— Triple Exponential Moving Averages Oscillator 指標に値の数を保存  int    bars_calculated=0;  //+——————————————————————+  //| カスタム指標を初期化する関数                                            |  //+——————————————————————+  int OnInit()  {  //— 配列の指標バッファへの割り当て  SetIndexBuffer(0,iTriXBuffer,INDICATOR_DATA);  //— 指標が描画するシンボルを決める  name=symbol;  //— 左右のスペースを削する  StringTrimRight(name);  StringTrimLeft(name);  //—「name」文字列の長さがゼロになった場合  if(StringLen(name)==0)  {  //— 指標が接続されているチャートのシンボルを取る  name=_Symbol;  }  //— 指標ハンドルを作成する  if(type==Call_iTriX)  handle=iTriX(name,period,ma_period,applied_price);  else  {  //— 構造体を指標のパラメータで記入       MqlParam pars[2];  //— 期間  pars[0].type=TYPE_INT;  pars[0].integer_value=ma_period;  //— 価格の種類  pars[1].type=TYPE_INT;  pars[1].integer_value=applied_price;  handle=IndicatorCreate(name,period,IND_TRIX,2,pars);  }  //— ハンドルが作成されなかった場合  if(handle==INVALID_HANDLE)  {  //— 失敗した事実とエラーコードを出力する  PrintFormat(“Failed to create handle of the iTriX indicator for the symbol %s/%s, error code %d”,  name,  EnumToString(period),  GetLastError());  //— 指標が早期に中止された  return(INIT_FAILED);  }  //— Triple Exponential Moving Averages Oscillator 指標が計算された銘柄/時間軸を表示  short_name=StringFormat(“iTriX(%s/%s, %d, %s)”,name,EnumToString(period),  ma_period,EnumToString(applied_price));  IndicatorSetString(INDICATOR_SHORTNAME,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[])  {  //— iTriX 指標から複製された値の数  int values_to_copy;  //— 指標で計算された値の数を決める  int calculated=BarsCalculated(handle);  if(calculated<=0)  {  PrintFormat(“BarsCalculated() returned %d, error code %d”,calculated,GetLastError());  return(0);  }  //— これが指標計算の初めであるか iTriX 指標の値の数が変更した  //—または、2 つ以上のバーの指標の計算が必要である場合(価格履歴で何かが変更された)  if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1)  {  //— iTriXBuffer 配列が銘柄/期間でiTriX 指標の値の数より大きい場合、全体のコピーはしない   //— 他の場合、指標バッファサイズより少ない量をコピーをする  if(calculated>rates_total) values_to_copy=rates_total;  else                       values_to_copy=calculated;  }  else  {  //— これは初回の計算ではなく、  //— 前回の OnCalculate() から、一以上のバーが加えられてない。  values_to_copy=(rates_total-prev_calculated)+1;  }  //— Triple Exponential Moving Averages Oscillator 指標の値で記入  //— FillArrayFromBuffer が false を返した場合、情報の準備が終わっていないので操作を終了する  if(!FillArrayFromBuffer(iTriXBuffer,handle,values_to_copy)) return(0);  //— メッセージを形成する  string comm=StringFormat(“%s ==>  Updated value in the indicator %s: %d”,  TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS),  short_name,  values_to_copy);  //— チャートにサービスメッセージを表示する  Comment(comm);  //— Triple Exponential Moving Averages Oscillator 指標の値の数を覚える  bars_calculated=calculated;  //— prev_calculated 値を次の関数呼び出しのために返す  return(rates_total);  }  //+——————————————————————+  //| iTriX 指標から指標バッファを記入する                                      |  //+——————————————————————+  bool FillArrayFromBuffer(double &trix_buffer[], // Triple Exponential Moving Averages Oscillator 値の指標バッファ  int ind_handle,       // iTriX 指標ハンドル  int amount             // 複製された値の数  )  {  //— エラーコードをリセットする  ResetLastError();  //— インデックス0 を持つ指標バッファの値で iTriXBuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,0,0,amount,trix_buffer)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iTriX indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— 全てが成功  return(true);  }  //+——————————————————————+  //| 指標初期化解除関数                                                  |  //+——————————————————————+  void OnDeinit(const int reason)  {  //— 指標の削除後チャートをクリアする  Comment(“”);  }  | 
iWPR
この関数は Larry Williams’ Percent Range(ラリーウィリアムパーセントレンジ)指標のハンドルを返します。バッファは 1 つです。
int  iWPR(  string          symbol,            ENUM_TIMEFRAMES  period,            int              calc_period        );  | 
パラメータ
symbol
[in] データが指標計算に使用される有価証券の銘柄名(NULL は現在のシンボル)
period
[in] 期間の値は ENUM_TIMEFRAMES 列挙の値の 1 つで、0 は現在の時間軸の意味です。
calc_period
[in]  指標計算の平均期間(バーの数)
戻り値
例:
//+——————————————————————+  //|                                                    Demo_iWPR.mq5 |  //|                        Copyright 2011, MetaQuotes Software Corp. |  //|                                             https://www.MQL5.com |  //+——————————————————————+  #property copyright “Copyright 2011, MetaQuotes Software Corp.”  #property link     “https://www.mql5.com”  #property version   “1.00”  #property description “The indicator demonstrates how to obtain data”  #property description “of indicator buffers for the iWPR technical indicator.”  #property description “A symbol and timeframe used for calculation of the indicator,”  #property description “are set by the symbol and period parameters.”  #property description “The method of creation of the handle is set through the ‘type’ parameter (function type).” #property indicator_separate_window  #property indicator_buffers 1  #property indicator_plots   1  //— iWPR プロット  #property indicator_label1 “iWPR”  #property indicator_type1   DRAW_LINE  #property indicator_color1  clrCyan  #property indicator_style1 STYLE_SOLID  #property indicator_width1  1  //— 指標値を制限する  #property indicator_minimum -100  #property indicator_maximum 0  //— 指標ウィンドウの水平レベル  #property indicator_level1  -20.0  #property indicator_level2  -80.0  //+——————————————————————+  //| 作成を処理する方法の列挙                                              |  //+——————————————————————+  enum Creation  {  Call_iWPR,             // iWPRを使用する  Call_IndicatorCreate   // IndicatorCreateを使用する  };  //— 入力パラメータ  input Creation             type=Call_iWPR;           // 関数の種類  input int                  calc_period=14;           // 期間  input string               symbol=” “;               // シンボル   input ENUM_TIMEFRAMES     period=PERIOD_CURRENT;     // 時間軸  //— 指標バッファ  double         iWPRBuffer[];  //— iWPR 指標ハンドルを格納する変数  int    handle;  //— 格納に使用される変数  string name=symbol;  //— チャートでの指標名  string short_name;  //— ラリーウィリアムパーセントレンジ 指標に値の数を保存  int    bars_calculated=0;  //+——————————————————————+  //| カスタム指標を初期化する関数                                            |  //+——————————————————————+  int OnInit()  {  //— 配列の指標バッファへの割り当て  SetIndexBuffer(0,iWPRBuffer,INDICATOR_DATA);  //— 指標が描画するシンボルを決める  name=symbol;  //— 左右のスペースを削する  StringTrimRight(name);  StringTrimLeft(name);  //—「name」文字列の長さがゼロになった場合  if(StringLen(name)==0)  {  //— 指標が接続されているチャートのシンボルを取る  name=_Symbol;  }  //— 指標ハンドルを作成する  if(type==Call_iWPR)  handle=iWPR(name,period,calc_period);  else  {  //— 構造体を指標のパラメータで記入       MqlParam pars[1];  //— 期間  pars[0].type=TYPE_INT;  pars[0].integer_value=calc_period;  handle=IndicatorCreate(name,period,IND_WPR,1,pars);  }  //— ハンドルが作成されなかった場合  if(handle==INVALID_HANDLE)  {  //— 失敗した事実とエラーコードを出力する  PrintFormat(“Failed to create handle of the iWPR indicator for the symbol %s/%s, error code %d”,  name,  EnumToString(period),  GetLastError());  //— 指標が早期に中止された  return(INIT_FAILED);  }  //— ウィリアムパーセントレンジ 指標が計算された銘柄/時間軸を表示  short_name=StringFormat(“iWPR(%s/%s, %d)”,name,EnumToString(period),calc_period);  IndicatorSetString(INDICATOR_SHORTNAME,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[])  {  //— iWPR 指標から複製された値の数  int values_to_copy;  //— 指標で計算された値の数を決める  int calculated=BarsCalculated(handle);  if(calculated<=0)  {  PrintFormat(“BarsCalculated() returned %d, error code %d”,calculated,GetLastError());  return(0);  }  //— これが指標計算の初めであるか iWPR 指標の値の数が変更した  //—または、2 つ以上のバーの指標の計算が必要である場合(価格履歴で何かが変更された)  if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1)  {  //— iiWPRBuffer 配列が銘柄/期間で iWPR 指標の値の数より大きい場合、全体のコピーはしない   //— 他の場合、指標バッファサイズより少ない量をコピーをする  if(calculated>rates_total) values_to_copy=rates_total;  else                       values_to_copy=calculated;  }  else  {  //— これは初回の計算ではなく、  //— 前回の OnCalculate() から、一以上のバーが加えられてない。  values_to_copy=(rates_total-prev_calculated)+1;  }  //—配列をウィリアムパーセントレンジ 指標の値で記入  //— FillArrayFromBuffer が false を返した場合、情報の準備が終わっていないので操作を終了する  if(!FillArrayFromBuffer(iWPRBuffer,handle,values_to_copy)) return(0);  //— メッセージを形成する  string comm=StringFormat(“%s ==>  Updated value in the indicator %s: %d”,  TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS),  short_name,  values_to_copy);  //— チャートにサービスメッセージを表示する  Comment(comm);  //— ラリーウィリアムパーセントレンジ 指標の値の数を覚える  bars_calculated=calculated;  //— prev_calculated 値を次の関数呼び出しのために返す  return(rates_total);  }  //+——————————————————————+  //| iWPR 指標から指標バッファを記入する                                       |  //+——————————————————————+  bool FillArrayFromBuffer(double &wpr_buffer[], // ウィリアムパーセントレンジ 値の指標バッファ  int ind_handle,       // iWPR 指標ハンドルr  int amount             // 複製された値の数  )  {  //— エラーコードをリセットする  ResetLastError();  //— インデックス0 を持つ指標バッファの値で iWPRBuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,0,0,amount,wpr_buffer)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iWPR indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— 全てが成功  return(true);  }  //+——————————————————————+  //| 指標初期化解除関数                                                  |  //+——————————————————————+  void OnDeinit(const int reason)  {  //— 指標の削除後チャートをクリアする  Comment(“”);  }  | 
iVIDyA
この関数は Variable Index Dynamic Average 指標ハンドルを返します。バッファは 1 つです。
int  iVIDyA(  string              symbol,              ENUM_TIMEFRAMES    period,              int                cmo_period,          int                ema_period,          int                ma_shift,            ENUM_APPLIED_PRICE  applied_price        );  | 
パラメータ
symbol
[in] データが指標計算に使用される有価証券の銘柄名(NULL は現在のシンボル)
period
[in] 期間の値は ENUM_TIMEFRAMES 列挙の値の 1 つで、0 は現在の時間軸の意味です。
cmo_period
[in]  Chande モメンタムオシレーター計算の期間(バーの数)
ema_period
[in]  平滑化係数計算の EMA 期間(バーの数)
ma_shift
[in]  価格チャートに相対した指標のシフト
applied_price
[in]  使用される価格。ENUM_APPLIED_PRICE 価格定数のいずれか、または別の指標ハンドル。
戻り値
例:
//+——————————————————————+  //|                                                  Demo_iVIDyA.mq5 |  //|                        Copyright 2011, MetaQuotes Software Corp. |  //|                                             https://www.MQL5.com |  //+——————————————————————+  #property copyright “Copyright 2011, MetaQuotes Software Corp.”  #property link     “https://www.mql5.com”  #property version   “1.00”  #property description “The indicator demonstrates how to obtain data”  #property description “of indicator buffers for the iVIDyA technical indicator.”  #property description “A symbol and timeframe used for calculation of the indicator,”  #property description “are set by the symbol and period parameters.”  #property description “The method of creation of the handle is set through the ‘type’ parameter (function type).”  #property description “All other parameters like in the standard Variable Index Dynamic Average.” #property indicator_chart_window  #property indicator_buffers 1  #property indicator_plots   1  //— iVIDyA プロット  #property indicator_label1 “iVIDyA”  #property indicator_type1   DRAW_LINE  #property indicator_color1  clrBlue  #property indicator_style1 STYLE_SOLID  #property indicator_width1  1  //+——————————————————————+  //| 作成を処理する方法の列挙                                              |  //+——————————————————————+  enum Creation  {  Call_iVIDyA,           // iVIDyA を使用する  Call_IndicatorCreate   // IndicatorCreateを使用する  };  //— 入力パラメータ  input Creation             type=Call_iVIDyA;         // 関数の種類  input int                  cmo_period=15;             // Chande モメンタム期間  input int                  ema_period=12;             // 平滑化係数の期間  input int                  ma_shift=0;               // シフト  input ENUM_APPLIED_PRICE   applied_price=PRICE_CLOSE; // 価格の種類  input string               symbol=” “;               // シンボル   input ENUM_TIMEFRAMES     period=PERIOD_CURRENT;     // 時間軸  //— 指標バッファ  double         iVIDyABuffer[];  //— iVIDyA 指標ハンドルを格納する変数  int    handle;  //— 格納に使用される変数  string name=symbol;  //— チャートでの指標名  string short_name;  //— Variable Index Dynamic Average 指標に値の数を保存  int    bars_calculated=0;  //+——————————————————————+  //| カスタム指標を初期化する関数                                            |  //+——————————————————————+  int OnInit()  {  //— 配列の指標バッファへの割り当て  SetIndexBuffer(0,iVIDyABuffer,INDICATOR_DATA);  //— シフトを設定  PlotIndexSetInteger(0,PLOT_SHIFT,ma_shift);  //— 指標が描画するシンボルを決める  name=symbol;  //— 左右のスペースを削する  StringTrimRight(name);  StringTrimLeft(name);  //—「name」文字列の長さがゼロになった場合  if(StringLen(name)==0)  {  //— 指標が接続されているチャートのシンボルを取る  name=_Symbol;  }  //— 指標ハンドルを作成する  if(type==Call_iVIDyA)  handle=iVIDyA(name,period,cmo_period,ema_period,ma_shift,applied_price);  else  {  //— 構造体を指標のパラメータで記入       MqlParam pars[4];  //— Chande モメンタム期間  pars[0].type=TYPE_INT;  pars[0].integer_value=cmo_period;  //— 平滑化係数の期間  pars[1].type=TYPE_INT;  pars[1].integer_value=ema_period;  //— シフト  pars[2].type=TYPE_INT;  pars[2].integer_value=ma_shift;  //— 価格の種類  pars[3].type=TYPE_INT;  pars[3].integer_value=applied_price;  handle=IndicatorCreate(name,period,IND_VIDYA,4,pars);  }  //— ハンドルが作成されなかった場合  if(handle==INVALID_HANDLE)  {  //— 失敗した事実とエラーコードを出力する  PrintFormat(“Failed to create handle of the iVIDyA indicator for the symbol %s/%s, error code %d”,  name,  EnumToString(period),  GetLastError());  //— 指標が早期に中止された  return(INIT_FAILED);  }  //— Variable Index Dynamic Average 指標が計算された銘柄/時間軸を表示  short_name=StringFormat(“iVIDyA(%s/%s, %d, %d, %d, %s)”,name,EnumToString(period),  cmo_period,ema_period,ma_shift,EnumToString(applied_price));  IndicatorSetString(INDICATOR_SHORTNAME,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[])  {  //— iVIDyA 指標から複製された値の数  int values_to_copy;  //— 指標で計算された値の数を決める  int calculated=BarsCalculated(handle);  if(calculated<=0)  {  PrintFormat(“BarsCalculated() returned %d, error code %d”,calculated,GetLastError());  return(0);  }  //— これが指標計算の初めであるか iVIDyA 指標の値の数が変更した  //—または、2 つ以上のバーの指標の計算が必要である場合(価格履歴で何かが変更された)  if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1)  {  //— iVIDyABuffer 配列が銘柄/期間でiVIDyA 指標の値の数より大きい場合、全体のコピーはしない   //— 他の場合、指標バッファサイズより少ない量をコピーをする  if(calculated>rates_total) values_to_copy=rates_total;  else                       values_to_copy=calculated;  }  else  {  //— これは初回の計算ではなく、  //— 前回の OnCalculate() から、一以上のバーが加えられてない。  values_to_copy=(rates_total-prev_calculated)+1;  }  //— 配列を Variable Index Dynamic Average 指標の値で記入  //— FillArrayFromBuffer が false を返した場合、情報の準備が終わっていないので操作を終了する  if(!FillArrayFromBuffer(iVIDyABuffer,ma_shift,handle,values_to_copy)) return(0);  //— メッセージを形成する  string comm=StringFormat(“%s ==>  Updated value in the indicator %s: %d”,  TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS),  short_name,  values_to_copy);  //— チャートにサービスメッセージを表示する  Comment(comm);  //— Variable Index Dynamic Average 指標の値の数を覚える  bars_calculated=calculated;  //— prev_calculated 値を次の関数呼び出しのために返す  return(rates_total);  }  //+——————————————————————+  //| iVIDyA 指標から指標バッファを記入する                                     |  //+——————————————————————+  bool FillArrayFromBuffer(double &vidya_buffer[],// Variable Index Dynamic Average 値の指標バッファ  int v_shift,           // 線のシフト   int ind_handle,       // iVIDyA 指標ハンドル  int amount             // 複製された値の数  )  {  //— エラーコードをリセットする  ResetLastError();  //— インデックス0 を持つ指標バッファの値で iVIDyABuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,0,-v_shift,amount,vidya_buffer)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iVIDyA indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— 全てが成功  return(true);  }  //+——————————————————————+  //| 指標初期化解除関数                                                  |  //+——————————————————————+  void OnDeinit(const int reason)  {  //— 指標の削除後チャートをクリアする  Comment(“”);  }  | 
iVolumes
この関数は Volumes(ボリューム)指標のハンドルを返します。バッファは 1 つです。
int  iVolumes(  string              symbol,              ENUM_TIMEFRAMES      period,              ENUM_APPLIED_VOLUME  applied_volume        )  | 
パラメータ
symbol
[in] データが指標計算に使用される有価証券の銘柄名(NULL は現在のシンボル)
period
[in] 期間の値は ENUM_TIMEFRAMES 列挙の値の 1 つで、0 は現在の時間軸の意味です。
applied_volume
[in]  使用されるボリューム(ENUM_APPLIED_VOLUME 値のいずれか)
戻り値
例:
//+——————————————————————+  //|                                                Demo_iVolumes.mq5 |  //|                        Copyright 2011, MetaQuotes Software Corp. |  //|                                             https://www.MQL5.com |  //+——————————————————————+  #property copyright “Copyright 2011, MetaQuotes Software Corp.”  #property link     “https://www.mql5.com”  #property version   “1.00”  #property description “The indicator demonstrates how to obtain data”  #property description “of indicator buffers for the iVolumes technical indicator.”  #property description “A symbol and timeframe used for calculation of the indicator,”  #property description “are set by the symbol and period parameters.”  #property description “The method of creation of the handle is set through the ‘type’ parameter (function type).” #property indicator_separate_window  #property indicator_buffers 2  #property indicator_plots   1  //— iVolumes プロット  #property indicator_label1 “iVolumes”  #property indicator_type1   DRAW_COLOR_HISTOGRAM  #property indicator_color1  clrGreen, clrRed  #property indicator_style1 STYLE_SOLID  #property indicator_width1  1  //+——————————————————————+  //| 作成を処理する方法の列挙                                              |  //+——————————————————————+  enum Creation  {  Call_iVolumes,         // iVolumesを使用する  Call_IndicatorCreate   // IndicatorCreateを使用する  };  //— 入力パラメータ  input Creation             type=Call_iVolumes;           // 関数の種類  input ENUM_APPLIED_VOLUME  applied_volume=VOLUME_TICK;   // ボリュームの種類  input string               symbol=” “;                   // シンボル   input ENUM_TIMEFRAMES     period=PERIOD_CURRENT;       // 時間軸  //— 指標バッファ  double         iVolumesBuffer[];  double         iVolumesColors[];  //— iVolumes 指標ハンドルを格納する変数  int    handle;  //— 格納に使用される変数  string name=symbol;  //— チャートでの指標名  string short_name;  //— ボリューム指標に値の数を保存  int    bars_calculated=0;  //+——————————————————————+  //| カスタム指標を初期化する関数                                            |  //+——————————————————————+  int OnInit()  {  //— 配列の指標バッファへの割り当て  SetIndexBuffer(0,iVolumesBuffer,INDICATOR_DATA);  SetIndexBuffer(1,iVolumesColors,INDICATOR_COLOR_INDEX);  //— 指標が描画するシンボルを決める  name=symbol;  //— 左右のスペースを削する  StringTrimRight(name);  StringTrimLeft(name);  //—「name」文字列の長さがゼロになった場合  if(StringLen(name)==0)  {  //— 指標が接続されているチャートのシンボルを取る  name=_Symbol;  }  //— 指標ハンドルを作成する  if(type==Call_iVolumes)  handle=iVolumes(name,period,applied_volume);  else  {  //— 構造体を指標のパラメータで記入       MqlParam pars[1];  //— 価格の種類  pars[0].type=TYPE_INT;  pars[0].integer_value=applied_volume;  handle=IndicatorCreate(name,period,IND_VOLUMES,1,pars);  }  //— ハンドルが作成されなかった場合  if(handle==INVALID_HANDLE)  {  //— 失敗した事実とエラーコードを出力する  PrintFormat(“Failed to create handle of the iVolumes indicator for the symbol %s/%s, error code %d”,  name,  EnumToString(period),  GetLastError());  //— 指標が早期に中止された  return(INIT_FAILED);  }  //— ボリューム指標が計算された銘柄/時間軸を表示  short_name=StringFormat(“iVolumes(%s/%s, %s)”,name,EnumToString(period),EnumToString(applied_volume));  IndicatorSetString(INDICATOR_SHORTNAME,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[])  {  //— iVolumes 指標から複製された値の数  int values_to_copy;  //— 指標で計算された値の数を決める  int calculated=BarsCalculated(handle);  if(calculated<=0)  {  PrintFormat(“BarsCalculated() returned %d, error code %d”,calculated,GetLastError());  return(0);  }  //— これが指標計算の初めであるか iVolumes 指標の値の数が変更した  //—または、2 つ以上のバーの指標の計算が必要である場合(価格履歴で何かが変更された)  if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1)  {  //— iVolumesBuffer 配列が銘柄/期間で iVolumes 指標の値の数より大きい場合、全体のコピーはしない   //— 他の場合、指標バッファサイズより少ない量をコピーをする  if(calculated>rates_total) values_to_copy=rates_total;  else                       values_to_copy=calculated;  }  else  {  //— これは初回の計算ではなく、  //— 前回の OnCalculate() から、一以上のバーが加えられてない。  values_to_copy=(rates_total-prev_calculated)+1;  }  //— 配列を iVolumes 指標の値で記入  //— FillArraysFromBuffer が false を返した場合、情報の準備が終わっていないので操作を終了する  if(!FillArraysFromBuffers(iVolumesBuffer,iVolumesColors,handle,values_to_copy)) return(0);  //— メッセージを形成する  string comm=StringFormat(“%s ==>  Updated value in the indicator %s: %d”,  TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS),  short_name,  values_to_copy);  //— チャートにサービスメッセージを表示する  Comment(comm);  //— ボリューム指標値の数を覚える  bars_calculated=calculated;  //— prev_calculated 値を次の関数呼び出しのために返す  return(rates_total);  }  //+——————————————————————+  //| iVolumes 指標から指標バッファを記入する                                   |  //+——————————————————————+  bool FillArraysFromBuffers(double &volume_buffer[],   // ボリューム値の指標バッファ  double &color_buffer[],   // 色の指標バッファ  int ind_handle,           // ボリューム指標ハンドル  int amount                 // 複製された値の数  )  {  //— エラーコードをリセットする  ResetLastError();  //— インデックス0 を持つ指標バッファの値で iVolumesBuffer 配列の一部を記入する  if(CopyBuffer(ind_handle,0,0,amount,volume_buffer)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iVolumes indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— インデックス 1 を持つ指標バッファの値で iVolumesColors 配列の一部を記入する  if(CopyBuffer(ind_handle,1,0,amount,color_buffer)<0)  {  //— 複製が失敗したら、エラーコードを出す  PrintFormat(“Failed to copy data from the iVolumes indicator, error code %d”,GetLastError());  //— ゼロ結果で終了。 指標は計算されていないと見なされる  return(false);  }  //— 全てが成功  return(true);  }  //+——————————————————————+  //| 指標初期化解除関数                                                  |  //+——————————————————————+  void OnDeinit(const int reason)  {  //— 指標の削除後チャートをクリアする  Comment(“”);  }  | 
Originally posted 2019-07-30 09:42:34.