I have a strategy that I built with the builder and the compiled to be able to make manual modifications...
However the problem is that the the long and short orders cancel each other out. So while a long position is open, a short position gets opened, canceling the long position. What I'd like is for each trade to COMPLETE in line with the TP and SL conditions.
Any suggestion please? I've tried using the unrealized profit loss criterion but it's completely ignored. This is really weird and usually I don't have that issue, so maybe I messed up something
Thanks!
Calculate = Calculate.OnEachTick; EntriesPerDirection = 1; EntryHandling = EntryHandling.AllEntries; IsExitOnSessionCloseStrategy = true; ExitOnSessionCloseSeconds = 30; IsFillLimitOnTouch = false; MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix; OrderFillResolution = OrderFillResolution.Standard; Slippage = 0; StartBehavior = StartBehavior.WaitUntilFlat; TimeInForce = TimeInForce.Gtc; TraceOrders = true; RealtimeErrorHandling = RealtimeErrorHandling.IgnoreAllErrors; StopTargetHandling = StopTargetHandling.PerEntryExecution; BarsRequiredToTrade = 20;
protected override void OnBarUpdate() { if (BarsInProgress != 0) return; if (State == State.Historical) return; if (CurrentBars[0] < 1) return; // Set 1 if ((CrossAbove(RelativeVigorIndex1.Default, RelativeVigorIndex2.Signal, 1)) && BarsSinceExitExecution() > 2 || BarsSinceExitExecution() == -1 && (Position.GetUnrealizedProfitLoss(PerformanceUnit. Currency, Close[0]) == 0) // TradingHours && (Times[0][0].TimeOfDay <= new TimeSpan(20, 0, 0) && (Times[0][0].TimeOfDay >= new TimeSpan(2, 0, 0)) && (GetCurrentAsk(0) > SMA1[0]))) { EnterLong(Convert.ToInt32(DefaultQuantity), @"golong"); } // Set 2 if ((CrossBelow(RelativeVigorIndex3.Default, RelativeVigorIndex4.Signal, 1)) && BarsSinceExitExecution() > 2 || BarsSinceExitExecution() == -1 && (Position.GetUnrealizedProfitLoss(PerformanceUnit. Currency, Close[0]) == 0) // TradingHours && (Times[0][0].TimeOfDay <= new TimeSpan(20, 0, 0) && (Times[0][0].TimeOfDay >= new TimeSpan(2, 0, 0)) && (GetCurrentAsk(0) < SMA2[0]))) { EnterShort(Convert.ToInt32(DefaultQuantity), @"goshort"); } }
Comment