I have a strategy with 2 entries. When entry 1 closes, I want entry 2 to move to breakeven. I am getting the referenced error when compiling. Hoping you can point out something obvious I am doing wrong.
Thank you!
protected override void OnBarUpdate()
{
if (BarsInProgress != 0)
return;
if (CurrentBars[0] < 1)
return;
// Check if L1 position is closed
if (Position.MarketPosition != MarketPosition.Long && L1Closed == false && entryPriceL1 > 0)
{
L1Closed = true;
// Move L2 to breakeven
ExitLongStopMarket(1, entryPriceL1, "Move to BE", "L2");
}
// Set 1
if (CrossBelow(Low, SamriMathRTIntradayV21.Minus18, 1))
{
EnterLong(1, @"L1");
entryPriceL1 = Close[0];
L1Closed = false;
}
// Set 2
if (entryPriceL1 > 0 && Close[0] <= entryPriceL1 - 80 * TickSize)
{
EnterLong(1, @"L2");
}
}
protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, OrderState orderState, DateTime time)
{
if (orderState == OrderState.Filled && order.Name == "L1" && order.OrderAction == OrderAction.Sell)
{
// When L1 closes, move L2 to breakeven
if (Position.MarketPosition == MarketPosition.Long && Position.Quantity == 1)
{
ExitLongStopMarket(1, entryPriceL1, "Move to BE", "L2");
}
}
}

Comment