Hi All,

I have noticed in the backtesting of my algorithm that the code is not purchasing calls when it should be.  Sometimes it will buy them, but other times it will go 15-20 days without making one purchase even though there should be at least 3 buys per day based off of the indicator that I am giving it.  I took my buy conditions out for security purposes, but put in arbitrary buy signals in and you can see that it is not purchasing the contracts when it should be.  I placed some Debug strings in to see where it is failing and it seems that whenever I reach for j in data.OptionChains: chains = j.Value, self.BuyCall(chains), (line ~72) it only iterates through every once in a while.  Could someone explain what is going on here and how to get around it?  I also know that this code is still very ugly; I still have a bit of work to do but didnt want to work on anything else until I can get these buys down properly.  Another side question Ill ask while I'm here: can you call your BuyCall() and pass an option chain without being in the OnData method?  I didn't think you could, but my algo figures out the buy conditions in a consolidator's event handler, so at the moment, I just have it setting a flag and then the OnData will look at that flag each time and make decisions based off of the flag.  Is that the right way of going about that?  I know that means that buy and sells will be one minute later than the point in which the flag is set, so I'm sure there is a better way of doing it.  Thank you for the help in advance!!  Oh, and I am obviously not worried about the result/profits of the backtest as I don't have my strategies implemented into this code.