Announcement

Collapse
No announcement yet.

Weighted MA

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

  • Weighted MA

    I am attempting to write an efs file to create a weighted moving average with a fairly long lookback period. When I do this the brute force way, however, it is so iterative that it locks up my computer trying to process the info. Is there a "canned" call I can make in the program to get a weighted moving average, or am I just stuck? Any attempts I have made with a formulaic approach take forever to process. Thanks.

  • #2
    Dwain,

    There is a weighted option for the basic MA study. Do you mean something other than that?

    Dennis

    Comment


    • #3
      dwain
      The following code will plot a Weighted MA based on the close with a lookback period of 100

      PHP Code:
      var vWMA100 = new MAStudy(1000"Close"MAStudy.WEIGHTED);

      function 
      preMain() {

          
      setPriceStudy(true);
          
      setStudyTitle("weightedMA");
          
      setCursorLabelName("wma"0);
          
      setDefaultBarStyle(PS_SOLID0);
          
      setDefaultBarFgColor(Color.red0);
          
      setDefaultBarThickness(10);
          
      setPlotType(PLOTTYPE_LINE0);

      }

      function 
      main() {
       
          return 
      vWMA100.getValue(MAStudy.MA);


      Changing parameters will have to be done using the Editor.
      If instead you want to be able to have a WMA where all the parameters can be modified via Edit Studies click here and download basicMA.efs.
      Hope this helps
      Alex

      Comment


      • #4
        Nope, that was it. I didn't realize there was that option in the studies. In general, how are the options called?

        Comment


        • #5
          dwain
          Those are just the built-in studies.
          The easiest way to build a formula with these studies is to use the Formula Wizard. With it you will achieve the same result as in the listed code.
          Alex

          Comment


          • #6
            Thanks Alexis
            I just wasn't aware that the various options for MA's could be called from the getValue.MAStudy line. I've already plugged it in and it works great. The application was to set an overnight .wav alarm for my position trading, yank me out of bed if things go bad.

            Thanks again

            Comment

            Working...
            X