OPEN-SOURCE SCRIPT

EMA Crossover Strategy

This script calculates the 9, 21, and 50-period EMAs, plots them on the chart, and generates buy signals when the 9 EMA crosses above the 21 EMA while being above the 50 EMA, and sell signals when the 9 EMA crosses below the 21 EMA while being below the 50 EMA. You can customize the colors and styles as needed. ```pinescript //version=5 indicator("EMA Crossover Strategy", overlay=true)

// Define the EMAs ema9 = ta.ema(close, 9) ema21 = ta.ema(close, 21) ema50 = ta.ema(close, 50)

// Plot the EMAs plot(ema9, color=color.blue, title="EMA 9") plot(ema21, color=color.red, title="EMA 21") plot(ema50, color=color.green, title="EMA 50")

// Define buy and sell conditions buySignal = ta.crossover(ema9, ema21) and ema9 > ema50 sellSignal = ta.crossunder(ema9, ema21) and ema9 < ema50

// Plot buy and sell signals plotshape(series=buySignal, location=location.belowbar, color=color.green, style=shape.labelup, text="Buy") plotshape(series=sellSignal, location=location.abovebar, color=color.red, style=shape.labeldown, text="Sell")

// Optional: Add alerts for buy and sell signals alertcondition(buySignal, title="Buy Alert", message="Buy Signal: EMA 9 crossed above EMA 21") alertcondition(sellSignal, title="Sell Alert", message="Sell Signal: EMA 9 crossed below EMA 21") pinescript //version=5 indicator("EMA Crossover Strategy", overlay=true)

// Define the EMAs ema9 = ta.ema(close, 9) ema21 = ta.ema(close, 21) ema50 = ta.ema(close, 50)

// Plot the EMAs plot(ema9, color=color.blue, title="EMA 9") plot(ema21, color=color.red, title="EMA 21") plot(ema50, color=color.green, title="EMA 50")

// Define buy and sell conditions buySignal = ta.crossover(ema9, ema21) and ema9 > ema50 sellSignal = ta.crossunder(ema9, ema21) and ema9 < ema50

// Plot buy and sell signals plotshape(series=buySignal, location=location.belowbar, color=color.green, style=shape.labelup, text="Buy") plotshape(series=sellSignal, location=location.abovebar, color=color.red, style=shape.labeldown, text="Sell")

// Optional: Add alerts for buy and sell signals alertcondition(buySignal, title="Buy Alert", message="Buy Signal: EMA 9 crossed above EMA 21") alertcondition(sellSignal, title="Sell Alert", message="Sell Signal: EMA 9 crossed below EMA 21")

// Additional feature: Highlight the background during buy/sell signals bgcolor(buySignal ? color.new(color.green, 90) : na, title="Buy Background") bgcolor(sellSignal ? color.new(color.red, 90) : na, title="Sell Background")
Candlestick analysis

Skrypt open-source

W prawdziwym duchu TradingView autor tego skryptu opublikował go jako open source, aby inwestorzy mogli go zrozumieć i zweryfikować. Pozdrowienia dla autora! Możesz go używać bezpłatnie, ale ponowne użycie tego kodu w publikacji podlega Zasadom Regulaminu. Możesz go oznaczyć jako ulubione, aby użyć go na wykresie.

Chcesz użyć tego skryptu na wykresie?

Wyłączenie odpowiedzialności