Futures Bot | EMA + RSI + ATR — Strategy by Ericvalmond

By version

Performance Metrics

Description

// ============================================================// FUTURES TRADING BOT — Pine Script v5// Compatible with: Crypto Futures, Forex, Stock Futures// Features: EMA Trend + RSI + ATR-based Risk Management// ============================================================//version=5strategy( title = "Futures Bot | EMA + RSI + ATR", shorttitle = "FuturesBot", overlay = true, default_qty_type = strategy.percent_of_equity, default_qty_value = 5, commission_type = strategy.commission.percent, commission_value = 0.05, slippage = 2, pyramiding = 0)// ─────────────────────────────────────────────// ░░ USER INPUTS// ─────────────────────────────────────────────grp_trend = "📈 Trend Filter (EMA)"ema_fast = input.int(21, "Fast EMA", minval=5, maxval=200, group=grp_trend)ema_slow = input.int(55, "Slow EMA", minval=10, maxval=500, group=grp_trend)ema_trend = input.int(200, "Trend EMA", minval=50, maxval=500, group=grp_trend)grp_rsi = "📊 RSI Settings"rsi_len = input.int(14, "RSI Length", minval=5, maxval=50, group=grp_rsi)rsi_ob = input.int(70, "Overbought", minval=60, maxval=90, group=grp_rsi)rsi_os = input.int(30, "Oversold", minval=10, maxval=40, group=grp_rsi)grp_risk = "🛡️ Risk Management"atr_len = input.int(14, "ATR Length", minval=5, maxval=50, group=grp_risk)sl_mult = input.float(1.5,"Stop Loss (ATR×)", minval=0.5, maxval=5.0, step=0.1, group=grp_risk)tp_mult = input.float(3.0,"Take Profit (ATR×)", minval=1.0, maxval=10.0,step=0.1, group=grp_risk)trail_stop = input.bool(true, "Use Trailing Stop", group=grp_risk)trail_mult = input.float(1.0, "Trailing ATR×", minval=0.5, maxval=3.0, step=0.1, group=grp_risk)grp_vol = "📦 Volume Filter"use_vol = input.bool(true, "Require Above-Average Volume", group=grp_vol)vol_len = input.int(20, "Volume MA Length", minval=5, maxval=100, group=grp_vol)// ─────────────────────────────────────────────// ░░ INDICATORS// ─────────────────────────────────────────────ema21 = ta.ema(close, ema_fast)ema55 = ta.ema(close, ema_slow)ema200 = ta.ema(close, ema_trend)rsi = ta.rsi(close, rsi_len)atr = ta.atr(atr_len)vol_ma = ta.sma(volume, vol_len)vol_ok = use_vol ? volume > vol_ma : true// ─────────────────────────────────────────────// ░░ SIGNAL CONDITIONS// ─────────────────────────────────────────────bull_trend = ema21 > ema55 and ema55 > ema200bear_trend = ema21 40 and rsi rsi_osbull_candle = close > open and close > close[1]bear_candle = close 0 if trail_stop strategy.exit("Long Exit", "Long", trail_offset = atr * trail_mult / syminfo.mintick, limit = take_profit, stop = stop_loss) else strategy.exit("Long Exit", "Long", stop=stop_loss, limit=take_profit) if ta.crossunder(ema21, ema55) strategy.close("Long", comment="EMA Exit")if strategy.position_size ema55 ? color.new(color.green, 85) : color.new(color.red, 85))plotshape(long_signal, title="Long", style=shape.triangleup, location=location.belowbar, color=color.new(#00E676, 0), size=size.normal, text="LONG")plotshape(short_signal, title="Short", style=shape.triangledown, location=location.abovebar, color=color.new(#FF1744, 0), size=size.normal, text="SHORT")plot(strategy.position_size != 0 ? stop_loss : na, "Stop Loss", color=color.red, style=plot.style_linebr, linewidth=1)plot(strategy.position_size != 0 ? take_profit : na, "Take Profit", color=color.green, style=plot.style_linebr, linewidth=1)// ─────────────────────────────────────────────// ░░ HUD TABLE// ─────────────────────────────────────────────var table info = table.new(position.top_right, 2, 7, bgcolor = color.new(color.black, 60), border_color = color.new(color.gray, 40), border_width = 1, frame_color = color.new(color.gray, 30), frame_width = 1)if barstate.islast pos_str = strategy.position_size > 0 ? "🟢 LONG" : strategy.position_size rsi_ob ? color.red : rsi < rsi_os ? color.green : color.white, text_size=size.small) table.cell(info, 0, 4, "ATR", text_color=color.gray, text_size=size.small) table.cell(info, 1, 4, str.tostring(math.round(atr, 4)), text_color=color.white, text_size=size.small) table.cell(info, 0, 5, "R:R", text_color=color.gray, text_size=size.small) table.cell(info, 1, 5, "1 : " + str.tostring(rr_ratio), text_color=color.yellow, text_size=size.small) table.cell(info, 0, 6, "Volume", text_color=color.gray, text_size=size.small) table.cell(info, 1, 6, vol_ok ? "✓ OK" : "✗ Low", text_color=vol_ok ? color.green : color.red, text_size=size.small)// ─────────────────────────────────────────────// ░░ ALERTS// ─────────────────────────────────────────────alertcondition(long_signal, title="🟢 Long Entry", message="FuturesBot: LONG on {{ticker}} @ {{close}}")alertcondition(short_signal, title="🔴 Short Entry", message="FuturesBot: SHORT on {{ticker}} @ {{close}}")

Browse all 5,900+ TradingView Pine Script strategies

View on TradingView