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 DayTradingDEMON, Today, 09:28 AM
              1 response
              12 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by cmtjoancolmenero, Yesterday, 03:58 PM
              8 responses
              31 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by helpwanted, Today, 03:06 AM
              2 responses
              22 views
              0 likes
              Last Post NinjaTrader_LuisH  
              Started by navyguy06, Today, 09:28 AM
              0 responses
              5 views
              0 likes
              Last Post navyguy06  
              Started by rjbtrade1, 11-30-2023, 04:38 PM
              2 responses
              77 views
              0 likes
              Last Post DavidHP
              by DavidHP
               
              Working...
              X