Adaptive Moving Average Crossover Strategy Based on Uhl MA

Author: ChaoZhang, Date: 2023-09-19 22:06:42
Tags:

Overview

The Uhl MA system is an adaptive moving average crossover system designed to overcome the deficiencies of traditional MA systems. It uses fast and slow moving averages to generate trading signals, with the slow MA being the corrected MA (CMA) originally proposed by Andreas Uhl and the fast MA being the corrected trend step (CTS) which is also based on the corrected MA. The system adaptively adjusts the MA parameters to achieve more reliable trading signals.

Principle Analysis

The core of this strategy lies in the calculation of Uhl MA and CTS lines. Uhl MA line is an enhancement over the traditional SMA, using variance (VAR) and historical squared deviation (SECMA) to adaptively adjust the weights between SMA and previous CMA. When VAR is less than SECMA, more weight is put on SMA, otherwise more weight is put on CMA. This helps filter out some noise and generate smoother MA. CTS line uses similar adaptive calculation based on SRC price.

The crossover logic is the same as traditional MA systems. A buy signal is generated when CTS crosses above Uhl MA, and a sell signal when crossing below. This forms an adaptive MA trading system.

Advantage Analysis

Compared to traditional MA crossover systems, the biggest advantage of this strategy is the use of adaptive MAs, which can filter some noise and generate more reliable signals in range-bound markets. The adaptive crossover reduces false signals compared to dead cross and golden cross. Also, the fast and slow MA combination allows catching some trend-trading opportunities. From backtest results we can see superior performance in assets with obvious trends.

Risk Analysis

The major risk of this strategy comes from the increased false signals in ranging markets, as MAs are trend-following indicators in nature. This is largely due to the adaptive calculation of CMA, which converges to price ranges in consolidation, generating unnecessary signals. Proper parameter tuning is also a big challenge. Improper parameters may lead to missing good trades or increased false signals.

Optimization Suggestions

The potential optimizations include:

  1. Improve CMA calculation to avoid convergence in ranging markets, using other indicators for example.

  2. Optimize parameters through multi-variate optimization algorithms like genetic algorithms.

  3. Introduce stop loss to control single trade loss.

  4. Add filters using other indicators to avoid over-trading in consolidation, such as volatility measures, RFM index etc.

  5. Optimize risk management including position sizing, risk metrics to better control overall risk.

Conclusion

The Uhl MA system is a very innovative adaptive MA crossover strategy. Compared to traditional strategies, the dynamic MAs help reduce false signals and better capture trends. But limitations exist in ranging markets. Further improvements in calculation methodology and adding filters hold great potential. Meanwhile, parameter tuning and risk control are also critical. Overall, the Uhl MA strategy has good potential and research value worth further exploration.

[/trans]


/*backtest
start: 2023-01-01 00:00:00
end: 2023-06-25 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © alexgrover

//@version=4
strategy("Uhl MA System - Strategy Analysis")
length = input(100),mult = input(1.),src = input(close)
//----
out = 0., cma = 0., cts = 0.
Var = variance(src,length)           ,sma = sma(src,length)
secma = pow(nz(sma - cma[1]),2)      ,sects = pow(nz(src - cts[1]),2) 
ka = Var < secma ? 1 - Var/secma : 0 ,kb = Var < sects ? 1 - Var/sects : 0
cma := ka*sma+(1-ka)*nz(cma[1],src)  ,cts := kb*src+(1-kb)*nz(cts[1],src)
//----
if crossover(cts,cma)
    strategy.entry("Buy", strategy.long)
if crossunder(cts,cma)
    strategy.entry("Sell", strategy.short)
//----
cap = 50000
eq = strategy.equity
rmax = 0.
rmax := max(eq,nz(rmax[1]))
//----
css = eq > cap ? #0cb51a : #e65100
a = plot(eq,"Equity",#2196f3,2,transp=0)
b = plot(rmax,"Maximum",css,2,transp=0)
fill(a,b,css,80)

More