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

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 bmartz, 03-12-2024, 06:12 AM
              5 responses
              32 views
              0 likes
              Last Post NinjaTrader_Zachary  
              Started by Aviram Y, Today, 05:29 AM
              4 responses
              13 views
              0 likes
              Last Post Aviram Y  
              Started by algospoke, 04-17-2024, 06:40 PM
              3 responses
              28 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by gentlebenthebear, Today, 01:30 AM
              1 response
              8 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by cls71, Today, 04:45 AM
              1 response
              8 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Working...
              X