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 CaptainJack, 04-24-2026, 11:07 PM
            0 responses
            24 views
            0 likes
            Last Post CaptainJack  
            Started by Mindset, 04-21-2026, 06:46 AM
            0 responses
            122 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by M4ndoo, 04-20-2026, 05:21 PM
            0 responses
            179 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by M4ndoo, 04-19-2026, 05:54 PM
            0 responses
            93 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by cmoran13, 04-16-2026, 01:02 PM
            0 responses
            136 views
            0 likes
            Last Post cmoran13  
            Working...
            X