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 Hwop38, 05-04-2026, 07:02 PM
          0 responses
          161 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Started by CaptainJack, 04-24-2026, 11:07 PM
          0 responses
          310 views
          0 likes
          Last Post CaptainJack  
          Started by Mindset, 04-21-2026, 06:46 AM
          0 responses
          245 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by M4ndoo, 04-20-2026, 05:21 PM
          0 responses
          349 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by M4ndoo, 04-19-2026, 05:54 PM
          0 responses
          179 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Working...
          X