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

Test for Rising value over x bars ago

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

    Test for Rising value over x bars ago

    Can someone help me with the code on how to test if a value has risen on any of 'x' bars ago?

    the internal Rising() feature only works on 1 bar ago. I need the same test, but with further back like 50 bars...

    I know it's something like this, but not quite...

    while x < 50 // 50 bars ago
    do
    {
    if Value[x] > Value[x-1] rising = true;
    x++;
    }

    TIA
    Mike

    #2
    try using the slope function if it is positive it's rising and negative if it is falling.

    Comment


      #3
      Should be "x + 1" not "x - 1"
      RayNinjaTrader Customer Service

      Comment


        #4
        Thanks, I will try the slope method.

        I need it to be usable in a long laundry list of if statements, so the while loop doesn't work as nested inside an if statement, would have to re-do my strategy logic.

        I don't know much about slope, but will go learn about it.

        Comment


          #5
          Originally posted by NinjaTrader_Ray View Post
          Should be "x + 1" not "x - 1"
          Oops

          thx
          Mike

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by terofs, Yesterday, 04:18 PM
          1 response
          21 views
          0 likes
          Last Post terofs
          by terofs
           
          Started by CommonWhale, Today, 09:55 AM
          1 response
          3 views
          0 likes
          Last Post NinjaTrader_Erick  
          Started by Gerik, Today, 09:40 AM
          2 responses
          7 views
          0 likes
          Last Post Gerik
          by Gerik
           
          Started by RookieTrader, Today, 09:37 AM
          2 responses
          12 views
          0 likes
          Last Post RookieTrader  
          Started by alifarahani, Today, 09:40 AM
          1 response
          7 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Working...
          X