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 de código abierto

Siguiendo fielmente el espíritu de TradingView, el autor de este script lo ha publicado en código abierto, permitiendo que otros traders puedan entenderlo y verificarlo. ¡Olé por el autor! Puede utilizarlo de forma gratuita, pero tenga en cuenta que la reutilización de este código en la publicación se rige por las Normas internas. Puede añadir este script a sus favoritos y usarlo en un gráfico.

¿Quiere utilizar este script en un gráfico?

Exención de responsabilidad