i am having problems to set breakeven properly in my strategy.
After my condition in formed, I would like to enter in trade, pending entry order is High[1] (calculateonbarclose = false), and as market goes, i would like to enter on High of each followed bar so i am in multiple trading positions.
i would like to set breakeven condition at each placed trade, however my code works only in case one trade is open in a time, it does not work when multiple trades have been placed.
Could you please help me how to set breakevens for each placed trade, using multiple entry orders?
Condition
if (High[1] > High[2] && High[1] > High[3] && formace1 == true && FirstTickOfBar) { ++c; DrawArrowUp(CurrentBar.ToString(), false, 0, Low[0] - 1, Color.Black); ABC_trend = EnterLongStop(0, false, 1, High[1] + 1 * TickSize, "trend" + c); formace1 = true; Print(Position.AvgPrice); }
if (breakeven_test == false && Position.MarketPosition == MarketPosition.Long && Close[0] >= Position.AvgPrice + (2 * (TickSize / 2))) { if ( ABC_trend != null && ABC_trend.StopPrice < Position.AvgPrice ) { exitStopLongTrend = ExitLongStop(0, true, 1, Position.AvgPrice , "SL_Trend", "trend" + c); breakeven_test = true; Print("Breakeven_test: " + breakeven_test + c); } }
if (ABC_trend != null && ABC_trend == execution.Order) { if (execution.Order.OrderState == OrderState.Filled) { exitStopLongTrend = ExitLongStop(0, true, 1, execution.Order.AvgFillPrice - 70 * TickSize , "SL_RH1_Trend" + c, "trend" + c); exitLimitLongTrend = ExitLongLimit(0, true, 1, execution.Order.AvgFillPrice + 70 * TickSize, "TP_RH1_Trend" + c, "trend" + c); if (execution.Order.OrderState != OrderState.Filled) { ABC_trend = null; } }
Thank you for support
Comment