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);
        }
        BertrandNinjaTrader Customer Service

        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 :

            BertrandNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by pechtri, 06-22-2023, 02:31 AM
            9 responses
            122 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by frankthearm, 04-18-2024, 09:08 AM
            16 responses
            67 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Started by habeebft, Today, 01:18 PM
            1 response
            7 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by benmarkal, Today, 12:52 PM
            2 responses
            18 views
            0 likes
            Last Post benmarkal  
            Started by f.saeidi, Today, 01:38 PM
            1 response
            10 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Working...
            X