• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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 SAITON, Today, 09:03 PM
          0 responses
          1 view
          0 likes
          Last Post SAITON
          by SAITON
           
          Started by suprsnipes, Today, 08:26 PM
          0 responses
          5 views
          0 likes
          Last Post suprsnipes  
          Started by RobertoPaez, Today, 06:47 PM
          0 responses
          7 views
          0 likes
          Last Post RobertoPaez  
          Started by catinabag, Today, 06:45 PM
          0 responses
          4 views
          0 likes
          Last Post catinabag  
          Started by darkgreen, Today, 03:35 PM
          0 responses
          9 views
          0 likes
          Last Post darkgreen  
          Working...
          X