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

How to say IF current price is higher than price since last X bars?

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

    How to say IF current price is higher than price since last X bars?

    Hi,


    Hopefully the title is pretty self explanatory. Trying to avoid taking trades in ranging conditions because it doesn't help the strat.

    Thanks

    #2
    Originally posted by demo166130 View Post
    Hopefully the title is pretty self explanatory.
    Actually, no.

    "higher than price of last X bars"

    Do you mean the highest High price of last X bars?
    Or the highest Close price of last X bars?

    Comment


      #3
      Thanks for your inquiry demo166130,

      HighestBar could be used to determine if the current price is the highest of the last X number of bars and can take any price series as input (Open, High, Low, Close.)

      HighestBar(Close, 4) would tell you how many bars ago the highest Close value was in the last 4 bars.

      if(HighestBar(Close, 4) == 0) would tell you that the current Close is the highest value from 4 bars ago.

      HighestBar() - https://ninjatrader.com/support/help...highestbar.htm

      HighestBar can be used in the Strategy Wizard in a Condition Builder under Misc > Highest bar.

      Please let us know if we can be of further assistance.
      JimNinjaTrader Customer Service

      Comment


        #4
        Originally posted by bltdavid View Post

        Actually, no.

        "higher than price of last X bars"

        Do you mean the highest High price of last X bars?
        Or the highest Close price of last X bars?
        Both. I mean I'm trying to ask IF current price is higher than the price of the last X number of bars, whether that be close or highest high. Where X exists I would define a value, obviously. Trying to avoid using C# where possible.

        Comment


          #5
          Originally posted by NinjaTrader_Jim View Post
          Thanks for your inquiry demo166130,

          HighestBar could be used to determine if the current price is the highest of the last X number of bars and can take any price series as input (Open, High, Low, Close.)

          HighestBar(Close, 4) would tell you how many bars ago the highest Close value was in the last 4 bars.

          if(HighestBar(Close, 4) == 0) would tell you that the current Close is the highest value from 4 bars ago.

          HighestBar() - https://ninjatrader.com/support/help...highestbar.htm

          HighestBar can be used in the Strategy Wizard in a Condition Builder under Misc > Highest bar.

          Please let us know if we can be of further assistance.
          Many thanks. That goes pretty much all the way to explaining.

          Peace, but never with truth as a compromise.

          Comment


            #6
            Having tried to do this using the Wizard I'm not entirely clear how it works. Lets say we want to make a stipulation for entering a trade 'If the current bar close is greater than the highs of the last X bars', is it the Period on the left or the Bars ago on the right that would define how many bars ago we're looking back?

            So on the left you have Misc > Lowest Bar ***Which values here**** 'less than' Price Data > 'Low' ****Which values here??***

            Comment


              #7
              And is 'if(HighestBar(Close, 4) == 0)' saying If since the last 4 bars the current close is highest?

              Comment


                #8
                Hello demo166130,

                Thanks for the reply.

                The BarsAgo property is the value that your script is going to read. If you specified 1 for the BarsAgo, then it would evaluate the Low of the bar 1 bar ago.

                If 'if(HighestBar(Close, 4) == 0)', that would mean the highest bar is the current close.

                Please let me know if I can assist further.
                Chris L.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by sidlercom80, 10-28-2023, 08:49 AM
                167 responses
                2,260 views
                0 likes
                Last Post jeronymite  
                Started by warreng86, 11-10-2020, 02:04 PM
                7 responses
                1,361 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Started by Perr0Grande, Today, 08:16 PM
                0 responses
                5 views
                0 likes
                Last Post Perr0Grande  
                Started by elderan, Today, 08:03 PM
                0 responses
                9 views
                0 likes
                Last Post elderan
                by elderan
                 
                Started by algospoke, Today, 06:40 PM
                0 responses
                10 views
                0 likes
                Last Post algospoke  
                Working...
                X