Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Is it possible to set the period of an indicator?

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

    Is it possible to set the period of an indicator?

    I basically want to have an indicator that is set on a 2 minute basis on a chart. I want to get the value of that indicator only on the open of each 2 minute interval.

    When I add indicators like SMA in script, I don't see a parameter for setting the period of which I want the values to be based on. Am I missing something or is it by default going to calculate the SMA tick by tick?

    BarUpdate does fire every single tick right? I think I need a way to have it fire only every 2 minutes, or more importantly, to get the value of the SMA only every 2 minutes.

    Is this possible?

    #2
    If you want SMA on every new bar on a 2 min basis throw the indicator on a 2min chart and set CalculateOnBarClose to true. If it is false it will calculate every tick otherwise it will calculate once at every bar close (aka new bar open).

    If you need this on a different than 2min chart you can do it in a strategy via multi-time framed techniques. Multi-time framed indicators are not currently available, but will be in NT7 though.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Thanks that did the trick! The only problem is I am wondering how long does it take for the MACD to start painting on the chart? It seems that on a 10 minute chart it takes quite a few bars. Sometimes I switch to 1 minute and see it, then switch back and it starts painting. it's almost as if there is a bug and it won't paint until I switch the period. Of course doing that with a strategy linked chart will stop the first strategy and start another.

      Am I missing something?

      Comment


        #4
        MACD will start painting when it decides it has enough historical bars to run its calculations. This is dependent on your setting for the MACD. You can check out its code to fully understand how much it needs.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Thanks for that explanation. Actually that raises a good question. How can I programatically determine when the MACD has actually started to paint or provide a real value? If I query the values prior to it being ready I am going to get some skewed numbers.

          Comment


            #6
            Are you trying to access it from a Strategy? If that is the case you can set a property called BarsRequired in the Initialize() method. Set it large enough so all your indicators will have enough bars before it starts calculating. The default setting is 20. This way you don't have to worry about programming your own checks.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Josh View Post
              Are you trying to access it from a Strategy? If that is the case you can set a property called BarsRequired in the Initialize() method. Set it large enough so all your indicators will have enough bars before it starts calculating. The default setting is 20. This way you don't have to worry about programming your own checks.
              That's good to know. I had wondered what was controlling that 20-bar blank space on my charts. I got irritated by this, so eventually I discovered that you can display indicator plots in this 20-bar space if you open your chart properties and set it to show the "unstable region" of the indicators. I now find this useful for debugging if I have written a complicated indicator that doesn't initialize properly.

              -Alex

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by condorhero, Today, 09:28 PM
              0 responses
              5 views
              0 likes
              Last Post condorhero  
              Started by MaraAnkh, Today, 08:44 PM
              0 responses
              6 views
              0 likes
              Last Post MaraAnkh  
              Started by wooofad, Today, 05:38 PM
              0 responses
              7 views
              0 likes
              Last Post wooofad
              by wooofad
               
              Started by caacapital, Today, 10:10 AM
              2 responses
              18 views
              0 likes
              Last Post caacapital  
              Started by DiverG20, Today, 10:23 AM
              0 responses
              23 views
              0 likes
              Last Post DiverG20  
              Working...
              X