As always....any help is appreciated.
Code Snippet:
public class BigTAutoStrategy_V2 : Strategy
{
private Order StopLongOrder = null;
private Order StopShortOrder = null;
...
protected override void OnBarUpdate()
{
if (High[0] > Position.AveragePrice * 1.0045)
{
StopLongOrder = ExitLongStopMarket(0, true, QuantitySize, Position.AveragePrice * 1.002, "LongStop", "Long1");
StopLongOrder = ExitLongStopMarket(0, true, QuantitySize, Position.AveragePrice * 1.002, "LongStop", "Long2");
StopLongOrder = ExitLongStopMarket(0, true, QuantitySize, Position.AveragePrice * 1.002, "LongStop", "Long3");
StopLongOrder = ExitLongStopMarket(0, true, QuantitySize, Position.AveragePrice * 1.002, "LongStop", "Long4");
StopLongOrder = ExitLongStopMarket(0, true, QuantitySize, Position.AveragePrice * 1.002, "LongStop", "Long5");
StopLongOrder = ExitLongStopMarket(0, true, QuantitySize, Position.AveragePrice * 1.002, "LongStop", "Long6");
StopLongOrder = ExitLongStopMarket(0, true, QuantitySize, Position.AveragePrice * 1.002, "LongStop", "Long7");
}
}
protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, string nativeError)
{
if (order.Name == "LongStop")
{
if (orderState != OrderState.Filled)
{
StopLongOrder = order;
}
}
if (StopLongOrder != null && StopLongOrder == order)
{
if (order.OrderState == OrderState.Cancelled && order.Filled == 0)
{
StopLongOrder = null;
}
}
}
protected override void OnExecutionUpdate(Execution execution, string executionId, double price, int quantity, MarketPosition marketPosition, string orderId, DateTime time)
{
if (StopLongOrder != null && StopLongOrder == execution.Order)
{
if (execution.Order.OrderState == OrderState.Filled)
{
StopLongOrder = null;
}
}
}


Comment