Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

ExitShortStop

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

    ExitShortStop

    Dear Support

    i have strategy activating a ExitLongStopMarket.
    The order is put correctly however in the next bar update it gets cancelled.

    you can see in the screenshot attached

    this is my code below

    Code:
    if (StopLossSet == 0 && Position.GetUnrealizedProfitLoss(PerformanceUnit.P oints, Close[0]) > 0.25 && Close[0] >= EMA200[0])
    {
    Print("Position Hit EMA200, Set Exit Stop Market Order 0.25 above Average Price");
    ExitLongStopMarket((int)CalculationMode.Price, (Position.AveragePrice + 0.25));
    StopLossSet = 1;
    }
    Then When the market position is flat i reset the variable flag to 0 -> StopLossSet = 0;

    So this ExitLongStopMarket gets ran only one time, since what i want is to set it and let the price continue ging up or closing with 1 tick profit.
    but i dont know why is getting cancelled as soon as next bar is created.

    what am i doing wrong?

    Thanks
    Last edited by jimmy_NT; 05-19-2022, 11:38 PM.

    #2
    here is the screenshot

    Comment


      #3
      Hi jimmy_NT, thanks for posting. Use the advanced overload to keep resting orders alive:

      ExitLongStopMarket(int barsInProgressIndex, bool isLiveUntilCancelled, int quantity, double stopPrice, string signalName, string fromEntrySignal)

      This overload lets you keep the order alive. Other resting orders will be canceled on the close of every bar unless they are resubmitted each bar.

      Kind regards,
      -ChrisL
      Chris L.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by wzgy0920, 04-20-2024, 06:09 PM
      2 responses
      26 views
      0 likes
      Last Post wzgy0920  
      Started by wzgy0920, 02-22-2024, 01:11 AM
      5 responses
      32 views
      0 likes
      Last Post wzgy0920  
      Started by wzgy0920, Yesterday, 09:53 PM
      2 responses
      49 views
      0 likes
      Last Post wzgy0920  
      Started by Kensonprib, 04-28-2021, 10:11 AM
      5 responses
      192 views
      0 likes
      Last Post Hasadafa  
      Started by GussJ, 03-04-2020, 03:11 PM
      11 responses
      3,234 views
      0 likes
      Last Post xiinteractive  
      Working...
      X