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 Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  579 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  334 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  101 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  554 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  551 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X