An Adaptive Moving Average For Swing Trading

The importable  EDS file based on Scott Cong’s article in the May 2023 issue of Stocks & Commodities magazine, “An Adaptive Moving Average For Swing Trading,” can be obtained on request via rdencpa@gmail.com.

In this article, Scott proposes a new adaptive moving average (AMA). It adjusts its parameters automatically according to the volatility of market, tracking price closely in trending movement, and staying flat in congestion areas. The new AMA is well-suited for swing trading.

The code is also available below.

Code for the author’s indicator as shown below is set up in the downloadable EDS code file.

!ADAPTIVE MOVING AVERAGE FOR SWING TRADING
!Author: Scott Cong, TASC May 2023
!Coded by: Richard Denning, 03/14/2023

!INPUTS:
Len is 20.

!CODING ABREVIATIONS:
H is [high].
L is [low].
C is [close].
C1 is val([close],1).

TR is Max(H-L,max(abs(C1-L),abs(C1-H))).
Effort is sum(TR,Len).
Result is highresult(H,Len) – lowresult(L,Len).
alpha is Result / Effort.
beta is 1 – alpha.

DaysInto is ReportDate() – RuleDate().
Stop if DaysInto > Len*2.
stopAMA is iff(stop,C, AMA).
AMA is alpha * [close] + beta * valresult( stopAMA, 1).
ESA is expavg(C,Len).

The figure below shows a chart of Broadcom (AVGO) along with the AMA[20] indicator (the red jagged line) and an exponential moving average indicator [20] (the green smooth line).

en_GBEnglish
en_GBEnglish