contractQuantity = 2;
entryPriceShortRedCount = 12867;
protectedoverridevoid OnBarUpdate()
{
ShortRedCtEntryOrder = EnterShortLimit(contractQuantity, entryPriceShortRedCount, "Short Red Count : 0");
}
protectedoverridevoid OnExecution(IExecution execution)
{
if (ShortRedCtEntryOrder != null && ShortRedCtEntryOrder.Token == execution.Order.Token)
{
if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled || (execution.Order.OrderState == OrderState.Cancelled && execution.Order.Filled > 0))
{
ShortRedCtTargetOrder = ExitShortLimit(0, true, execution.Order.Filled, execution.Price - 40 * TickSize, "Profit Target", "Short Red Count : 0");
ShortRedCtStopOrder = ExitShortStop(0, true, execution.Order.Filled, execution.Price + 75 * TickSize, "Stop Loss", "Short Red Count : 0");
ShortRedCtEntryPrice = execution.Price;
}
// Resets ShortRedCtEntryOrder object to null after order has been fully filled
// or partially filled with the remaining orders cancelled
if (execution.Order.OrderState != OrderState.PartFilled // fully filled/cancelled
)
{
ShortRedCtEntryOrder = null;
}
}
}
The Entry order was partially filled with 1 contract, then fully filled with the second contract.
The Profit target order was submitted for 1 contract, then the Stop target was accepted for 2 contracts. It looks like the Profit Target then was modified to have 2 contracts as needed, but the broker rejected that modification.
Not sure what happened exactly, but the log file is attached. Can you please help me understand the sequence of events that lead to my strategy being shut down and the trade being exited instantly. I lost a large sum of $ because this crashed and missed not only this profit, but the subsequent trade, which never fired because the strategy had crashed.
Comment