無料でロボットをダウンロードする方法を見る
Facebook上で私たちを見つけてください。
私たちのファンページに参加してください
興味深いスクリプト?
それではリンクにそれを投稿してください。-
他の人にそれを評価してもらいます
記事を気に入りましたか?MetaTrader 5ターミナルの中でそれを試してみてください。
ライブラリ

MQL4からMQL5の互換性ライブラリ - MetaTrader 5のためのライブラリ

ビュー:
1527
評価:
(49)
パブリッシュ済み:
2016.10.07 11:39
アップデート済み:
2016.11.22 07:34
このコードに基づいたロボットまたはインジケーターが必要なら、フリーランスでご注文ください フリーランスに移動

このライブラリは、MetaTrader4のためのスクリプトと指標のMetaTrader5での実行を可能にします。関数のほとんどはすでにカバーされていますが、エキスパートでの取引の仕組みを書き換える必要があるために取引ロジックは残されています。

このライブラリは、EA取引メカニズム以外の機能のほとんどをカバーしています。また、MT5でエラーを発生する関数については名前がMQL4で終わる代替関数があります。それらのほとんどは、すでにMQL5で同じ名前を持っている関数と相反するものです。オリジナルの記事はスケルトンライブラリにつながったのみなので、このライブラリのバージョンはほとんどMQL4関数で満たされています。特定の関数名の検索には「MQL4」を検索パターンとしてライブラリソースコードを検索してください。

やること:注文の送信及び制御のためのEAの取引力学。一部の関数は一般的なスタブで、ログにエラーメッセージを生成します。これらのリターンコードは常に-1です。

インストール:

mql4compat.mqhをインクルードディレクトリに配置します(Windowsユーザーローミングプロファイル内)。

MQL4 EA/indicator/library/scriptの #property 定義の直後に下記を追加します。


 

#include <mql4compat.mqh>

 

MQL4関数を変えます。

