My strategy currently implements a stop and reverse in the following manner, if my stop loss is hit then the order automatically turns around and goes short for the same number of contracts. I have tried to achieve this with the following code but I seem to be running into some NT internal order handling rules as my S&R is implemented as a short stop at the time the long stop is triggered. Is there some other way to do this?
Attached code:
//////////////////////////
protected override void OnExecution(IExecution execution)
{
//LongOrder Execution
if (LongOrder != null && LongOrder.Token == execution.Order.Token)
{
if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled || (execution.Order.OrderState == OrderState.Cancelled && execution.Order.Filled > 0))
{
LongOrderStop = ExitLongStop(0, true, execution.Order.Filled, LongStopPrice, "LOSS", "BR2");
LongOrderTarget = ExitLongLimit(0, true, execution.Order.Filled, execution.Order.AvgFillPrice + 45 * TickSize, "PROFIT", "BR2");
if (LSAR == 'Y')
{
LongOrderSAR = EnterShortStop(0, true, NOC, LongStopPrice, "BRSAR1");
}
if (execution.Order.OrderState != OrderState.PartFilled)
{
LongOrder = null;
}
}
}
/////////////////////////
Thanks for any help
Regards
Ross

Comment