OPEN-SOURCE SCRIPT

1.618 Strategy Full System

72
//version=5
strategy("1.618 Strategy Full System", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10)

// === SETTINGS ===
fibo_ratio = 1.618
atr_len = 14
risk_reward = 2.0

// === TREND DETECTION ===
ema_fast = ta.ema(close, 21)
ema_slow = ta.ema(close, 55)
trend_up = ema_fast > ema_slow
trend_down = ema_fast < ema_slow

// === MARKET STRUCTURE: SWING HIGH/LOW ===
swing_high = ta.pivothigh(high, 5, 5)
swing_low = ta.pivotlow(low, 5, 5)

// === FVG / Yetim svecha ===
fvg_up = low[2] > high
fvg_dn = high[2] < low

// === ORDER BLOCK (OB) ===
ob_bullish = close[1] < open[1] and close > open
ob_bearish = close[1] > open[1] and close < open

// === CANDLESTICK PATTERN: Engulfing ===
bullish_engulfing = close > open and open < close[1] and close[1] < open[1]
bearish_engulfing = close < open and open > close[1] and close[1] > open[1]

// === FIBONACCI 1.618 TARGET ===
entry_long = ta.valuewhen(trend_up and bullish_engulfing and ob_bullish and fvg_up, close, 0)
entry_short = ta.valuewhen(trend_down and bearish_engulfing and ob_bearish and fvg_dn, close, 0)

tp_long = entry_long + (math.abs(entry_long - swing_low)) * fibo_ratio
sl_long = swing_low

tp_short = entry_short - (math.abs(swing_high - entry_short)) * fibo_ratio
sl_short = swing_high

// === EXECUTE STRATEGY ===
if trend_up and bullish_engulfing and ob_bullish and fvg_up
strategy.entry("Long", strategy.long, comment="Long Entry")
strategy.exit("TP/SL Long", from_entry="Long", limit=tp_long, stop=sl_long)

if trend_down and bearish_engulfing and ob_bearish and fvg_dn
strategy.entry("Short", strategy.short, comment="Short Entry")
strategy.exit("TP/SL Short", from_entry="Short", limit=tp_short, stop=sl_short)

// === PLOTTING ===
plotshape(bullish_engulfing and trend_up, location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(bearish_engulfing and trend_down, location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.