A Multi Currency EA.
In "OnTick" I have loop that tests if a new bar has arrived .
ThisTimeStamp and LastTimeStamp are datetime
ThisTF is ENUM_TIMEFRAMES and is set to 15M
I am running the EA on a 5 Minutes chart. On MT5 the loop runs every 15 minutes. On MT4 it runs every 5M (Or whatever Timeframe I run the EA on)
Really hard to tell from that small snippet of code.....
What it shows is that the test for timestamp comparison works in MQL5. The comparison is done with the Timeframe I specify in the code (15M)
When running MT4 the comparison is made with the Timeframe the EA is running on. In MT5 The loop is executed every 15M. In MT4 it is executed every
time for the time frame the EA is running. MT4 does not use the timeframe I specify in the code. That is the error.
Further tests
Code below is done in OnInit on both MQL4 code and MQL5 code.
EA is started on M5 chart
When I run it on MT5 the Print output is as I expected it to be
Input TimeFrame: M15
>>>MyTF is M15
When I run it on MT4 the Print ouput is not what I expect.
Input TimeFrame: M15
>>>>MyTF is Current
A lot of code references using "myTF" to get indicators and close data. In MT4 all is taken from the Time frame the EA is running on instead of the TF I specify.
In MT5 it works as expected. in MT4 it is in error
input string TimeFrame = "M15"; ENUM_TIMEFRAMES myTF; if(TimeFrame == "M3") myTF = PERIOD_M3; if(TimeFrame == "M5") myTF = PERIOD_M5; if(TimeFrame == "M15") myTF = PERIOD_M15; if(TimeFrame == "H1") myTF = PERIOD_H1; if(TimeFrame == "Current") myTF = PERIOD_CURRENT; Print("Input TimeFrame: " + TimeFrame); if(myTF == PERIOD_M15) Print(">>> myTF is M15"); if(myTF == PERIOD_CURRENT) Print(">>> myTF is Current"); if(myTF == PERIOD_M5) Print(">>> myTF is M5");
Mysteri solved!!!!!!
The input "TimeFrame" that should contain "M15" did in reality contain " M15" so the test failed
Lots of time and energy to solve a simple error
A Multi Currency EA.
In "OnTick" I have loop that tests if a new bar has arrived .
ThisTimeStamp and LastTimeStamp are datetime
ThisTF is ENUM_TIMEFRAMES and is set to 15M
I am running the EA on a 5 Minutes chart. On MT5 the loop runs every 15 minutes. On MT4 it runs every 5M (Or whatever Timeframe I run the EA on)

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
A Multi Currency EA.
In "OnTick" I have loop that tests if a new bar has arrived .
ThisTimeStamp and LastTimeStamp are datetime
ThisTF is ENUM_TIMEFRAMES and is set to 15M
I am running the EA on a 5 Minutes chart. On MT5 the loop runs every 15 minutes. On MT4 it runs every 5M (Or whatever Timeframe I run the EA on)