Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to set stoploss to previous bar

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

    How to set stoploss to previous bar

    Hi,
    I would like to know how can I configure my stop loss to be at the previous bar high or low within strategy analyzer.
    If I enter short, stop loss will be at the previous bar high and if I enter long, stop loss at previous bar low.

    I don't see any option to do this at the Stop Loss and Profit Targets window within strategy analyzer Wizard.

    Thanks,
    JR

    #2
    Originally posted by john_robertson00 View Post
    Hi,
    I would like to know how can I configure my stop loss to be at the previous bar high or low within strategy analyzer.
    If I enter short, stop loss will be at the previous bar high and if I enter long, stop loss at previous bar low.

    I don't see any option to do this at the Stop Loss and Profit Targets window within strategy analyzer Wizard.

    Thanks,
    JR
    You will have to unlock your Strategy code, and code that in manually.

    Comment


      #3
      Do you have any ideas on how to code that?
      Any hints is appreciated. Thx.

      Comment


        #4
        John, you could do for example something along those lines here :

        if (CrossAbove(Close, HMA(High, 21), 1))
        {
        EnterLong(DefaultQuantity, "");
        }

        if (Position.MarketPosition == MarketPosition.Long)
        {
        SetStopLoss(CalculationMode.Price, Low[1] - TickSize);
        DrawDot("stoptag1" + CurrentBar, true, 0, Low[1] - TickSize, Color.BlueViolet);
        }

        Comment


          #5
          Originally posted by NinjaTrader_Bertrand View Post
          John, you could do for example something along those lines here :

          if (CrossAbove(Close, HMA(High, 21), 1))
          {
          EnterLong(DefaultQuantity, "");
          }

          if (Position.MarketPosition == MarketPosition.Long)
          {
          SetStopLoss(CalculationMode.Price, Low[1] - TickSize);
          DrawDot("stoptag1" + CurrentBar, true, 0, Low[1] - TickSize, Color.BlueViolet);
          }
          Bertrand, I'd also love to set this up but I jhave no experience in programming, is there a downloadable add on that could do this or could one be written. Yours hopefully, Mark

          Comment


            #6
            Mark, thanks for the post - this part would need to be created in custom coding in the NinjaScript editor - if you're not a programmer and not looking to pick this up, I would suggest contacting a certified consultant that could create this code then for you and work other desired modifications into it as well - here's a list of all certified ones :

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by CarlTrading, 03-31-2026, 09:41 PM
            1 response
            68 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 04-01-2026, 02:41 AM
            0 responses
            39 views
            0 likes
            Last Post CarlTrading  
            Started by CaptainJack, 03-31-2026, 11:44 PM
            0 responses
            63 views
            1 like
            Last Post CaptainJack  
            Started by CarlTrading, 03-30-2026, 11:51 AM
            0 responses
            62 views
            0 likes
            Last Post CarlTrading  
            Started by CarlTrading, 03-30-2026, 11:48 AM
            0 responses
            53 views
            0 likes
            Last Post CarlTrading  
            Working...
            X