Announcement

Collapse
No announcement yet.

weighted average of highest close

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

  • weighted average of highest close

    Hi

    Ive been trying for awhile to get
    a 9 weighted moving average of the highest close of last the 13,

    Tried arrays and all sorts, but i just keep getting null, The closest script ive seen (from Alexis) to what im after is attached, however after appling the wma() to it, i get null

    Please help

    Regards

    Bob
    Attached Files

  • #2
    Actually, before the wma can be done, the midpoint of the highest close and lowest close has to be performed first.
    ie

    (highest of 13 closes + lowest of 13 closes) /2
    and then
    a 9 weighted moving average of this result

    Comment


    • #3
      Bob

      a 9 weighted moving average of the highest close of last the 13

      I have yet to look at the efs you posted but you may want to consider using efs2 to do what you want ie
      var myStudy = wma(9,upperDonchian(13,close()));
      Alex

      Comment


      • #4
        Bob

        (highest of 13 closes + lowest of 13 closes) /2
        and then
        a 9 weighted moving average of this result


        In this case you would use
        var myStudy = wma(9,middleDonchian(13,close()));
        Alex

        Comment


        • #5
          Thanks Alexis

          I tried that, but this statement does not take into consideration the highest and lowest of the 13 closes or does it ???

          This seems to work, however it may not be the best way of writing it.

          var blar=wma(9, (highest(13, close())-lowest(13, close()))/2)

          I plotted this against the middledonchian as you suggested and they are different.

          Comment


          • #6
            Bob

            I tried that, but this statement does not take into consideration the highest and lowest of the 13 closes or does it ???

            Yes it does. When you pass an input to the Donchian study such as for example close() the study will be based on that input therefore middleDonchian(10, close()) is the same as writing
            (upperDonchian(10,close()) + lowerDonchian(10,close())) /2

            var blar=wma(9, (highest(13, close())-lowest(13, close()))/2)

            That will not work (or if it does will return an incorrect result) because builti-in studies require a series as the input which (highest(13, close())-lowest(13, close())) is not. That equation returns a value not a series.
            Alex

            Comment


            • #7
              Thanks for clarfying that Alex.

              Your are right, The way I did it,does plot a value, but its not right.

              Kind Regards

              Bob

              Comment


              • #8
                Bob
                The reason why the efs you posted earlier does not work is because you are not passing a valid input to the wma() study. The input needs to be a series whereas in that efs ll and hh are just values.
                In order to use ll and hh as inputs for wma() you would need to move all the calculations for ll and hh into a separate function and in that function replace return new Array (hh,ll) with return (hh+ll)/2. Then in main you would call that function through efsInternal() which would create the data series that you can use as a source for the wma() study.
                Alternatively you could leave the highest-lowest.efs as I originally wrote it - changing only the return as described above - and call it from within a new efs through efsExternal(). For example
                wma(9,efsExternal("highest-lowest.efs",close(),13))
                Note that I am passing the parameters in the same order as they are expected by the efs ie Source, Length.
                If you are interested in reading more on how to use efsInternal() and efsExternal() functions see this thread.
                Alex

                Comment

                Working...
                X