The atmStrategyCreate executes and the call back function block matches the AtmStrategyID and their are no Errors.
So isAtmStrategyCreated is set true. The code for this identical to the sample code supplied.
The AtmStrategy template gets applied to the chart. This all happens on the close of a bar ( i.e. Is first tick of bar)
And Here is where it takes a left turn. On the next tick ( i.e. Not first tick) a portion of my code reads the market position.
if (GetAtmStrategyMarketPosition(atmStrategyId) == Cbi.MarketPosition.Flat)
and it reports back that it is "FLAT". My code then clears variables etc which disables all of the features that need to be accessed while the Atmstrategy is on the chart on running.
This seems like some kind of synchronization problem. What is going on as clearly it is not flat.
I assumed since my AtmStrategy submits a Market order, It was filled immediately and since I am waiting for the next onbarupdate (next tick). I again assumed I was good to go. I am going to insert a while loop checking if flat with a counter after the isAtmstrategycreated. But that seems an unseemly way to solve this if it does.
Thanks for any help and direction you can give.
Jerry

Comment