Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bar Lookback?

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

    Bar Lookback?

    Hi guys, i want an indicator to calculate the amount of times a condition is true but only counting from 200 bars back till present, how do i do that?

    this is what i ve got

    if ( condition )
    {
    value++;
    }

    its missing the look-back, it must be really simple but beats me.

    Thanks in advance
    Last edited by kabott; 10-07-2014, 10:24 AM.

    #2
    Hello Kabott,

    Thank you for your post.

    You would want to use if(!Historical) and then start your check working backwards. This could be done with a FOR loop.

    Code:
    if(!Historical)
    {
         for(int i = 0; i < 200; i++)
         {
             if(condition)
                value++;
         }
    }
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by kabott View Post
      Hi guys, i want an indicator to calculate the amount of times a condition is true but only counting from 200 bars back till present, how do i do that?

      this is what i ve got

      if ( condition )
      {
      value++;
      }

      its missing the look-back, it must be really simple but beats me.

      Thanks in advance
      CountIf()?

      ref: http://www.ninjatrader.com/support/h...t7/countif.htm

      Comment


        #4
        Cal, i cant seem to find any related help on "!Historical"
        i would like to do the count-back in a different way than "CountIf()" thats why i was cheking Historical, although cant make it work and cant find any help on the "!Historical" method.

        Help pls

        Comment


          #5
          Kabott,

          Historical is a true or false property.

          When we check for !Historical it means we are checking when Historical is false, which only occurs once real time data starts taking over in the indicator.

          The check that either Koganam or myself have offered will do the trick. It will be a matter of which one you would want to use and performance of either one.

          http://www.ninjatrader.com/support/h...historical.htm
          Cal H.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          579 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          334 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          554 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          551 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X