Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

What to add for a multiple of ATR in BarArray and double checking what to compare.

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

    What to add for a multiple of ATR in BarArray and double checking what to compare.

    Hi folks:

    What would I add to this to make it a multiple (i.e. 2 times the atr) of ATR with a BarArray on daily?

    Code:
    		protected override void Initialize()
                          Add(PeriodType.Day, 1); 
    
                    protected override void OnBarUpdate()
                          if (Close[0] > ATR (BarsArray[1], 14)
    Also, should I use "Close" or something else to compare the ATR with to make it work correctly? I basically would like the current day's range with the BarArray's ATR from daily bars. I have a feeling I should use something other that "Close".



    Greg

    #2
    Hello Greg,

    Thank you for your post.

    I do not fully understand your inquiry. Are you trying to check the ATR's High and Low for the day? Where are you comparing the 2 times ATR value of the day? What value do you want to compare it against?

    I look forward to your response.

    Comment


      #3
      Patrick...

      Hi...

      Yea...current days range at each bar close of the primary data series with the average true rage of the last 14 days per the barsarray series...

      is that better?

      I am mobile fyi...smile...

      Greg

      Comment


        #4
        Hello Greg,

        Thank you for your response.

        So compare the ATR against the High and Low of the day at close?

        Comment


          #5
          Compare the current day's range against the ATR (from bararray).

          Comment


            #6
            Hi birdog,

            To get the current range of the day:

            double daysRange = CurrentDayOHL().CurrentHigh[0] - CurrentDayOHL().CurrentLow[0];

            then:

            if (daysRange > ATR (BarsArray[1], 14)[0])
            {
            // do something
            }
            Paul H.NinjaTrader Customer Service

            Comment


              #7
              How would it be written to do:

              If the current days range is greater that 1.5 times the ATR's BarsArray from the last 14 days?

              Also, I could not get the "double" value to compile (what section does that go)?

              Comment


                #8
                Hi Greg,

                Thanks for your question.

                I have changed the code below so that the days range must exceed the 14 day ATR * 1.5.

                The code compiles as is without errors and can be placed below OnBarUpdate()

                Code:
                [COLOR="RoyalBlue"]double[/COLOR] daysrange = CurrentDayOHL().CurrentHigh[0] - CurrentDayOHL().CurrentLow[0];
                
                if (daysrange > (ATR (BarsArray[1], 14)[0])*1.5)
                {
                [COLOR="SeaGreen"]// Do something here[/COLOR]
                }
                Please let me know if I can be of further assistance.
                Paul H.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by slightly, Today, 12:49 AM
                0 responses
                2 views
                0 likes
                Last Post slightly  
                Started by sdauteuil, 09-23-2021, 10:16 AM
                4 responses
                1,208 views
                0 likes
                Last Post jacobpescaia44  
                Started by agclub, 04-21-2024, 08:57 PM
                5 responses
                34 views
                0 likes
                Last Post agclub
                by agclub
                 
                Started by ESHunter, Yesterday, 08:06 PM
                2 responses
                18 views
                0 likes
                Last Post ESHunter  
                Started by ETFVoyageur, 05-07-2024, 07:05 PM
                19 responses
                151 views
                0 likes
                Last Post ETFVoyageur  
                Working...
                X