//version=5
indicator("Simple Moving Average Crossover", overlay=true)
// Input for moving average length
length = input(14, title="Moving Average Length")
// Calculate SMAs
sma_short = sma(close, length)
sma_long = sma(close, 2 * length)
// Plot SMAs on the chart
plot(sma_short, color=color.blue, title="Short MA")
plot(sma_long, color=color.red, title="Long MA")
// Buy signal when short MA crosses above long MA
strategy.entry("Buy", strategy.long, when=crossover(sma_short, sma_long))
// Sell signal when short MA crosses below long MA
strategy.entry("Sell", strategy.short, when=crossunder(sma_short, sma_long))
indicator("Simple Moving Average Crossover", overlay=true)
// Input for moving average length
length = input(14, title="Moving Average Length")
// Calculate SMAs
sma_short = sma(close, length)
sma_long = sma(close, 2 * length)
// Plot SMAs on the chart
plot(sma_short, color=color.blue, title="Short MA")
plot(sma_long, color=color.red, title="Long MA")
// Buy signal when short MA crosses above long MA
strategy.entry("Buy", strategy.long, when=crossover(sma_short, sma_long))
// Sell signal when short MA crosses below long MA
strategy.entry("Sell", strategy.short, when=crossunder(sma_short, sma_long))
Declinazione di responsabilità
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.
Declinazione di responsabilità
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.