Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multiple Series Immediately Closes after Opening Position

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

    Multiple Series Immediately Closes after Opening Position

    I am running a strategy on the NQ futures chart and placing the trades on the MNQ(chart).

    I would like to be able to adjust the Profit Target and Stop Loss similar to entering an ATM order from the chart trader where you can drag the profit and stop on the chart.

    I was able to accomplish this if I run a strategy on the primary chart by following the example from a previous post on exit methods and the ExitMethodsSample strategy (attached).


    When I try to use the same exit method using MNQ as the secondary the position immediately closes after opening. Aside from referencing the secondary series the code is the same.

    AddDataSeries(Data.BarsPeriodType.Tick, 1);
    AddDataSeries("MNQ 03-21", Data.BarsPeriodType.Tick, 1, Data.MarketDataType.Last);

    If (Entry Logic True)

    EnterLong(2,Convert.ToInt32(Contracts), Convert.ToString(EntryNameTrevDtv));
    PositionOpen = true;

    **

    Exit Logic

    if (Positions[2].MarketPosition == MarketPosition.Long && PositionOpen == true)
    {
    ExitLongStopMarket(2, true, Position.Quantity, Position.AveragePrice - StopLoss * TickSize, "Stop Loss","");
    ExitLongLimit(2, true, Position.Quantity, Position.AveragePrice + ProfitTarget * TickSize, "Profit Target", "");
    PositionOpen = false;
    }

    However if I use SetProfitTarget and SetStopLoss the position does not close immediately and the target and stop appear on the MNQ (secondary) chart.

    //SetProfitTarget(Convert.ToString(""), CalculationMode.Ticks, ProfitTarget);
    //SetStopLoss(Convert.ToString(""), CalculationMode.Ticks, StopLoss, false);


    Any help with this is appreciated.


    Attached Files

    #2
    Hello sdauteuil, thanks for writing in.

    Could you please post your modification of the original script so I can test on my end? The IsLiveUntilCanceled parameter is true, so I would expect the orders to stay alive after subsequent bars.

    I look forward to hearing from you.

    Comment


      #3
      Thanks

      I got it to work. I was missing the reference to the MNQ series in the exit code.

      ExitLongLimit(2, true, Positions[2].Quantity, Positions[2].AveragePrice + ProfitTarget * TickSize, "Profit Target", "");

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Today, 05:17 AM
      0 responses
      50 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      126 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      69 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      42 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      46 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X