int init() to int OnInit()
int deinit() to void OnDeinit(const int reason);
int start() in script to void OnStart();
指標のint start() に:
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[])
  {

そして、最後の行の return() 関数は下記となります。

   return(rates_total);

 パラメータ変更によるMQL4とMQL5の間の競合の関数名をMQL4を追加して変更します。

   int ArrayInitializeMQL4(double &array[], double value)
   int ArrayMaximumMQL4(double &array[], int count=WHOLE_ARRAY, int start=0)
   int ArrayMinimumMQL4(double &array[], int count=WHOLE_ARRAY, int start=0)
   int ArraySortMQL4(double &array[], int count=WHOLE_ARRAY, int start=0, int sort_dir=MODE_ASCEND)
   double CopyBufferMQL4(int handle,int index,int shift)
   double EnvelopesMQL4(string symbol, int tf, int ma_period, int method, int ma_shift, int price, double deviation, int mode, int shift)
   double FileReadDoubleMQL4(int handle, int size=DOUBLE_VALUE)
   bool FileSeekMQL4(long handle, int offset, ENUM_FILE_POSITION origin)
   int IndicatorCountedMQL4(int _prev_calculated=0)
   bool ObjectCreateMQL4(string name, ENUM_OBJECT type, int window, datetime time1, double price1, datetime time2=0, double price2=0, datetime time3=0, double price3=0)
   bool ObjectDeleteMQL4(string name)
   string ObjectDescriptionMQL4(string name)
   int ObjectFindMQL4(string name)
   bool ObjectMoveMQL4(string name, int point, datetime time1, double price1)
   string ObjectNameMQL4(int index)
   int ObjectsDeleteAllMQL4(int window=EMPTY, int type=EMPTY)
   int ObjectsTotalMQL4(int type=EMPTY, int window=-1)
   bool SetIndexBufferMQL4(int index, double &array[])
   string StringConcatenateMQL4(string _str1,string _str2, ... string _str64="")
   int StringGetCharMQL4(string text, int pos)
   string StringSetCharMQL4(string text, int pos, int value)
   double iACMQL4(string symbol, int tf, int shift)
   double iADMQL4(string symbol, int tf, int shift)
   double iADXMQL4(string symbol, int tf, int period, int price, int mode, int shift)
   double iAOMQL4(string symbol, int tf, int shift)
   double iATRMQL4(string symbol, int tf, int period, int shift)
   double iAlligatorMQL4(string symbol, int tf, int jaw_period, int jaw_shift, int teeth_period, int teeth_shift, int lips_period, int lips_shift, int method, int price, int mode, int shift)
   double iBWMFIMQL4(string symbol, int tf, int shift)
   double iBandsMQL4(string symbol, int tf, int period, double deviation, int bands_shift, int method, int mode, int shift)
   double iBearsPowerMQL4(string symbol, int tf, int period, int price, int shift)
   double iBullsPowerMQL4(string symbol, int tf, int period, int price, int shift)
   double iCCIMQL4(string symbol, int tf, int period, int price, int shift)
   double iDeMarkerMQL4(string symbol, int tf, int period, int shift)
   double iForceMQL4(string symbol, int tf, int period, int method, int price, int shift)
   double iFractalsMQL4(string symbol, int tf, int mode, int shift)
   double iGatorMQL4(string symbol, int tf, int jaw_period, int jaw_shift, int teeth_period, int teeth_shift, int lips_period, int lips_shift, int method, int price, int mode, int shift)
   double iIchimokuMQL4(string symbol, int tf, int tenkan_sen, int kijun_sen, int senkou_span_b, int mode, int shift)
   double iMACDMQL4(string symbol, int tf, int fast_ema_period, int slow_ema_period, int signal_period, int price, int mode, int shift)
   double iMAMQL4(string symbol, int tf, int period, int ma_shift, int method, int price, int shift)
   double iMFIMQL4(string symbol, int tf, int period, int shift)
   double iMomentumMQL4(string symbol, int tf, int period, int price, int shift)
   double iOBVMQL4(string symbol, int tf, int price, int shift)
   double iOsMAMQL4(string symbol, int tf, int fast_ema_period, int slow_ema_period, int signal_period, int price, int shift)
   double iRSIMQL4(string symbol, int tf, int period, int price, int shift)
   double iRVIMQL4(string symbol, int tf, int period, int mode, int shift)
   double iSARMQL4(string symbol, int tf, double step, double maximum, int shift)
   double iStdDevMQL4(string symbol, int tf, int ma_period, int ma_shift, int method, int price, int shift)
   double iStochasticMQL4(string symbol, int tf, int Kperiod, int Dperiod, int slowing, int method, int field, int mode, int shift)
   double iWPRMQL4(string symbol, int tf, int period, int shift)

指標では、OnInit() 関数と#propertyヘッダーのために手動の調整が必要です。また、IndicatorCounted()関数は、一部分を削除するか、MQL5 prev_calculated変数に変えることで同じ名前の変数に変更する必要があります。

#define IndicatorCounted IndicatorCountedMQL4(prev_calculated)

カスタム指標では#propertyヘッダがMQL5でどのように設定されextern 入力パラメータ定義がinputに置き換えられるかをご覧ください。また、MQL5にはconstantsが存在し、この値を変えようとする試みはエラー発生につながります。これは、一時変数を追加して入力パラメータ値をコピーすることで解決できます。

お使いのベースコードの最初の行に、MQL4で予約されている変数の初期化を追加してください(OHLC/Time/Volume予約変数がOnCalculate()で使われている場合、カスタム指標は警告を発しますが、これは無視しても安全です)。 

 

// -- MQL4に互換性のある環境を初期化
   InitMQL4Env();

MetaQuotes Ltdによって英語から翻訳されました。
元のコード: https://www.mql5.com/en/code/1787

Relative Momentum Index (RMI) Relative Momentum Index (RMI)

RMI (Relative Momentum Index) 指標はRSIの改良版で、計算にモメンタムが含まれています。

Hull_Candles Hull_Candles

平均足アルゴリズムと2つの平均に基づいてたローソク足の形での指標

RSIImproved RSIImproved

2つのRSIオシレータに基づいて構築された複合指標

ImpulseOsMA ImpulseOsMA

この指標は Elder's Impluse system に基づいてバーを描画します。