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 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