
This strategy is an intelligent trading system based on multiple technical indicators, combining signals from Moving Averages (MA), Volume, and Average True Range (ATR) to capture market opportunities through comprehensive analysis of price trends, trading activity, and market volatility. The strategy employs a dual moving average system as the primary trend indicator, while incorporating volume and volatility as trading filters to achieve multiple validations of trading signals.
The core logic is based on three dimensions: 1. Trend Dimension: Uses 9-day and 21-day Simple Moving Averages (SMA) to construct a dual MA system, identifying trend direction through golden and death crosses. 2. Volume Dimension: Calculates 21-day average volume, requiring current volume to exceed 1.5 times the average, ensuring sufficient market liquidity. 3. Volatility Dimension: Employs 14-day ATR to measure market volatility, requiring current volatility to be above its mean, ensuring adequate price movement potential.
Trading signals are generated only when conditions in all three dimensions are simultaneously satisfied, significantly improving trading accuracy through this multi-filter mechanism.
This strategy constructs a comprehensive trading decision system through the synergistic analysis of multiple technical indicators. The design thoroughly considers market characteristics including trends, liquidity, and volatility, demonstrating strong practicality and reliability. Through continuous optimization and improvement, the strategy shows promise for maintaining stable performance across various market environments. Its modular design provides a solid foundation for future extensions, allowing flexible adjustments and optimizations based on actual needs.
/*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)
// Parâmetros de entrada
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)
// Cálculo das médias móveis
shortSMA = ta.sma(close, shortPeriod)
longSMA = ta.sma(close, longPeriod)
// Cálculo do volume médio
averageVolume = ta.sma(volume, longPeriod)
// Cálculo da volatilidade (ATR - Average True Range)
volatility = ta.atr(volatilityPeriod)
// Condições de compra e venda baseadas em médias móveis
maBuyCondition = ta.crossover(shortSMA, longSMA)
maSellCondition = ta.crossunder(shortSMA, longSMA)
// Verificação do volume
volumeCondition = volume > averageVolume * volumeThreshold
// Condição de volatilidade (volatilidade acima de um certo nível)
volatilityCondition = volatility > ta.sma(volatility, volatilityPeriod)
// Condições finais de compra e venda
buyCondition = maBuyCondition and volumeCondition and volatilityCondition
sellCondition = maSellCondition and volumeCondition and volatilityCondition
// Plotando as médias móveis
plot(shortSMA, title="Short SMA", color=color.red)
plot(longSMA, title="Long SMA", color=color.blue)
// Sinal de compra
if (buyCondition)
strategy.entry("Buy", strategy.long)
// Sinal de venda
if (sellCondition)
strategy.close("Buy")
// Plotando sinais no gráfico
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")
// Configurando alertas
alertcondition(buyCondition, title="Buy Alert", message="Buy Signal Triggered")
alertcondition(sellCondition, title="Sell Alert", message="Sell Signal Triggered")