OPEN-SOURCE SCRIPT

MA + Volume Strategy

//version=5
strategy("MA + Volume Strategy", overlay=true)

// Parameters
maLength = input.int(50, title="MA Length", minval=1)
volLength = input.int(20, title="Volume MA Length", minval=1)

// Calculating Moving Average and Volume Average
ma = ta.sma(close, maLength)
volMa = ta.sma(volume, volLength)

// Plot the Moving Average
plot(ma, title="Moving Average", color=color.blue, linewidth=2)

// Buy Condition: Price crosses above the MA and Volume > Volume MA
buyCondition = ta.crossover(close, ma) and volume > volMa

// Sell Condition: Price crosses below the MA and Volume > Volume MA
sellCondition = ta.crossunder(close, ma) and volume > volMa

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

if (sellCondition)
strategy.close("Buy")

// Plot volume with volume average for reference
plot(volume, title="Volume", color=color.green, style=plot.style_histogram, transp=70)
plot(volMa, title="Volume Moving Average", color=color.red)
Bill Williams Indicators

Script open-source

Dans le plus pur esprit TradingView, l'auteur de ce script l'a publié en open-source, afin que les traders puissent le comprendre et le vérifier. Bravo à l'auteur! Vous pouvez l'utiliser gratuitement, mais la réutilisation de ce code dans une publication est régie par nos Règles. Vous pouvez le mettre en favori pour l'utiliser sur un graphique.

Vous voulez utiliser ce script sur un graphique ?

Clause de non-responsabilité