OPEN-SOURCE SCRIPT

Moving Average Simple

46
//version=5
indicator("EMA 20 and 200 Crossover Strategy", overlay=true)

// Input parameters
emaShortLength = input.int(20, title="Short EMA Length", minval=1)
emaLongLength = input.int(200, title="Long EMA Length", minval=1)

// Calculate EMAs
emaShort = ta.ema(close, emaShortLength) // 20-period EMA
emaLong = ta.ema(close, emaLongLength) // 200-period EMA

// Plot EMAs
plot(emaShort, color=color.blue, title="EMA 20", linewidth=2)
plot(emaLong, color=color.red, title="EMA 200", linewidth=2)

// Crossover Conditions
buySignal = ta.crossover(emaShort, emaLong) // EMA 20 crosses above EMA 200
sellSignal = ta.crossunder(emaShort, emaLong) // EMA 20 crosses below EMA 200

// Plot Buy/Sell Signals
plotshape(series=buySignal, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(series=sellSignal, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")

// Alerts
alertcondition(buySignal, title="Buy Signal Alert", message="EMA 20 crossed above EMA 200: Buy Signal")
alertcondition(sellSignal, title="Sell Signal Alert", message="EMA 20 crossed below EMA 200: Sell Signal")

כתב ויתור

המידע והפרסומים אינם אמורים להיות, ואינם מהווים, עצות פיננסיות, השקעות, מסחר או סוגים אחרים של עצות או המלצות שסופקו או מאושרים על ידי TradingView. קרא עוד בתנאים וההגבלות.