Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Trailing Stop problem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Trailing Stop problem

    I enter 2 positions for each direction when my strategy give me a signal: ShortTIa and ShortTIb, LongTIa and LongTIb. I then set a target for ShortTIa and LongTIa at 30 cents and a target for ShortTIb and LongTIb for 60 cents. I have different trailing stop for each order (4 in total). However, whenever I backtest this strategy, it only execute the LongTIa and ShortTIa orders. Here is my code:

    Add(EMA(EMASlow));
    Add(EMA(EMAFast));
    Add(ADX(14));
    Add(ADX(14));
    Add(EMA(EMASlow));
    Add(EMA(EMAFast));
    Add(ADX(14));
    Add(ADX(14));
    SetTrailStop("LongTIa", CalculationMode.Ticks, TrailStopV, true);
    SetTrailStop("LongTIb", CalculationMode.Ticks, TrailStopV, true);
    SetProfitTarget("LongTIa", CalculationMode.Ticks, TargetV_a);
    SetProfitTarget("ShortTIa", CalculationMode.Ticks, TargetV_a);
    SetProfitTarget("LongTIb", CalculationMode.Ticks, TargetV_b);
    SetProfitTarget("ShortTIb", CalculationMode.Ticks, TargetV_b);
    SetTrailStop("ShortTIa", CalculationMode.Ticks, TrailStopV, false);
    SetTrailStop("ShortTIb", CalculationMode.Ticks, TrailStopV, false);

    CalculateOnBarClose = true;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // Condition set 1
    if (CrossAbove(EMA(EMASlow), EMA(EMAFast), 1)
    && ADX(14)[0] > ADX(14)[1]
    && ADX(14)[0] > 20)
    {
    EnterLong(100, "LongTIa");
    EnterLong(100, "LongTIb");
    }

    // Condition set 2
    if (CrossBelow(EMA(EMASlow), EMA(EMAFast), 1)
    && ADX(14)[0] > ADX(14)[1]
    && ADX(14)[0] > 20)
    {
    EnterShort(100, "ShortTIa");
    EnterShort(100, "ShortTIb");
    }
    }

    #region Properties
    [Description("EMA Fast")]
    [Category("Parameters")]
    public int EMAFast
    {
    get { return eMAFast; }
    set { eMAFast = Math.Max(1, value); }
    }

    [Description("EMA Slow")]
    [Category("Parameters")]
    public int EMASlow
    {
    get { return eMASlow; }
    set { eMASlow = Math.Max(1, value); }
    }

    [Description("AdxPedriod")]
    [Category("Parameters")]
    public int AdxPedriod
    {
    get { return adxPedriod; }
    set { adxPedriod = Math.Max(1, value); }
    }

    [Description("TrailStopV")]
    [Category("Parameters")]
    public int TrailStopV
    {
    get { return trailStopV; }
    set { trailStopV = Math.Max(1, value); }
    }

    [Description("StartingTime")]
    [Category("Parameters")]
    public int StartingTime
    {
    get { return startingTime; }
    set { startingTime = Math.Max(1, value); }
    }

    [Description("TargetV_a")]
    [Category("Parameters")]
    public int TargetV_a
    {
    get { return targetV_a; }
    set { targetV_a = Math.Max(1, value); }
    }

    [Description("TargetV_b")]
    [Category("Parameters")]
    public int TargetV_b
    {
    get { return targetV_b; }
    set { targetV_b = Math.Max(1, value); }
    }
    #endregion
    }
    }


    Can you guys tell my what is wrong and how to fix it?

    #2
    Your EnterLong will cancel or close your short Order and visa-versa.

    Comment


      #3
      Found the problem:
      I have to add this
      EntriesPerDirection = 2;

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      574 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      332 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      553 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      551 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X