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

สคริปต์โอเพนซอร์ซ

ด้วยเจตนารมณ์หลักของ TradingView ผู้เขียนสคริปต์นี้ได้เผยแพร่เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถเข้าใจและตรวจสอบได้ ต้องขอบคุณผู้เขียน! ที่ให้คุณใช้ได้ฟรี แต่การนำโค้ดนี้ไปใช้ในการเผยแพร่ซ้ำจะต้องอยู่ภายใต้ กฎระเบียบการใช้งาน คุณสามารถตั้งเป็นรายการโปรดเพื่อใช้บนชาร์ตได้

ต้องการที่จะใช้สคริปต์นี้บนชาร์ตใช่ไหม?

คำจำกัดสิทธิ์ความรับผิดชอบ