Announcement

Collapse
No announcement yet.

Slope of a Moving Average

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

  • Slope of a Moving Average

    Hi

    I'm looking to code the slope of a Moving Average, i.e., if the slope is steeper than X (indicating a strong trend), then...

    Does anybody know how to go about it?

    Thanks

  • #2
    Rather then mess with linear regression you can get a reasonable approximation by taking the difference of the logged prices divided by the number of time periods being analyzed:

    (ln(P2) - ln(P1))/(T2 - T1)

    You have to define the lookback time period (number of bars) you want to cover. The log function is found in the Math library; I don't know what it is, probably Math.log() or Math.ln().

    Comment


    • #3
      Actually it should be the MA #s not the prices:

      (ln(MA2) - ln(MA1))/(T2 - T1)

      Comment

      Working...
      X