Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ATR Profit Target

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

    #31
    You could then simply change the barcolor if the target / stop loss activation triggers via your code. You would then have a visual market once this process starts to kick in.

    Comment


      #32
      Good idea. thanks for all your help

      Comment


        #33
        Originally posted by NinjaTrader_Bertrand View Post
        You could then simply change the barcolor if the target / stop loss activation triggers via your code. You would then have a visual market once this process starts to kick in.
        Stupid question. Can i get it to print just the first bar that the target is hit on? It colors all bars after as well, as it is performing the colorbar calc for each new bar close.
        Code:
         
         
        // If a long position is open, allow for stop loss modification 
        else if (Position.MarketPosition == MarketPosition.Long)
        {
        // Once the price is greater than entry price+3*ATR, set stop loss to recent bar close - 1.5ATR
        if (Close[0] > Position.AvgPrice + (ATR(14)[0]) * atrtargetx)
        { BarColorSeries[0] = Color.Blue;}
        {SetStopLoss(CalculationMode.Price, Close[0] - (ATR(14)[0] * atrstopx)); 
        }

        Comment


          #34
          You could either work with bool flags, or separate the codes for stop loss adjustment and trigger visualization. If you check for a Cross above the price for example for the visuals, you would get only one bar painted.

          Comment


            #35
            Yup CrossAbove did it. Only thing is when it crosses back below and then up through again, it prints another blue bar, but no big deal.

            Comment


              #36
              Right...then you could combine that with a bool flag you reset once the position flat, that means it will 'guard' you against a recoloring for the time you're in the trade as desired.

              Comment


                #37
                Originally posted by NinjaTrader_Bertrand View Post
                Right...then you could combine that with a bool flag you reset once the position flat, that means it will 'guard' you against a recoloring for the time you're in the trade as desired.
                Finally figured out how to code the bool flag in. Perfect! thanks

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                656 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                371 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                109 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                574 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                579 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X