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
There are actually more errors in the code. For example, it is well shown that using CSymbolInfo just for the sake of SB-style is evil.
Closing positions via a previously collected list of tickets is evil. This is a very common error.
I think this says a lot:
It is worth understanding that this EA is for training purposes.
About processing server return codes. Personally, I always process them. But here - in the tester (I hope you understand that a training EA is made for the tester and for its further modifications independently) - it is probably not necessary to process all the necessary return codes. As well as always having your own trading environment is quite justified both for real trading, and even more so for a tester.
You can see what is there:
First, you fill in the data about existing positions:
Then, after checking the signals, the opening (here the Buy position is opened):
If the number of Sell is greater than zero - close. The Expert Advisor is swinging - there is always only one position. So there are no Buy positions if there are Sell positions - it is unnecessary to check their number here, as well as to update the trading environment in the internal arrays of the Expert Advisor.
Then it checks the number of Buy positions. Their number can be greater than zero only after opening. But after closing Sell, the number of Buy positions is necessarily equal to zero - a swing EA. And there is no need to run a loop looking for something that is already known.
Next are the minimum correctness checks and the opening of a Buy position. Immediately after returning true, the internal arrays of the EA's trading environment are updated.
Everything is laconic and without excesses. Correct me if I did not see something here.
The error is in the enum input and call, not in the min. distance. But it is also calculated incorrectly, because
I don't see it. Show me - it's interesting.
I think this one speaks volumes:
It is worth realising that this EA is for training purposes.
About processing server return codes. Personally, I always process them. But here - in the tester (I hope you understand that a training Expert Advisor is made for the tester and for its further modifications independently) - it is probably not necessary to process all the necessary return codes. As well as always having your own trading environment is quite justified both for real trading, and even more so for a tester.
You didn't read carefully. I didn't want any return codes. CloseSell on tickets is evil in itself. What does a tester have to do with it when the code should work correctly at least on a demo and have no obvious potential errors?
There should be RefreshRates after CloseSell. It is absent, so there will be failures even in the tester if you enable the delay mode. Using a standard bible for the sake of SB-style is evil. And the code shows it well.
Having made only a few changes in SymbolInfo.mqh, I managed to compile it and use it in MT4. But who in his right mind can think of this when writing something in MQL4! Why does it occur to many people when coding in MQL5?! Not only does it cover a lot of potential errors, takes time to learn, but it also looks clumsy.
You didn't read it carefully. I didn't want a return code. CloseSell on tickets is evil in itself. What does a tester have to do when the code should work correctly at least on a demo and have no obvious potential errors?
There should be RefreshRates after CloseSell. It is absent, so there will be failures even in the tester if you enable the delay mode. Using a standard bible for the sake of SB-style is evil. And the code shows it well.
After CloseSell() there is a Buy opening with a zero price:
Why two times RefreshRates() ? Have you looked at the code of opening in SB in CTrade? I did:
After CloseSell() the Buy is opened with a zero price:
Why RefreshRates() twice ?
Because Correct functions are called.
Have you looked at the code of opening in CTrade?
Include\Trade\*.mqh I always watch/vigil, because you should know the enemy by sight.
Then that Correct functions are called.
Include\Trade\*.mqh I always watch/vigil, because you should know the enemy by sight.
Enemy :))))
Yes, now I've seen it - in correct functions the price is read from m_tick variables of SB, which are filled in during updating, not directly through SymbolInfoDouble() - that would not be a possible ambush you are talking about. Moreover, there is not much code before the correct functions, and the prices are updated right after the tick arrives - at the very beginning of OnTick():
Enemy :)))))
Yes, now I've seen it - the correct functions read the price from m_tick variables of the SB, which are filled in when updating, but not directly through SymbolInfoDouble() - that would not be a possible problem you are talking about. Moreover, there is not much code before the correct functions, and the prices are updated immediately upon the tick arrival - at the very beginning of OnTick():
Forum on trading, automated trading systems and testing trading strategies.
Expert Advisors: Diff_TF_MA_EA
fxsaber, 2018.02.01 22:10
Having made very few changes to SymbolInfo.mqh it turned out to compile it and use it in MT4. But who in their right mind can think of this when writing something in MQL4! Why does it occur to many people when coding in MQL5?! Not only does it cover a lot of potential errors, takes time to learn, but it also looks clumsy.
I will throw a stone in the MQL4 garden. Bid/Ask with forced RefreshRates is evil. But there is a wonderful macro-construction that gives an unmistakable and concise result.
I've been waiting for you to ride your humpback horse :)))).
It is quite enough to use SymbolInfoDouble() in these correct functions to get the necessary prices. However, that's what I do in my similar functions. Here the programmer relied in vain on the data received from the symbol object - they are given out old - written to m_tick only when updating.
I've been waiting for you to saddle up your hunchback horse :))))))
It is quite enough to use SymbolInfoDouble() in these functions to get the necessary prices. However, that's what I do in my similar functions. Here, the programmer relied on the data received from the symbol object in vain - it is given out old - written to m_tick only when updating.
Here a logical question arises, who made him to get the simplest data in OOP? In MQL4 he always received this data without any problems, but what has changed in his mind?
Humpbacked Horse
Forum on trading, automated trading systems and testing trading strategies.
MT4-Tester VS MT5-Tester
fxsaber, 2017.05.08 10:04 AM
Thanks to the subj found the culprit, it always happens when there is an opportunity to compare.
Expert Advisor showing the bug
MT4
MT5