I developing a strategy and I need it to trigger a stop loss order separately for a short position and a long position. I tried to use BarsSinceExitExecution("Stop loss") method, but it triggers all executions "Stop loss". I have "SAT4 : Buy" as a signal name for my long orders, and "SAT4 : Sell" as a signal name for my short orders. I think this could be done with OnOrderUpdate(…) method. Here is a part of my code, but it is not working.
protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, string comment)
{
if (order.Name == "SAT4 : Buy" && order.OrderState == OrderState.Filled)
{ … }
}
Please tell me what's wrong with it.
Comment