Hi,
I tried to do accurate ranking of limit order using StaticVarGenarateRanks, but I realized that it still won't correctly enter positions since I can't know how many positions are currently open for accurately limiting the number of positions I can enter.
So I'm trying to turn to mid-level BTC were I can use the GetFirstOpenPos/GetNextOpenPos methods to get that information, then use sig.Price = -1 to drop the redundant signals that shouldn't have entered.
What I want is to better understand how do the GetFirstOpenPos/GetNextOpenPos methods are updated; meaning if I run on bars and close a signal with sig.Price = -1 on the current bar, then does GetFirstOpenPos/GetNextOpenPos methods updates accordingly in the ext bar?
The GetFirstOpenPos/GetNextOpenPos methods are used to iterate through open trades. If you change a particular signal object to prevent a trade entry, then that signal will never result in a new trade being opened, and therefore on the next bar there is nothing new for GetFirstOpenPos/GetNextOpenPos to reflect from that particular signal.
You need to modify the signals for the current bar before you call bo.ProcessTradeSignals(). The way you're doing it will have no effect on the outcome because all the trades have been entered before you disable any signals. Try moving bo.ProcessTradeSignals() after your for loop.
Also, you can just call bo.GetOpenPosQty(); to find the number of open positions without looping.