You need to check placing, modifying, deleting, closing, etc of Orders and report any errors immediately . . you need to read up on how GetLastError works: https://docs.mql4.com/check/GetLastError once called it is reset back to 0 . . .
You need to add some Print statements to your EA so you can see what is going on . . .
You need to check placing, modifying, deleting, closing, etc of Orders and report any errors immediately . . you need to read up on how GetLastError works: https://docs.mql4.com/check/GetLastError once called it is reset back to 0 . . .
You need to add some Print statements to your EA so you can see what is going on . . .
Hi Raptor,
Thanks for the assistance. i will learn up about error reporting and see where it takes me.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I am brand new to coding and have written this program to open orders quickly as my trade management requires that i exit portions of my trade at different takeprofit levels therefor i am need to open 3 positions when i get into a trade, all of different sizes.
The idea of the program is to give you the option of getting in either "at market" or "limit". Long or Short. Adjustment of TP's and Stoploss is also available but defaults are in place in the code if TP's are left 0.0. The program also works out the risk based on current account balance and tick value and opens the appropriate lot sizes.
The program works perfectly all except for 1 bug that i can't seem to work out. Sometimes randomly it opens a duplicate of the trade again at a random point in the future. I came back to the computer today and noticed that it had opened a trade another 2 times (totaling an extra 6 positions). I have not re-compiled or restarted MT4.
I am temporarily combating this by running the EA and then removing the EA from the chart so it cant open another one. The issue with doing this is it doesnt allow the "Move stop to Break even" feature to take place after the first "take Proft" is hit which is an important feature of this program and it obviously needs to still be attached to the chart for this.
I am using a boolean called "Traded" which is initiated up the top of the code as false. The trades are only supposed to be run if "Traded" == False. This bool idea definitely works otherwise it would keep opening orders endlessly on every tick, it is the random thing out of nowhere that is doing my head in....... Is it possible that this bool is resting itself to false somehow?
If anyone has any ideas to help make this program better and or fix this bug, i would very much appreciate your help and opinions.
Thanks in advance.