When I start the strategy on a chart, both print statements from OnBarUpdate execute, but it never gets to OnExecution(). I'm not sure if the order isn't actually being submitted or what. The price does indeed go through the level a few bars later. Am I using ENTERLONGSTOP() incorrectly here? This seems very simple, I must be doing something wrong.
protectedoverridevoid OnBarUpdate()
{
// Check if we have no position (at start of strategy on first bar calc), and create both buy and sell orders if true
if (Position.MarketPosition == MarketPosition.Flat && initialPxFlag == false)
{
initialPx = Close[0];
initialPxFlag = true;
Print(Time[0] + " start, initialPx = " + initialPx);
// Set initial buy order
tradeEntryPx = initialPx + NumTrailingTicks*myTickSize;
EnterLongStop(DefaultQuantity, tradeEntryPx, "myTrade");
Print(Time[0] + " start, tradeEntryPx = " + tradeEntryPx);
} // end if
} // end OnBarUpdate()
protectedoverridevoid OnExecution(IExecution execution)
{
tradedPx = execution.Order.AvgFillPrice;
localMin = tradedPx;
localMax = tradedPx;
Print(Time[0] + " in OnExecution, tradedPx = " + tradedPx);
} // end OnExecution
Comment