Hello inkexit
Firstly:
see file naming conventions: Creating and Using Programs and most importantly: File System
This script is simply supposed to add up all lots taken, determine their position, close all orders and enter a new order in the opposite direction of the same total size. There would be problems if you have orders of two different directions open at once, but since I do not trade this way, it is no problem for me. The script starts fine, it addds up the total lots well, and closes all open positions. Then, however, nothing happens. If I activate another script, such as buy, I get a pop up window which says, do you really want to stop Reverse.mqh and run Buy.mqh? Which leads me to believe there must be an endless loop somewhere in the code, but I can't spot it.
As you said, it's and endless loop:
copy/paste is not a good habit
you have a typo here. "i--" should be "j--"
for(int j=total-1;j>=0;i--) //CHANGE THIS LINE, should be for(int j=total-1;j>=0;j--) { if (OrderSelect(j,SELECT_BY_POS)) { ordertype=OrderType();
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
This script is simply supposed to add up all lots taken, determine their position, close all orders and enter a new order in the opposite direction of the same total size. There would be problems if you have orders of two different directions open at once, but since I do not trade this way, it is no problem for me. The script starts fine, it addds up the total lots well, and closes all open positions. Then, however, nothing happens. If I activate another script, such as buy, I get a pop up window which says, do you really want to stop Reverse.mqh and run Buy.mqh? Which leads me to believe there must be an endless loop somewhere in the code, but I can't spot it.