Announcement

Collapse
No announcement yet.

horizontal moving average

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

  • horizontal moving average

    I saw this question asked a few months ago and never saw it receive an answer so I will ask it again.

    Is there a way to plot a daily moving average such as the 50 day MA as a horizontal line on an intraday or daily chart?

    Thanks in advance for your reply

  • #2
    Re: horizontal moving average

    ralex
    I believe the post you are referring to was answered (see here)
    Alex


    Originally posted by ralex
    I saw this question asked a few months ago and never saw it receive an answer so I will ask it again.

    Is there a way to plot a daily moving average such as the 50 day MA as a horizontal line on an intraday or daily chart?

    Thanks in advance for your reply

    Comment


    • #3
      horizontal moving average

      thank you for your reply.

      I did see that attachment and tried it but it does not exactly accomplish what I am looking for -- let me clarify

      I am looking for a complete horizontal line rather than a jagged one the updates throughout the day. So maybe I guess I should have asked if there is a way to plot the moving average as a constant number based on its value on the previous day's close. That, i think, will give me just one, stable line that is not updated intraday.

      Thanks for any reply

      Comment


      • #4
        horizontal moving average

        hello again Alexis

        also, regarding the attachment you referenced, I do see how you "set" this to show, say the 50 day MA, on the intraday chart.

        I go to edit studies and set the MA to 50 but it seems to be plotting a period other than the daily MA because the numbers on the intraday chart don't match up with the real 50 day moving average.

        THANKS

        Comment


        • #5
          Re: horizontal moving average

          ralex
          You can do that using the addBand() function to which you pass the value of the average based on the daily interval offset forward by 1 so as to use the prior day's value. A basic example would be
          var myDailyAvg = sma(myLength, inv("d"));
          addBand(myDailyAvg.getValue(-1), PS_SOLID, 1, Color.blue, "line");

          This will draw a line across the entire chart at the value of the daily average
          Alex


          Originally posted by ralex
          thank you for your reply.

          I did see that attachment and tried it but it does not exactly accomplish what I am looking for -- let me clarify

          I am looking for a complete horizontal line rather than a jagged one the updates throughout the day. So maybe I guess I should have asked if there is a way to plot the moving average as a constant number based on its value on the previous day's close. That, i think, will give me just one, stable line that is not updated intraday.

          Thanks for any reply

          Comment

          Working...
          X