Announcement

Collapse
No announcement yet.

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,

        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,

            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 :

                Comment


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

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by cmoran13, 04-16-2026, 01:02 PM
                  0 responses
                  43 views
                  0 likes
                  Last Post cmoran13  
                  Started by PaulMohn, 04-10-2026, 11:11 AM
                  0 responses
                  25 views
                  0 likes
                  Last Post PaulMohn  
                  Started by CarlTrading, 03-31-2026, 09:41 PM
                  1 response
                  163 views
                  1 like
                  Last Post NinjaTrader_ChelseaB  
                  Started by CarlTrading, 04-01-2026, 02:41 AM
                  0 responses
                  98 views
                  1 like
                  Last Post CarlTrading  
                  Started by CaptainJack, 03-31-2026, 11:44 PM
                  0 responses
                  158 views
                  2 likes
                  Last Post CaptainJack  
                  Working...
                  X