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 tsantospinto, 04-12-2024, 07:04 PM
          6 responses
          98 views
          0 likes
          Last Post tsantospinto  
          Started by rocketman7, Today, 02:12 AM
          5 responses
          25 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by ZenCortexReal, Today, 08:54 AM
          0 responses
          1 view
          0 likes
          Last Post ZenCortexReal  
          Started by ZenCortexReal, Today, 08:52 AM
          0 responses
          0 views
          0 likes
          Last Post ZenCortexReal  
          Started by trilliantrader, 04-18-2024, 08:16 AM
          7 responses
          28 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Working...
          X