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.
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
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.