OPEN-SOURCE SCRIPT
EMA 20/40 Crossover

//version=5
indicator(title="EMA 20/40 Crossover", shorttitle="EMA Cross", overlay=true)
// Calculate EMAs
ema20 = ta.ema(close, 20)
ema40 = ta.ema(close, 40)
// Detect crossovers
bullCross = ta.crossover(ema20, ema40) // EMA20 crosses above EMA40 (Buy signal)
bearCross = ta.crossunder(ema20, ema40) // EMA20 crosses below EMA40 (Sell signal)
// Plot EMA lines
plot(ema20, color=color.blue, title="EMA 20", linewidth=2)
plot(ema40, color=color.red, title="EMA 40", linewidth=2)
// Plot signals
plotshape(series=bullCross, title="Buy Signal", location=location.belowbar, style=shape.labelup, size=size.small, color=color.green, text="BUY")
plotshape(series=bearCross, title="Sell Signal", location=location.abovebar, style=shape.labeldown, size=size.small, color=color.red, text="SELL")
// Alert setup (optional)
alertcondition(bullCross, title="EMA Bullish Cross", message="EMA 20 crossed above EMA 40 - BUY!")
alertcondition(bearCross, title="EMA Bearish Cross", message="EMA 20 crossed below EMA 40 - SELL!")
indicator(title="EMA 20/40 Crossover", shorttitle="EMA Cross", overlay=true)
// Calculate EMAs
ema20 = ta.ema(close, 20)
ema40 = ta.ema(close, 40)
// Detect crossovers
bullCross = ta.crossover(ema20, ema40) // EMA20 crosses above EMA40 (Buy signal)
bearCross = ta.crossunder(ema20, ema40) // EMA20 crosses below EMA40 (Sell signal)
// Plot EMA lines
plot(ema20, color=color.blue, title="EMA 20", linewidth=2)
plot(ema40, color=color.red, title="EMA 40", linewidth=2)
// Plot signals
plotshape(series=bullCross, title="Buy Signal", location=location.belowbar, style=shape.labelup, size=size.small, color=color.green, text="BUY")
plotshape(series=bearCross, title="Sell Signal", location=location.abovebar, style=shape.labeldown, size=size.small, color=color.red, text="SELL")
// Alert setup (optional)
alertcondition(bullCross, title="EMA Bullish Cross", message="EMA 20 crossed above EMA 40 - BUY!")
alertcondition(bearCross, title="EMA Bearish Cross", message="EMA 20 crossed below EMA 40 - SELL!")
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.