بتكوين
شراء

Ema+rsi tp sl

198
//version=5
indicator("BTC EMA20/50 + RSI + TP/SL", overlay=true)

// === INPUTS ===
emaFastLen = input.int(20, title="EMA Fast (20)")
emaSlowLen = input.int(50, title="EMA Slow (50)")
rsiLen = input.int(14, title="RSI Period")
rsiSrc = input.source(close, title="RSI Source")
tpPercent = input.float(2.0, title="Take Profit (%)", minval=0.1)
slPercent = input.float(1.0, title="Stop Loss (%)", minval=0.1)

// === INDICATOR CALC ===
emaFast = ta.ema(close, emaFastLen)
emaSlow = ta.ema(close, emaSlowLen)
rsi = ta.rsi(rsiSrc, rsiLen)

// === SIGNAL CONDITIONS ===
buySignal = ta.crossover(rsi, 50) and emaFast > emaSlow and close > emaFast
sellSignal = ta.crossunder(rsi, 50) and emaFast < emaSlow and close < emaFast

// === TP & SL LEVELS ===
var float buyEntry = na
var float sellEntry = na
var float buyTP = na
var float sellTP = na
var float buySL = na
var float sellSL = na

if (buySignal)
buyEntry := close
buyTP := buyEntry * (1 + tpPercent / 100)
buySL := buyEntry * (1 - slPercent / 100)

if (sellSignal)
sellEntry := close
sellTP := sellEntry * (1 - tpPercent / 100)
sellSL := sellEntry * (1 + slPercent / 100)

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

// === PLOT TP/SL LINES ===
plot(buyTP, title="Buy TP", color=color.green, linewidth=1, style=plot.style_linebr, offset=0)
plot(buySL, title="Buy SL", color=color.red, linewidth=1, style=plot.style_linebr, offset=0)
plot(sellTP, title="Sell TP", color=color.green, linewidth=1, style=plot.style_linebr, offset=0)
plot(sellSL, title="Sell SL", color=color.red, linewidth=1, style=plot.style_linebr, offset=0)

// === ALERTS ===
alertcondition(buySignal, title="Buy Signal", message="BUY: EMA20>EMA50 and RSI>50")
alertcondition(sellSignal, title="Sell Signal", message="SELL: EMA20<EMA50 and RSI<50")

إخلاء المسؤولية

لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.