Mastering the Stochastic Momentum Indicator for MetaTrader 5

Mike 2011.06.28 20:32 70 0 0
Attachments

Author: Andrey N. Bolkonsky

The Stochastic Momentum Indicator (SM) created by William Blau is a key tool for technical analysis. You can dive deeper into his methods in his book, Momentum, Direction, and Divergence.

This indicator measures the distance of the current closing price from the midpoint of a specified range of bars, known as the q-period.

  • Stochastic Momentum Value: This indicates how far the current price is from the midpoint of the q-period price range.
  • Sign of Stochastic Momentum: Positive values suggest the price is above the midpoint, while negative values indicate it's below.

Definition of Stochastic Momentum by William Blau

Definition of Stochastic Momentum by William Blau

  • Make sure to place WilliamBlau.mqh in terminal_data_folder/MQL5/Include/
  • Put Blau_SM.mq5 in terminal_data_folder/MQL5/Indicators/

Stochastic Momentum by William Blau

Calculation:

The q-period Stochastic Momentum is calculated using the following formula:

sm(price,q) = price - 1/2 * [LL(q) + HH(q)]

Where:

  • price: The closing price.
  • q: The number of bars used for the Stochastic Momentum calculation.
  • LL(q): The lowest price over the q bars.
  • HH(q): The highest price over the q bars.
  • 1/2 * [LL(q) + HH(q)]: This represents the midpoint of the q-period price range.

The smoothed q-period Stochastic Momentum is calculated using:

SM(price,q,r,s,u) = EMA(EMA(EMA(sm(price,q),r),s),u)

Where:

  • price: The closing price.
  • q: The number of bars for Stochastic Momentum.
  • sm(price,q): The q-period Stochastic Momentum.
  • EMA(sm(price,q),r): The first smoothing using an exponential moving average over period r.
  • EMA(EMA(...,r),s): The second smoothing using an EMA over period s.
  • EMA(EMA(EMA(sm(q),r),s),u): The third smoothing using an EMA over period u.

Input parameters:

  • q: Period of Stochastic Momentum (default q=5).
  • r: Period of the first EMA (default r=20).
  • s: Period of the second EMA (default s=5).
  • u: Period of the third EMA (default u=3).
  • AppliedPrice: Type of price used (default AppliedPrice=PRICE_CLOSE).
Note:
  • q must be greater than 0.
  • r, s, and u must also be greater than 0. If r, s, or u equals 1, smoothing is not applied.
  • Minimum rates = (q-1+r+s+u-3+1).

List
Comments 0