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

Why won't this calculate?

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

    Why won't this calculate?

    Hi;

    I'm trying to make this work in MarketAnalyzer.

    I want to get the value of the 200sma 30 days ago.

    This won't calculate (just get all zeros):

    DfmLkBktoMA200.Set((SMA(Close, 200)[0] - SMA(Close, 200) [30]) / Close[0] * 100);

    But this does (so I think that says the problem is not somewhere else):

    DfmLkBktoMA200.Set((SMA(Close, 200)[0] - 1) / Close[0] * 100);


    Even when I put it in its own indicator it only displays zeros in Market Analyzer:

    Plot0.Set(SMA(Close, 200) [30]);

    Thanks
    Last edited by user721; 05-29-2011, 05:17 PM.

    #2
    never used market analyzer,

    but just some general ideas to try: I'm guessing that bar[30] of 200 day sma would need days loaded > 230?.. i'm sure you have more than that, right?



    Does
    DfmLkBktoMA200.Set((SMA(Close, 200)[5] - 1) / Close[0] * 100);
    work?


    DfmLkBktoMA200.Set((SMA(Close, 200)[1]); ?
    DfmLkBktoMA200.Set((SMA(Close, 200)[30]); ?




    Originally posted by user721 View Post
    Hi;

    I'm trying to make this work in MarketAnalyzer.

    I want to get the value of the 200sma 30 days ago.

    This won't calculate (just get all zeros):

    DfmLkBktoMA200.Set((SMA(Close, 200)[0] - SMA(Close, 200) [30]) / Close[0] * 100);

    But this does (so I think that says the problem is not somewhere else):

    DfmLkBktoMA200.Set((SMA(Close, 200)[0] - 1) / Close[0] * 100);

    Thanks

    Comment


      #3
      Thanks

      Yes I have 300 bars loaded and maximum bars set to infinite

      Comment


        #4
        Which one did you set to the 300 bars lookback, the general or indicator column one?

        Thanks,
        BertrandNinjaTrader Customer Service

        Comment


          #5
          I have set both to 1000. Still the same, no look back yields results but when I change it to look back 1, 10, or 30 days it just comes up all zeros. thanks

          Comment


            #6
            What happens if you try to chart this indicator then? Would the behavior be any different? Do you see any log errors in the Control Center?

            Thanks,
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Same behavior in a chart.

              Here is the error from the Log:

              Error on calling 'OnBarUpdate' method for indicator 'aazTest' on bar 0: You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.

              I tried loading 1000 bars in the Data Series but to no avail. thanks

              Comment


                #8
                You likely do not have defined a proper CurrentBars check for your script then :

                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  That fixed it! thank you very much!!!

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by judysamnt7, 03-13-2023, 09:11 AM
                  4 responses
                  55 views
                  0 likes
                  Last Post DynamicTest  
                  Started by ScottWalsh, Today, 06:52 PM
                  4 responses
                  35 views
                  0 likes
                  Last Post ScottWalsh  
                  Started by olisav57, Today, 07:39 PM
                  0 responses
                  7 views
                  0 likes
                  Last Post olisav57  
                  Started by trilliantrader, Today, 03:01 PM
                  2 responses
                  19 views
                  0 likes
                  Last Post helpwanted  
                  Started by cre8able, Today, 07:24 PM
                  0 responses
                  7 views
                  0 likes
                  Last Post cre8able  
                  Working...
                  X