The great and terrible MT4 forever (or how to strategise a transition) - page 14
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
Yes, that's my point too. It turns out that the script manages to close one of the positions, when in fact there are two, but PositionsTotal() returns 1. And then, after closing, the cycle end condition is met, i.e. PositionsTotal() returns 2.
You can insert printouts to fully see what's going on.
Printouts can be inserted to fully see what is going on.
Yes, to confirm that the reasoning is correct:
Result:
In fact, the position is left alone hanging.
P. S. Corrected the post, because I put the wrong thing in the code because of the copy-paste.In fact, the position was left alone hanging.
In the log, it is likely that the recording time of the last trade follows the recording time of the script closing.
It is also important to print OrdersTotal.In the log, it is likely that the time of the last trade record follows the time of the script's closing record.
Are you referring to these two records?
I think everything is correct here in terms of ordering. There are in fact two positions but PositionsTotal() has not yet received an update. Therefore, it returns 1 and the position is closed. And after the trade operation is executed, it is updated to the state that corresponds to the one that existed before the trade operation was executed. So, we get 2.
The problem has been discussed for a long time. Almost everyone has encountered it. It is the first time that a stable reproducible code has been found.
A solution has been found.
And what is the solution?
What was the difficulty in finding a stable reproducing code? One action to open or close, and the next with a decision based on the numbers of positions in the market or in the history.Are you referring to these two records?
No, the last record of trading activity is in the second log.
It is also important to print OrdersTotal.
I have added prints. Now two positions remain, as expected:
Result:
What is the solution?
the number of positions in the market or in the history.
There was no difficulty, I wrote it on the fly.
It opens positions like this without stopping at all
It opens positions like this without stopping at all
Well, who's going to update the total? ))