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

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 hazylizard, Today, 08:38 AM
          2 responses
          8 views
          0 likes
          Last Post hazylizard  
          Started by geddyisodin, Today, 05:20 AM
          2 responses
          18 views
          0 likes
          Last Post geddyisodin  
          Started by Max238, Today, 01:28 AM
          5 responses
          47 views
          0 likes
          Last Post Max238
          by Max238
           
          Started by giulyko00, Yesterday, 12:03 PM
          3 responses
          13 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by habeebft, Today, 07:27 AM
          1 response
          16 views
          0 likes
          Last Post NinjaTrader_ChristopherS  
          Working...
          X