Multi-Indicator Dynamic Volatility Trading Strategy

FMZQuant - Feb 11 - - Dev Community

Image description

Overview
This strategy is an intelligent trading system based on multiple technical indicators. It combines market signals from three dimensions: moving average (MA), volume, and volatility (ATR). It captures market opportunities through a comprehensive analysis of price trends, trading activity, and market volatility. The strategy uses a dual moving average system as the main trend judgment basis, while introducing volume and volatility as trading filter conditions, achieving multiple verifications of trading signals.

Strategy Principle
The core logic of the strategy is based on the following three dimensions:

  1. Trend dimension: Use the 9-day and 21-day simple moving averages (SMA) to build a double moving average system, and determine the trend direction through golden crosses and dead crosses.
  2. Volume dimension: Calculate the 21-day average volume, requiring the current volume to be 1.5 times higher than the average to ensure sufficient market liquidity.
  3. Volatility dimension: 14-day ATR is used to measure market volatility, requiring the current volatility to be higher than its average to ensure sufficient room for price changes.

Only when the conditions of these three dimensions are met at the same time, the strategy will issue a trading signal. This multiple filtering mechanism effectively improves the accuracy of transactions.

Strategy Advantages

  1. High signal reliability: Through cross-validation of multiple technical indicators, the possibility of false breakthroughs is significantly reduced.
  2. Strong adaptability: Strategy parameters can be flexibly adjusted according to different market environments and have good universality.
  3. Perfect risk control: Through the dual filtering of volatility and trading volume, trading risks are effectively controlled.
  4. Clear execution logic: The strategy logic is simple and intuitive, easy to understand and maintain.
  5. High degree of automation: Contains complete signal generation and alarm mechanism, supports automated trading.

Strategy Risks

  1. Lag risk: Moving averages have a certain lag, which may cause a slight delay in entry.
  2. Risk of volatile market: Frequent false signals may occur in a sideways and volatile market.
  3. Parameter sensitivity: The effectiveness of the strategy is sensitive to the parameter settings, and parameters may need to be adjusted in different market environments.
  4. Liquidity Risk: In markets with low trading volumes, it may be difficult to meet trading conditions.

Strategy Optimization Direction

  1. Introduce trend strength indicators: Consider adding ADX or DMI indicators to evaluate trend strength and improve the accuracy of trend judgment.
  2. Optimize the stop-loss mechanism: It is recommended to add a dynamic stop-loss mechanism based on ATR to improve the flexibility of risk control.
  3. Improve signal filtering: Indicators such as RSI can be introduced to assist in judgment and reduce false signals.
  4. Increase position management: It is recommended to dynamically adjust the position size according to the volatility and optimize fund management.
  5. Market sentiment factor: Consider introducing market sentiment indicators to improve the strategy’s adaptability to the market environment.

Summary
This strategy builds a complete trading decision-making system through the collaborative analysis of multiple technical indicators. The strategy design fully considers market characteristics such as trends, liquidity and volatility, and has strong practicality and reliability. Through continuous optimization and improvement, the strategy is expected to maintain stable performance in various market environments. The modular design of the strategy also provides a good foundation for subsequent expansion, which can be flexibly adjusted and optimized according to actual needs.

Strategy source code

/*backtest
start: 2019-12-23 08:00:00
end: 2025-01-04 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy("Advanced Trading Strategy", overlay=true)

// Input parameters
shortPeriod = input.int(9, title="Short Period", minval=1)
longPeriod = input.int(21, title="Long Period", minval=1)
volumeThreshold = input.float(1.5, title="Volume Threshold Multiplier", minval=0.1)
volatilityPeriod = input.int(14, title="Volatility Period", minval=1)

// Calculation of moving averages
shortSMA = ta.sma(close, shortPeriod)
longSMA = ta.sma(close, longPeriod)

// Calculation of average volume
averageVolume = ta.sma(volume, longPeriod)

// Volatility calculation (ATR - Average True Range)
volatility = ta.atr(volatilityPeriod)

// Buying and selling conditions based on moving averages
maBuyCondition = ta.crossover(shortSMA, longSMA)
maSellCondition = ta.crossunder(shortSMA, longSMA)

// Volume check
volumeCondition = volume > averageVolume * volumeThreshold

// Volatility condition (volatility above a certain level)
volatilityCondition = volatility > ta.sma(volatility, volatilityPeriod)

// Final terms and conditions of purchase and sale
buyCondition = maBuyCondition and volumeCondition and volatilityCondition
sellCondition = maSellCondition and volumeCondition and volatilityCondition

// Plotting Moving Averages
plot(shortSMA, title="Short SMA", color=color.red)
plot(longSMA, title="Long SMA", color=color.blue)

// Buy signal
if (buyCondition)
    strategy.entry("Buy", strategy.long)

// For sale sign
if (sellCondition)
    strategy.close("Buy")

// Plotting signals on the chart
plotshape(series=buyCondition, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(series=sellCondition, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")

// Setting up alerts
alertcondition(buyCondition, title="Buy Alert", message="Buy Signal Triggered")
alertcondition(sellCondition, title="Sell Alert", message="Sell Signal Triggered")
Enter fullscreen mode Exit fullscreen mode

Strategy Parameters

Image description

The original address: Multi-Indicator Dynamic Volatility Trading Strategy

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .