Firstly - get rid of the i++ and change the loop to decrement rather than increment. Its been said umpteen times on this forum. As you close orders in the pool, the remaining orders get re-indexed. If you are running an incrementing loop, then you will miss certain orders.
Secondly, "how to do something just once" is probably the most asked question on this forum. If only we could find a way to have that question asked "only once". The answer is to create a boolean (true or false) variable which stores whether or not a certain operation has been completed. So - in this specific case, you'd check for the value of the bool in your if statement. And you'd set it once you close your order.
CB
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
Hello I'd like to execute this function only once.
Example: I open 2 lots. When the market get the "Take Profit", I'd like to close
half of the position. In this case, 1 lot. The probleme are each time the condition are meet,
the function closed half of the position again and again. 2 lots => 1 lot => 0.5 lot until 0.
I'd like to close half position at "Take Profit" and close the second half when other condition
are meet.
Thank's
pgforex