Multi-Moving Average Angle Trend Reversal Trading System

EMA SMA MA 趋势反转 角度分析 移动均线交叉 云指标 趋势线 横盘市场
Created on: 2025-05-20 10:05:33 Modified on: 2025-05-20 10:05:33
Copy: 0 Number of hits: 379
avatar of ianzeng123 ianzeng123
2
Follow
319
Followers

 Multi-Moving Average Angle Trend Reversal Trading System  Multi-Moving Average Angle Trend Reversal Trading System

Overview

The Multi-Moving Average Angle Trend Reversal Trading System is a quantitative trading strategy specifically designed for sideways markets, combining multiple moving averages and angle analysis techniques. The core of this strategy is to monitor the relationships between four different moving averages (two EMAs and two SMAs) while utilizing angle changes in the long-term moving average to identify market trend reversal points, thereby capturing high-probability trading opportunities in range-bound markets. The system particularly focuses on the crossovers between MA50 and EMA20, combined with angle changes in MA150 to filter out false signals, achieving precise entry and exit in oscillating markets.

Strategy Principles

The operational principles of this strategy are based on the collaborative analysis of four key moving averages: 1. Short-term EMA (default 15 periods): Reflects short-term price movements, represented in green 2. Medium-long term EMA (default 100 periods): Reflects medium to long-term trends, represented in red 3. Medium-term SMA (default 20 periods): Used to generate crossover signals, represented in blue 4. Long-term SMA (default 200 periods): Used to analyze major market trends, represented in orange

The core logic of the strategy lies in: - Forming a “TBO Cloud” through EMA20 and EMA40, providing an intuitive indication of market bias - Calculating the angle changes of MA150 (orange long-term average) to determine overall market trend strength - Considering the market in a sideways state when the MA150 angle is less than the set threshold (default 5 degrees) - Utilizing the crossover of MA50 (blue line) and EMA20 (green line) to generate trading signals in sideways markets - Buy condition: When EMA20 is below EMA40 (in the red cloud) and MA50 crosses below EMA20, while MA150 has no significant downward trend - Sell condition: When EMA20 is above EMA40 (in the green cloud) and MA50 crosses above EMA20, while MA150 has no significant upward trend - Automatically closing positions when the MA150 angle reverses (from rising to not rising or from falling to not falling)

The uniqueness of this strategy lies in its focus on capturing oscillation opportunities in sideways markets rather than chasing strong trends, filtering out false reversal signals in strong trend environments through angle analysis techniques.

Strategy Advantages

  1. Sideways Market Specialization: The strategy is specifically designed for sideways oscillating markets, avoiding the common “chasing highs and selling lows” trap of trend-following strategies.

  2. Multiple Confirmation Mechanisms: A multi-layered confirmation system is built through four different period moving averages and angle analysis, improving signal quality.

  3. Innovative Angle Analysis: The introduction of MA150 angle calculation to determine market trend strength and reversal is an innovation distinguishing it from traditional moving average systems.

  4. Automatic Risk Management: The strategy incorporates an automatic position closing mechanism based on trend reversals, exiting the market immediately when the major trend direction changes, effectively controlling risk.

  5. Visualized Trading Environment: The “TBO Cloud” and clear color system allow traders to intuitively understand current market conditions and signal quality.

  6. Adjustable Parameters: All key parameters can be adjusted, making the strategy adaptable to different market environments and trader styles.

  7. Counter-Trend Trading Capability: By identifying moments when trends temporarily weaken, the strategy can capture short-term reversal opportunities before trend continuation.

Strategy Risks

  1. False Signal Risk: In highly volatile markets, moving averages may frequently cross, generating false signals and leading to overtrading and losses. The solution is to add additional filtering conditions or expand moving average periods.

  2. Delayed Response Issue: Due to the use of multiple moving averages, the strategy may have a certain delay in responding to market changes, missing optimal entry or exit points. This can be reduced by adjusting the parameters of shorter-period EMAs.

  3. Trend Judgment Accuracy: The MA150 angle calculation uses a fixed period (5) to calculate slope, which may not accurately reflect trend strength across different timeframes. It’s recommended to dynamically adjust this parameter based on the trading timeframe.

  4. Parameter Sensitivity: The strategy is sensitive to various moving average parameters and angle threshold settings, with different parameter combinations yielding significantly different performance. Optimal parameter combinations for specific markets need to be identified through backtesting.

  5. Market Environment Dependency: The strategy may not perform well in strong trend markets, as it is designed specifically for sideways markets. Traders need the ability to identify market states or incorporate market environment filters.

  6. Lack of Stop-Loss Mechanism: The strategy lacks explicit stop-loss mechanisms, relying only on signal reversal or trend angle changes to exit, potentially facing significant losses in extreme market conditions. It’s advisable to supplement with stop-loss mechanisms based on fixed proportions or volatility.

