OPEN-SOURCE SCRIPT

TREND PULL BACK BUY SELL

262
//version=5
indicator("Clean Signal Bot 24/7 ($250 SL)", overlay=true)

// ===== SETTINGS =====
riskDollars = 250.0
pointValue = syminfo.pointvalue

// ===== INDICATORS =====
fastEMA = ta.ema(close, 9)
slowEMA = ta.ema(close, 21)
rsi = ta.rsi(close, 14)

// ===== TREND =====
bullTrend = fastEMA > slowEMA
bearTrend = fastEMA < slowEMA

// ===== PULLBACK =====
pullbackLong = close < fastEMA and close > slowEMA
pullbackShort = close > fastEMA and close < slowEMA

// ===== CANDLE CONFIRM =====
bullCandle = close > open
bearCandle = close < open

// ===== ENTRY SIGNALS =====
buySignal = bullTrend and pullbackLong and bullCandle and rsi > 50
sellSignal = bearTrend and pullbackShort and bearCandle and rsi < 50

// ===== TRADE STATE =====
var bool inLong = false
var bool inShort = false
var float entry = na
var float stop = na

riskPoints = riskDollars / pointValue

// ===== ENTER =====
if buySignal
inLong := true
inShort := false
entry := close
stop := entry - riskPoints

if sellSignal
inShort := true
inLong := false
entry := close
stop := entry + riskPoints

// ===== EXIT =====
exitLong = inLong and (close <= stop or bearTrend)
exitShort = inShort and (close >= stop or bullTrend)

if exitLong
inLong := false

if exitShort
inShort := false

// ===== CANDLE HIGHLIGHT =====
barcolor(
buySignal ? color.lime :
sellSignal ? color.red :
exitLong or exitShort ? color.yellow :
na)

// ===== LABELS =====
if buySignal
label.new(bar_index, low, "BUY", style=label.style_label_up, color=color.lime, textcolor=color.black)

if sellSignal
label.new(bar_index, high, "SELL", style=label.style_label_down, color=color.red, textcolor=color.white)

if exitLong or exitShort
label.new(bar_index, close, "EXIT", style=label.style_label_left, color=color.yellow, textcolor=color.black)

// ===== ALERTS =====
alertcondition(buySignal, "BUY ENTRY", "BUY SIGNAL")
alertcondition(sellSignal, "SELL ENTRY", "SELL SIGNAL")
alertcondition(exitLong or exitShort, "EXIT TRADE", "EXIT SIGNAL")

Declinazione di responsabilità

Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.