solution was to change the basic SampleAtmStrategy code to include the code below in " "
I am placing Buy/Sell stops with the code....which need to trigger, then fill....the reason you need to wait/check atm strat is actually filled (before setting the order string to empty) is to avoid the race condition of flat status while atm fills.
// Check for a pending entry order
if (orderId.Length > 0)
{
string[] status = GetAtmStrategyEntryOrderStatus(orderId);
if (status.GetLength(0) > 0 // added code here
"
&& atmStrategyId != null && atmStrategyId .Length > 0
&& GetAtmStrategyMarketPosition(atmStrategyId ) != Cbi.MarketPosition.Flat
"
)
{
Print("The entry order filled amount is: " + status[1]);
Print("The entry order order state is: " + status[2]);
// If the order state is terminal, reset the order id value
if (status[2] == "Filled" || status[2] == "Cancelled" || status[2] == "Rejected")
orderId = string.Empty; // want to wait for actual fill before setting this empty
}
} // If the strategy has terminated reset the strategy id
else if (atmStrategyId.Length > 0 && GetAtmStrategyMarketPosition(atmStrategyId) == Cbi.MarketPosition.Flat)
atmStrategyId = string.Empty;

Comment