protected override void OnOrderUpdate(Cbi.Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, Cbi.OrderState orderState, DateTime time, Cbi.ErrorCode error, string comment) { Print(order.Name + ": " + orderState.ToString()); if (error != ErrorCode.NoError) { Print("Error: " + error.ToString()); } } protected override void OnPositionUpdate(Cbi.Position position, double averagePrice, int quantity, Cbi.MarketPosition marketPosition) { if (done) { return; } if (position.MarketPosition == MarketPosition.Long) { done = true; EnterShortLimit(averagePrice + (TickSize * 3), "sl1"); //EnterShortStopMarket(averagePrice - (TickSize * 5), "ssm1"); } else { } } protected override void OnBarUpdate() { if (BarsInProgress != 0) { return; } if (CurrentBar < BarsRequiredToTrade) { return; } if (Position.MarketPosition == MarketPosition.Flat) { if (!done) { EnterLongLimit(GetCurrentBid(), "ll0"); } } }
ll0: Accepted
ll0: Working
ll0: Filled
Close position: Submitted
Close position: Accepted
Close position: Working
sl1: Submitted
sl1: Accepted
sl1: Working
Close position: CancelPending
Close position: CancelSubmitted
Close position: Cancelled
sl1: CancelPending
sl1: CancelSubmitted
sl1: Cancelled
And other question, i have the "ssm1" order commented because it doesn't work together with "sl1", why is that?
The idea is to avoid the "SetProfit.." and "StopLoss.." methods.
Comment