You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Because the broker may not have the MT5 platform.
Anthony,
Sanjay's code works in both MQL4 and MQL5. I'm inclined to agree with his approach and use code that works on either platform.
Be sure sometimes I have to come back to some my code months or years later and if my code contains more than 10 000 lines I'm usually glad that it doesn't contain such waste. And I'm not talking about code efficiency.
If I need to I can add a remark like this:
If your code is over a few hundred lines then you should rethink your code. For example use mqh files.
Anthony,
Sanjay's code works in both MQL4 and MQL5. I'm inclined to agree with his approach and use code that works on either platform.
If your code is over a few hundred lines then you should rethink your code. For example use mqh files.
Of course I have to use mqh and/or libraries. I also use a lot of remarks in code, but if I can write something in one line I don't prefer write it in ten lines.
As @SanjayBalraj said the better way is to write MQL4/MQL5 compatible code, but this is valid if you write it from scratch. If you just update your MQL4 code (like in this case) it does not have to be worth it.
But mainly, it does not solve @alex532110's problem. His problem is in setting "dt_TradeTime".
It must have to do with the dt_TradeTime. You have to check your code and look for logic error in setting the dt_TradeTime. Add this piece of code to check the dt_TradeTime
or
P.S.
I've updated my previous post. If you want to compare dt_TradeTime bar too you have to increase the length. But this doesn't have to do with your problem.
Thanks everyone for your responses.
It seems like the problem is with my understanding of how MT4 works.
The trade time is correct when i check the following...
Straight after I've defined dt_TradeTime.
But then when the code is run on the next period dt_TradeTime gets redefined as zero.
I'm not sure why this is the case. dt_TradeTime is defined inside an if statement that is only true if there are zero buy (sell) trades live.