Strategy Optimization Directions

  1. Dynamic Parameter Adjustment: Volatility indicators (such as ATR) can be introduced to dynamically adjust moving average periods and angle thresholds based on market volatility, allowing the strategy to self-adapt to different market environments.

  2. Incorporate Volume Analysis: Combine volume information to verify the reliability of moving average crossover signals, executing trades only when crossovers are accompanied by significant volume changes, effectively reducing false signals.

  3. Multi-Timeframe Analysis: Introduce higher timeframe trend judgments to filter signals, for example, entering only when the daily trend direction aligns with the current trading signal, improving the overall win rate of the strategy.

  4. Optimize Angle Calculation Method: Change the fixed-period angle calculation to an adaptive period based on market volatility, or use more advanced trend strength measurement methods such as regression analysis to improve the accuracy of angle judgment.

  5. Add Stop-Loss and Profit-Taking Mechanisms: Incorporate stop-loss settings based on ATR or support/resistance levels, as well as profit-taking mechanisms based on risk-reward ratios, perfecting the risk management framework.

  6. Add Market State Filter: Develop a market state classifier to identify whether the current market is in a trending, sideways, or chaotic state, activating the strategy only in suitable market states.

  7. Integrate Machine Learning Algorithms: Utilize machine learning techniques to optimize signal generation and filtering processes, training models with historical data to predict signal success probability.

Conclusion

The Multi-Moving Average Angle Trend Reversal Trading System is an innovative quantitative strategy focused on sideways markets, constructing a complete trading framework through four differently parameterized moving averages and angle analysis techniques. The core advantages of the strategy lie in its specialization for sideways markets and innovative angle analysis method, effectively identifying market trend turning points and filtering out false signals. Despite risks such as parameter sensitivity and market environment dependency, through the proposed optimization directions like dynamic parameter adjustment, multi-timeframe analysis, and improved risk management systems, the strategy has the potential to further enhance performance. For traders seeking stable returns in oscillating markets, this is a strategy framework worth in-depth research and practice.

Strategy source code
/*backtest
start: 2024-05-20 00:00:00
end: 2025-05-18 08:00:00
period: 2d
basePeriod: 2d
exchanges: [{"eid":"Futures_Binance","currency":"ETH_USDC"}]
*/

// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © pabloportugalgarcia

//@version=5
strategy("TBO - Bot", overlay=true)

// Inputs
len_ema20    = input.int(15, minval=1, title="Período Green EMA")
len_ema40    = input.int(100, minval=1, title="Período Red EMA")
len_ma50     = input.int(20, minval=1, title="Período Blue MA")
len_ma150    = input.int(200, minval=1, title="Período Orange MA")
pivot_len    = input.int(20, minval=1, title="Período Pivô Suporte/Resistência")
angle_limit  = input.float(5, minval=0, title="Ângulo mínimo da MA150 para considerar reversão (graus)")
angle_period = input.int(10, minval=1, title="Período para cálculo do ângulo MA150")

// Médias móveis
ema20 = ta.ema(close, len_ema20)
ema40 = ta.ema(close, len_ema40)
ma50  = ta.sma(close, len_ma50)
ma150 = ta.sma(close, len_ma150)

// Plots das médias/linhas
plot(ema20, color=color.lime, linewidth=1, title="Green EMA")
plot(ema40, color=color.red, linewidth=1, title="Red EMA")
plot(ma50,  color=color.blue, linewidth=2, title="Blue MA")
plot(ma150, color=color.orange, linewidth=2, title="Orange MA")

// Nuvem EMA20-EMA40
bull = ema20 > ema40
fill(plot(ema20, color=color.new(color.green, 80)), plot(ema40, color=color.new(color.red, 80)), color=bull ? color.new(color.green, 80) : color.new(color.red, 80), title="TBO Cloud")

// Cruzamentos da Blue MA com Green EMA
maCrossUp   = ta.crossover(ma50, ema20)   // MA50 cruza PARA CIMA EMA20
maCrossDown = ta.crossunder(ma50, ema20)  // MA50 cruza PARA BAIXO EMA20

// === Cálculo do declive e ângulo no período escolhido
ma150_slope = (ma150 - ma150[5]) / 5
ma150_angle = math.atan(ma150_slope) * 180 / math.pi

// Tendência baseada no ângulo
trendUp   = ma150_angle > angle_limit
trendDown = ma150_angle < -angle_limit

// Detecta reversão baseada no ângulo
trendDownRevert = trendDown[1] and not trendDown
trendUpRevert   = trendUp[1]   and not trendUp

// ---- Sinais
buySignal  = (ema20 < ema40) and maCrossDown and not trendDown    // Só compra se MA150 não está caindo o suficiente
sellSignal = (ema20 > ema40) and maCrossUp   and not trendUp      // Só vende se MA150 não está subindo o suficiente

if (sellSignal)
    strategy.entry("Sell", strategy.short, comment="Sell")
if (buySignal)
    strategy.entry("Buy", strategy.long, comment="Buy")
    
// === FECHE todos os shorts quando:
// 1) Um novo sinal de BUY acontecer
// 2) OU a linha laranja deixar de cair (tendência de baixa reverter)
if (buySignal or trendDownRevert)
    strategy.close("Sell", comment="Close shorts")

// === FECHE todos os longs quando:
// 1) Um novo sinal de SELL acontecer
// 2) OU a linha laranja deixar de subir (tendência de alta reverter)
if (sellSignal or trendUpRevert)
    strategy.close("Buy", comment="Close Longs")

// Sinais visuais
plotshape(buySignal,  style=shape.triangleup,   location=location.belowbar, size=size.small, color=color.lime,  title="Buy")
plotshape(sellSignal, style=shape.triangledown, location=location.abovebar, size=size.small, color=color.blue,  title="Sell")

// Debug: plot do ângulo em graus
plot(ma150_angle, color=color.orange, linewidth=1, title="Ângulo MA150")