OPEN-SOURCE SCRIPT
EMA 9/21 Crossover + ATR Stops (v5)

//version=5
indicator("EMA 9/21 Crossover + ATR Stops (v5)", overlay=true)
emaFastLen = input.int(9, "EMA Fast")
emaSlowLen = input.int(21, "EMA Slow")
atrLen = input.int(14, "ATR Length")
slMult = input.float(1.0, "Stop x ATR", step=0.1)
tpMult = input.float(2.0, "Target x ATR", step=0.1)
emaF = ta.ema(close, emaFastLen)
emaS = ta.ema(close, emaSlowLen)
atr = ta.atr(atrLen)
longSignal = ta.crossover(emaF, emaS)
shortSignal = ta.crossunder(emaF, emaS)
// Optional guide levels for next bar after signal
longSL = longSignal ? close - atr * slMult : na
longTP = longSignal ? close + atr * tpMult : na
shortSL = shortSignal ? close + atr * slMult : na
shortTP = shortSignal ? close - atr * tpMult : na
plot(emaF, "EMA Fast", color=color.new(color.teal, 0))
plot(emaS, "EMA Slow", color=color.new(color.orange, 0))
plot(longSL, "Long SL", color=color.new(color.red, 0), style=plot.style_linebr)
plot(longTP, "Long TP", color=color.new(color.lime, 0), style=plot.style_linebr)
plot(shortSL, "Short SL", color=color.new(color.red, 0), style=plot.style_linebr)
plot(shortTP, "Short TP", color=color.new(color.lime, 0), style=plot.style_linebr)
plotshape(longSignal, title="Long", text="Buy", style=shape.labelup, color=color.new(color.lime, 0), location=location.belowbar)
plotshape(shortSignal, title="Short", text="Sell", style=shape.labeldown, color=color.new(color.red, 0), location=location.abovebar)
// Alerts
alertcondition(longSignal, title="EMA Long", message="EMA 9/21 LONG crossover")
alertcondition(shortSignal, title="EMA Short", message="EMA 9/21 SHORT crossunder")
indicator("EMA 9/21 Crossover + ATR Stops (v5)", overlay=true)
emaFastLen = input.int(9, "EMA Fast")
emaSlowLen = input.int(21, "EMA Slow")
atrLen = input.int(14, "ATR Length")
slMult = input.float(1.0, "Stop x ATR", step=0.1)
tpMult = input.float(2.0, "Target x ATR", step=0.1)
emaF = ta.ema(close, emaFastLen)
emaS = ta.ema(close, emaSlowLen)
atr = ta.atr(atrLen)
longSignal = ta.crossover(emaF, emaS)
shortSignal = ta.crossunder(emaF, emaS)
// Optional guide levels for next bar after signal
longSL = longSignal ? close - atr * slMult : na
longTP = longSignal ? close + atr * tpMult : na
shortSL = shortSignal ? close + atr * slMult : na
shortTP = shortSignal ? close - atr * tpMult : na
plot(emaF, "EMA Fast", color=color.new(color.teal, 0))
plot(emaS, "EMA Slow", color=color.new(color.orange, 0))
plot(longSL, "Long SL", color=color.new(color.red, 0), style=plot.style_linebr)
plot(longTP, "Long TP", color=color.new(color.lime, 0), style=plot.style_linebr)
plot(shortSL, "Short SL", color=color.new(color.red, 0), style=plot.style_linebr)
plot(shortTP, "Short TP", color=color.new(color.lime, 0), style=plot.style_linebr)
plotshape(longSignal, title="Long", text="Buy", style=shape.labelup, color=color.new(color.lime, 0), location=location.belowbar)
plotshape(shortSignal, title="Short", text="Sell", style=shape.labeldown, color=color.new(color.red, 0), location=location.abovebar)
// Alerts
alertcondition(longSignal, title="EMA Long", message="EMA 9/21 LONG crossover")
alertcondition(shortSignal, title="EMA Short", message="EMA 9/21 SHORT crossunder")
סקריפט קוד פתוח
ברוח TradingView אמיתית, היוצר של הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יכולים לבדוק ולאמת את הפונקציונליות שלו. כל הכבוד למחבר! למרות שאתה יכול להשתמש בו בחינם, זכור שפרסום מחדש של הקוד כפוף לכללי הבית שלנו.
כתב ויתור
המידע והפרסומים אינם אמורים להיות, ואינם מהווים, עצות פיננסיות, השקעות, מסחר או סוגים אחרים של עצות או המלצות שסופקו או מאושרים על ידי TradingView. קרא עוד בתנאים וההגבלות.
סקריפט קוד פתוח
ברוח TradingView אמיתית, היוצר של הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יכולים לבדוק ולאמת את הפונקציונליות שלו. כל הכבוד למחבר! למרות שאתה יכול להשתמש בו בחינם, זכור שפרסום מחדש של הקוד כפוף לכללי הבית שלנו.
כתב ויתור
המידע והפרסומים אינם אמורים להיות, ואינם מהווים, עצות פיננסיות, השקעות, מסחר או סוגים אחרים של עצות או המלצות שסופקו או מאושרים על ידי TradingView. קרא עוד בתנאים וההגבלות.