• 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

Moving average is 0

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

    Moving average is 0

    Hey guys, I have a moving average/SMA that is showing as 0 instead of the real value:

    What could be causing this?

    Its SMA(Medians[2], mAPeriod)[0]

    mAPeriod is 32, I am loading 60 days of data into memory and Medians series 2 is a daily data series. How can I be sure that I have enough data loaded to create the SMA?

    It shows as 0 in realtime but, the backtest seems to work fine.

    Thanks,
    EliteTraderNYC

    #2
    Hello EliteTraderNYC,

    Thank you for your post.

    Can you please post the code that you are using for setting this SMA?

    Additionally, please check your log tab for any errors
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Hi, I created a strategy just for test, it is a betterrenko tick as primary series, I activated it with 100 days of data, the only 2 statements in the strategy are:

      Print("SMA closes: " + SMA(Closes[2], mAPeriod)[0] + " " + Closes[2][0]);
      Print("SMA medians: " + SMA(Medians[2], mAPeriod)[0] + " " + Closes[2][0]);

      But I do have like 5 data series in the strategy, and both print statements for SMA show as 0, however Closes[2][0] shows the correct value, any ideas why? i just activated it.

      Comment


        #4
        Hi guys I just found out, now the SMA is loading into memory and displaying on the screen, but it took until after 930am! It only appears to load when the session for that instrument is open.

        Comment


          #5
          Hi, guys one other question, the instrument mentioned below starts trading at 930am but I need the SMA daily average value before 930am, because the primary instrument in the strategy trades 24/7 and may make trades before 930, how do I get a value thats not 0?

          Comment


            #6
            Can you attach the full script that you are working with and is this just a stock you are testing?
            Cal H.NinjaTrader Customer Service

            Comment


              #7
              Hi NT staff, the solution for the above problem is to create your own SMA since the function does not work before the 930 open on the NYSE. The series data itself is available.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Da vinci, Today, 04:19 PM
              0 responses
              5 views
              0 likes
              Last Post Da vinci  
              Started by brunoviveiros, Today, 09:36 AM
              1 response
              19 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Started by GARZONJ, Today, 11:22 AM
              1 response
              10 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by KonalGondal, Today, 10:18 AM
              1 response
              19 views
              0 likes
              Last Post NinjaTrader_Kate  
              Started by Jorge.andres.o, Today, 09:24 AM
              4 responses
              23 views
              0 likes
              Last Post NinjaTrader_PaulH  
              Working...
              X