How about OrderMagicNumber() ? Thanks
How about OrderMagicNumber() ? Thanks
iBarShift() is easy to use but iBarShiftMQL4() is quite complex. And so on...
Why both "TickValue() and SymbolInfoDouble(_Symbol,SYMBOL_TRADE_TICK_VALUE)" always return "0"?!
Hi, Rosh:
I am very appreciated you said that:" I have plans to develop the MQL4 emulator, which will allow you to run your MQL4 programs in new MetaTrader 5 client terminal."
I am not a good programme designer but a trader. MQL5 is too difficult for me.
Waiting for your MQL4 emulator. TKS a Million!
Best Wishes for you.
I found a mistake
If only one chart window is open. Then the ID of this window of = -1
int WindowHandleMQL4(string symbol, int tf) { ENUM_TIMEFRAMES timeframe=TFMigrate(tf); long currChart,prevChart=ChartFirst(); int i=0,limit=100; while(i<limit) { currChart=ChartNext(prevChart); if(currChart<0) break; if(ChartSymbol(currChart)==symbol && ChartPeriod(currChart)==timeframe) return((int)currChart); prevChart=currChart; i++; } return(0); }
-
int WindowHandleMQL4(string symbol, int tf) { ENUM_TIMEFRAMES timeframe=TFMigrate(tf); long currChart,prevChart=ChartFirst(); int i=0,limit=100; while(i<limit) { currChart=ChartNext(prevChart); if( currChart<0 && currChart != -1) break; if(ChartSymbol(currChart)==symbol && ChartPeriod(currChart)==timeframe) return((int)currChart); prevChart=currChart; i++; } return(0); }
Also be careful on the precedence. I spent half a day debugging a logic and found that the precedence of && and || are different between MQL4 (|| first) and MQL5 (&& first). So in migrating from MQL4 to MQL5, make sure you search through all the comparison expressions.
- 2010.05.17
- Sergey Pavlov
- www.mql5.com
Also be careful on the precedence. I spent half a day debugging a logic and found that the precedence of && and || are different between MQL4 (|| first) and MQL5 (&& first). So in migrating from MQL4 to MQL5, make sure you search through all the comparison expressions.
You are right. See Precedence Rules:
Each group of operations in the table has the same priority. The higher the priority of operations is, the higher it is position of the group in the table. The precedence rules determine the grouping of operations and operands.
Attention: Precedence of operations in the MQL5 language corresponds to the priority adopted in C++, and differs from the priority given in the MQL4 language.
I found a mistake
If only one chart window is open. Then the ID of this window of = -1
-
My mistake, it is true. :)
int WindowHandleMQL4(string symbol, int tf) { ENUM_TIMEFRAMES timeframe=TFMigrate(tf); long currChart,prevChart=ChartFirst(); int i=0,limit=100; while(i<limit) { currChart=ChartNext(prevChart); if(i==0)currChart=prevChart; // Wenn nur ein Chartfenster offen ist if( currChart<0) break; if(ChartSymbol(currChart)==symbol && ChartPeriod(currChart)==timeframe) return((int)currChart); prevChart=currChart; i++; } return(0); }

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
New article Migrating from MQL4 to MQL5 is published:
Many developers have accumulated a lot of indicators and trading strategies written in MQL4. To use them in Metatrader 5, they should be converted to MQL5. It's not so easy to rewrite all programs in MQL5. It would be much easier to convert them, if there were a translation-reference, and better with examples.
This article is a quick guide to MQL4 language functions, it will help you to migrate your programs from MQL4 to MQL5. For each MQL4 function (except trading functions) the description and MQL5 implementation are presented, it allows you to reduce the conversion time significantly. For convenience, the MQL4 functions are divided into groups, similar to MQL4 Reference.
Author: Sergey