Good afternoon, I want to run the script in 2 steps:
1. The script opens two pending orders buystop and sellstop;
2. as soon as the price touches one of the orders,the “opposite” one is removed(for example, a buystop is opened,a sellstop is removed);
If I had no problems with the first step,then with the second….
Please tell me how to implement step 2 correctly.I heard that you can do this through the standard cycle of iterating orders (for (int i=orderstotal()-1; i>=0; i–) until> some does not fit the magic number,but how to implement this I do not understand.
I will be glad of any help and any advice.Thank you in advance.
Help with a simple script
Share
creepystaisy97
Good afternoon again, thank you for describing the steps.Tell me a little more please.here is such a situation,the first step I have is this-the script opens with the onset of a certain time,two orders.Can I leave step 1 as a script and make step 2 as an Expert Advisor?And if so, how?Or maybe it would be better to do all the steps with one Expert Advisor?Thank you in advance:)))
alexeyvik
Doing this in a script is absolutely wrong. In this case, you will have to loop the script, which is not welcome. But if you do this in the Expert Advisor, the algorithm is quite simple:
0aleksandr0
I didn’t overdo it)
Copied from my Expert Advisor, there is a similar functionality just)
creepystaisy97
is it mql5?
0aleksandr0
If there are no open positions before any of the orders are triggered, then I would build in an infinite loop checking the open position, and delete the remaining orders: