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

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 warreng86, 11-10-2020, 02:04 PM
              6 responses
              1,357 views
              0 likes
              Last Post mathewlo  
              Started by Perr0Grande, Today, 08:16 PM
              0 responses
              3 views
              0 likes
              Last Post Perr0Grande  
              Started by elderan, Today, 08:03 PM
              0 responses
              5 views
              0 likes
              Last Post elderan
              by elderan
               
              Started by algospoke, Today, 06:40 PM
              0 responses
              10 views
              0 likes
              Last Post algospoke  
              Started by maybeimnotrader, Today, 05:46 PM
              0 responses
              12 views
              0 likes
              Last Post maybeimnotrader  
              Working...
              X