Announcement

Collapse
No announcement yet.

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 CaptainJack, 05-29-2026, 05:09 AM
          0 responses
          51 views
          0 likes
          Last Post CaptainJack  
          Started by CaptainJack, 05-29-2026, 12:02 AM
          0 responses
          30 views
          0 likes
          Last Post CaptainJack  
          Started by charlesugo_1, 05-26-2026, 05:03 PM
          0 responses
          99 views
          0 likes
          Last Post charlesugo_1  
          Started by DannyP96, 05-18-2026, 02:38 PM
          1 response
          177 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          170 views
          0 likes
          Last Post CarlTrading  
          Working...
          X