Announcement

Collapse
No announcement yet.

BW Smoothed Moving Averages

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

  • BW Smoothed Moving Averages

    Greetings New Suggestion Support:

    I have a requirement to plot a smoothed moving average projected into the future and to be able to see the moving average data points beyond the end of the data. I understand that the last data points can only be seen from Built-in studies. I would greatly appreciate options to develop a smoothed moving average from the existing Built-in moving average or the ability to construct a Built-in formula myself. The method for the smoothed moving average can be found below.

    I see other versions of Bill Williams moving averages on the files section, but they do not use the SMOOTHED moving average. My finding are that the (H+L)/2 does not calculate the averages as Dr. Williams prescribes. I current believe that the smoothing method is found below although I have yet verified this for certain.

    Thanks;

    Burt

    -----------------

    Smooth:
    A Smoothed Moving Average is similar to a simple moving average. However, in a smoothed moving average, rather than subtracting the oldest value the previous smoothed average value is subtracted. For the following example the PERIOD equals 3.
    The first value for a Smoothed Moving Average is determined by the formula SMOOTH. It is plotted on the chart at the third bar from the left side of the screen.
    · SMOOTH =(PRICE 1 + PRICE 2 + PRICE 3)/PERIOD
    · The next value would be plotted at the fourth bar from the left side of the screen.
    · SMOOTH2 = (PREVIOUS SUM - PREVIOUS AVG + PRICE 4)/PERIOD
    · For the second calculation of SMOOTH, PREVIOUS SUM is the sum of PRICE 1 + PRICE 2 + PRICE 3; and PREVIOUS AVG is the initial value of SMOOTH.
    · The next value would be plotted at the fifth bar from the left side of the screen. SMOOTH = (PREVIOUS SUM - PREVIOUS AVG + PRICE 5)/PERIOD. Subsequent values would be determined by subtracting the PREVIOUS AVG from the PREVIOUS SUM, adding the next more recent PRICE, then dividing by the PERIOD.
    Example: If the values 1,2,3,4 and 5 were reported for the first five bars the three-period smoothed moving averages for those bars would be calculated as follows:
    (1+2 +3)/3 = 2 This is the first value and would be plotted on the third bar from the left.
    (6 - 2 + 4)/3 = 2.67 This second value would be plotted on the fourth bar from the left.
    (8 - 2.67+5)/3 = 3.44 This third value would be plotted on the fifth bar from the left, and so on.

  • #2
    I put together the script per your specifications. It can be found in the File Share area at the following link:

    http://share.esignal.com/groupconten...us&groupid=114

    File name is SmoothedMA.efs

    Chris

    Comment


    • #3
      See as Builtin?

      Greetings Chris:

      Thanks so much for the reply. I wonder though, is there any way to use this function as a "Builtin"? As far as I can determine, using it as a "Builtin" is the only way to see the last data points on the moving average when it is projected into the future. Scripts, as I understand them, are only calculated up to the last price bar. The routine I need is projected into the future, and seeing the data points projected past the last data bar are important to me. I can see how to modify your script to perform the offset, but it is still not clear to me how to produce my own Builtin or to modify the choices on the existing Builtin moving average to produce the smoothed variant. I would greatly appreciate any help you can provide.

      Thanks;

      Burt

      Comment


      • #4
        Burt:

        I created a new version of the script with an Offset parameter added. The script will allow you to offset the moving average to the right up to 50 bars and it will draw the lines 'into the future'. It uses a combination of return values as well as drawLine() calls to accomplish this.

        http://share.esignal.com/groupconten...us&groupid=114

        File name is SmoothedMA.efs.

        Chris

        Comment


        • #5
          The Wizard!

          Greetings Chris:

          You latest modification appears to do just what I needed. You are the Wizard for sure. I could not have accomplished this feat. Thanks so much.

          I did have one little problem though, I put up three of the moving averages (of different lengths and offsets) and attempted to changed their color. I cannot get the color on the other two MAs to change. Does the color change in "Edit Studies” work for you or am I having a local problem?

          Thanks So Much;

          Burt

          Comment


          • #6
            Burt:

            I placed a new version in the Miscellaneous folder this morning. This new version has color support (e.g., a new Color parameter) which will take care of the problem you described.

            Chris

            Comment


            • #7
              Color Now Works!

              Greetings Chris:

              Your routine appears to work flawlessly. Thanks so much once again. I also want to change the line thickness and name the study in the main pane and in the data window. I am seeing a bit how to do these changes thanks to your examples.

              Best Regards;

              Burt

              Comment


              • #8
                Burt:

                I placed a new version in the Specialty Groups Miscellaneous folder that has a new line thickness parameter.

                Chris

                Comment


                • #9
                  "SmoothedMA.efs" almost perfect.....

                  Chris and Burt,

                  You have succeeded where I have failed. I could not get my script right for plotting the "Alligator".

                  Thank you for sharing your script - it is almost perfect. Just for your information though, the values for the averages are very close to accurate when computed using the "close" price, but still are not quite exact - though it's hard to tell without close inspection.

                  When I compare the values computed using the "close" price with those in Investor's Dream, your formula plots the line just a few pips closer to the price.

                  When I change the code to calculate the MA based on the midpoint, the values are exactly the same as shown in Investor's Dream.

                  Could you adjust the formula to allow the option of plotting either the average close price or the midpoint? I have modified my copy of your script (thank you for sharing it) to use the midpoint, but I know there are many others who would appreciate having the correct formula.

                  Also, I thought I would change your script to allow me to plot all three lines from the same instance of this script, with the defaults set at:

                  Green line: period = 5, offset = 3;
                  Red line: period = 8, offset =5;
                  Blue line: period = 13, offset =8;


                  I have been unsuccessful. Would this be difficult for a real programmer such as yourself, Chris?


                  Thank you
                  Last edited by Salamander; 07-25-2003, 03:21 PM.

                  Comment


                  • #10
                    Salamander:

                    I put a new version up with various price options (close, hl/2, etc.)

                    Regarding printing 3 MA's from one script... what's wrong with just loading 3 (or more) copies of the script? Much more flexible and a lot less coding

                    Chris

                    Comment


                    • #11
                      Wow! Thank you for the prompt response. The new option works great.

                      There's nothing wrong with loading multiple instances of your script - it works great. I just don't like all the lines of text filling up the top left corner of the price window. I thought that by drawing all three lines from the same instance of the script, I could reduce the amount of text. Perhaps there's a better way???

                      One more thing, could you prevent the zeros from being drawn at the beginning of the chart? This is only a problem on larger intervals with a very limited history (4 hr, 6 hr...).

                      I have attached a picture so you can see what I mean about the text and zeros.

                      Thank you again Chris.
                      Last edited by Salamander; 07-26-2003, 02:13 PM.

                      Comment


                      • #12
                        Salamander
                        If you would rather not see the Study Titles and their parameters right click on the chart, select Properties and uncheck Draw Study Titles
                        Alex

                        Comment


                        • #13
                          Thank you.


                          For future reference, any ideas why my attached picture for the previous post didn't show up?

                          Comment


                          • #14
                            Salamander
                            First of all it seems that there are some problems posting attachments in the Bulletin Board today so it could just be related to that.
                            You may also want to check the copy of the image on your computer (if you have not done so already). If that too is completely blacked out then the problem could be at your end ie the video capture not working properly for some reason.
                            If the image on your machine is fine rename it then go back into your message using Edit and replace the attachment with the renamed one.
                            Alex
                            Last edited by ACM; 07-26-2003, 01:47 PM.

                            Comment


                            • #15
                              test for image attachment - please disregard
                              Alex
                              Attached Files

                              Comment

                              Working...
                              X