array or loop problem?
joshatt the last order closed and ArrayRange(sl,0) keeps 1. Could anybody please help me figure it out?
Of course, it does, you never set the array to zero size.
Instead, at the start of OnCalculate compute your count, then just return the actual count and use that.
Senario:
in the current currency pair, open multiple positions, then manually close them one by one.
The following function recountorders() works fine and I can test with ArrayRange(sl,0) showing order counts of the current currecy pair correctly, and it turns zero when all orders closed.
However, after I use this function in an indicator, ArrayRange(sl,0) is normal until the last order closed and ArrayRange(sl,0) keeps 1. Could anybody please help me figure it out?
I've broken down my code removing as much irrelavent things as possible. Please just consider one order left, then it's closed.