TradingView
PineCodersTASC
14 Apr 2023 pukul 13.04

TASC 2023.05 Cong Adaptive Moving Average 

S&P 500SP

Deskripsi

█ OVERVIEW

TASC's May 2023 edition of Traders' Tips features an article titled "An Adaptive Moving Average For Swing Trading" by Scott Cong. The article presents a new adaptive moving average (​AMA) that adjusts its parameters automatically based on market volatility. The ​AMA tracks price closely during trending movements and remains flat during congestion areas.

█ CONCEPTS

Conventional moving averages (MAs) use a fixed lookback period, which may lead to limited performance in constantly changing market conditions. Perry ​Kaufman's adaptive moving average, first described in his 1995 book Smarter Trading, is a great example of how an ​AMA can self-adjust to adapt to changing environments. Scott Cong draws inspiration from ​Kaufman's approach and proposes a new way to calculate the ​AMA smoothing factor.

█ CALCULATIONS

Following Perry Kaufman's approach, Scott Cong's ​AMA is calculated progressively as:
AMA = α * Close + (1 − α) * AMA(1),
where:
  • Close = Close of the current bar
  • AMA(1) = ​AMA value of the previous bar
  • α = Smoothing factor between 0 and 1, defined by the lookback period

The smoothing factor determines the performance of ​AMA. In Cong's approach, it is calculated as:
α = Result / Effort,
where:
  • Result = Highest price of the n period − Lowest price of the n period
  • Effort = Sum(​TR, n), where ​TR stands for Wilder’s true range values of individual bars of the n period
  • n = Lookback period

As the price range is always no greater than the total journey, α is ensured to be between 0 and 1.
Komentar
Spinn29
wTR(...) can be replaced with nz(math.max(...), sHigh - sLow)
thermal_winds
It actually is really great, first i tried using its phase shift at longer periods to identify trend bias, it was really responsive even at 233, 377 and 610 look back periods. A better way i found is to create a cloud between this moving average and its delayed values. That is so responsive, very less choppy and very much accurate. Thank you so much
Eric_McB
@thermal_winds, What do you mean by create a cloud?
thermal_winds
@mcbrearty1, Try plotting CAMA and CAMA{delay}, where delay can be any integer value. You can write this line of code in the end - plot(cama{input(5)}. See if it adds some more value - p.s. use square brackets instead of curly brackets, dunno why we can't use square brackets in comments
thermal_winds
Thank you so much, really great tool to have in arsenal
Lebih lanjut