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

Look back

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

    Look back

    Hey all,

    I'm a bit confused as how to do a look back for a period of bars.

    example; say I want to make a plot cycle code,

    if current high is > the Highest high (10 bars back) and down close
    {drawdots}

    How do I reference this in C# to look back at the last 10 bars?

    Thanks in advance.

    #2
    MAX(High, 10)[0] <-- returns the highest high value from the last 10 bars
    MAX(High, 10)[10] <-- returns the highest high value from the 10 bars prior to 10 bars ago.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Make perfect sense. Thanks Josh.

      Comment


        #4
        Code works fine when I state if(Open[0] > Close[0])
        but when I put in the MAX(high,5)[0] nothing plots. I'm confused as to why this does not work out.

        Code:
         {
        	if (High[0]> MAX(High, 5)[0] && Open[0] > Close[0])
        	   {
        		
         DrawDot("My dot" + CurrentBar, true, 0, High[0] + TickSize, Color.Yellow);
                    }
                }

        Comment


          #5
          The current bar High will never be greater than the current bar High, hence no plot. But it can be equal to it.

          Try

          if (High[0]>= MAX(High, 5)[0] && Open[0] > Close[0])

          so High is = to highest high of the bar

          Comment


            #6
            Thanks Velocity

            Works perfect, Just wondering why this statement wouldn't work as well?

            if (High[0]> MAX(High, 5)[1] && Open[0] > Close[0])

            Comment


              #7
              Technically it should work, but if you are going to use an [1] index please be sure that you have enough bars. http://www.ninjatrader-support2.com/...ead.php?t=3170
              Josh P.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Balage0922, Today, 07:38 AM
              0 responses
              1 view
              0 likes
              Last Post Balage0922  
              Started by JoMoon2024, Today, 06:56 AM
              0 responses
              6 views
              0 likes
              Last Post JoMoon2024  
              Started by Haiasi, 04-25-2024, 06:53 PM
              2 responses
              19 views
              0 likes
              Last Post Massinisa  
              Started by Creamers, Today, 05:32 AM
              0 responses
              6 views
              0 likes
              Last Post Creamers  
              Started by Segwin, 05-07-2018, 02:15 PM
              12 responses
              1,786 views
              0 likes
              Last Post Leafcutter  
              Working...
              X