Strategy · Pine Script v5 · On the chart

Gold Dominator Pro

by thanvish21· code credited to GoldDominatorPro v3.0 - STRATEGY VERSION (for backtesting)

Gold Dominator Pro is an overlay strategy aimed at gold.

View on GitHub

GitHub stars1on the repository
Pine versionv5runs as is
Lines of code204
Settings29inputs
LicenceNone statedfile: MPL-2.0
Last update2 months ago7 Aug 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.

Source Code

204 lines of Pine Script v5 from Gold_Dominator_Pro_v3_STRATEGY.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

Gold_Dominator_Pro_v3_STRATEGY.pine
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0
// © GoldDominatorPro v3.0 - STRATEGY VERSION (for backtesting)

//@version=5
strategy("Gold Dominator Pro v3.0 [Strategy]", shorttitle="GDP v3.0 [BT]", overlay=true,
     initial_capital=10000, default_qty_type=strategy.percent_of_equity,
     default_qty_value=100, commission_type=strategy.commission.cash_per_order,
     commission_value=7, slippage=2, pyramiding=0,
     process_orders_on_close=false, calc_on_every_tick=false,
     use_bar_magnifier=true)

// ============================================================================
// INPUTS
// ============================================================================

grp_trend = "═══ TREND (H4) ═══"
ema_fast_len = input.int(21, "Fast EMA", group=grp_trend)
ema_mid_len  = input.int(55, "Medium EMA", group=grp_trend)
ema_slow_len = input.int(200, "Slow EMA", group=grp_trend)
htf = input.timeframe("240", "Trend TF", group=grp_trend)

grp_mom = "═══ MOMENTUM ═══"
rsi_len    = input.int(14, "RSI Period", group=grp_mom)
rsi_ob     = input.int(72, "RSI OB", group=grp_mom)
rsi_os     = input.int(28, "RSI OS", group=grp_mom)
macd_f     = input.int(12, "MACD Fast", group=grp_mom)
macd_s     = input.int(26, "MACD Slow", group=grp_mom)
macd_sig   = input.int(9,  "MACD Signal", group=grp_mom)
stk        = input.int(14, "StochRSI K", group=grp_mom)
std        = input.int(3,  "StochRSI D", group=grp_mom)
sts        = input.int(3,  "StochRSI Smooth", group=grp_mom)

grp_vol = "═══ VOLATILITY ═══"
atr_len       = input.int(14, "ATR Period", group=grp_vol)
adx_len       = input.int(14, "ADX Period", group=grp_vol)
adx_thresh    = input.int(20, "ADX Threshold", group=grp_vol)
vol_sma_len   = input.int(20, "Volume SMA", group=grp_vol)
vol_mult      = input.float(1.2, "Volume Mult", group=grp_vol)

grp_risk = "═══ RISK ═══"
sl_mult  = input.float(1.5, "SL ATR Mult", step=0.1, group=grp_risk)
tp1_mult = input.float(1.2, "TP1 ATR Mult", step=0.1, group=grp_risk)
tp2_mult = input.float(2.0, "TP2 ATR Mult", step=0.1, group=grp_risk)
tp3_mult = input.float(3.0, "TP3 ATR Mult", step=0.1, group=grp_risk)
tp1_pct  = input.float(50, "TP1 Close %", step=5, group=grp_risk)
tp2_pct  = input.float(30, "TP2 Close %", step=5, group=grp_risk)

grp_sess = "═══ SESSION ═══"
use_sess = input.bool(true, "Session Filter", group=grp_sess)

grp_eq = "═══ EQUITY FILTER ═══"
use_eq_filter  = input.bool(true, "Equity Curve Filter", group=grp_eq, tooltip="Only trade when equity is above its own moving average — skips drawdown periods")
eq_ema_len     = input.int(20, "Equity EMA Length", group=grp_eq, minval=5, maxval=100)

grp_dd = "═══ DRAWDOWN GUARD ═══"
use_dd_guard   = input.bool(true, "Max Drawdown Guard", group=grp_dd)
max_dd_pct     = input.float(10.0, "Max Drawdown %", group=grp_dd, step=1.0, minval=1, maxval=50)

// ============================================================================
// CALCULATIONS
// ============================================================================

// H4 Trend
htf_ef = request.security(syminfo.tickerid, htf, ta.ema(close, ema_fast_len))
htf_em = request.security(syminfo.tickerid, htf, ta.ema(close, ema_mid_len))
htf_es = request.security(syminfo.tickerid, htf, ta.ema(close, ema_slow_len))
bull_trend = close > htf_es and htf_ef > htf_em
bear_trend = close < htf_es and htf_ef < htf_em

// Momentum
rsi = ta.rsi(close, rsi_len)
[ml, sl2, hl] = ta.macd(close, macd_f, macd_s, macd_sig)
rsi_stoch_raw = (ta.rsi(close, stk) - ta.lowest(ta.rsi(close, stk), stk)) / (ta.highest(ta.rsi(close, stk), stk) - ta.lowest(ta.rsi(close, stk), stk)) * 100
sk = ta.sma(rsi_stoch_raw, sts)
sd = ta.sma(sk, std)
stoch_up   = ta.crossover(sk, sd) and sk[1] < 20
stoch_down = ta.crossunder(sk, sd) and sk[1] > 80

// Volatility
atr = ta.atr(atr_len)
[dp, dm, adx] = ta.dmi(adx_len, adx_len)
vsma = ta.sma(volume, vol_sma_len)

// Session
hr = hour(time, "UTC")
in_session = use_sess ? ((hr >= 8 and hr < 11) or (hr >= 13 and hr < 17)) : true

// ============================================================================
// EQUITY CURVE FILTER
// ============================================================================

eq = strategy.equity
var float eq_ema = na
eq_ema := na(eq_ema) ? eq : eq_ema + (2.0 / (eq_ema_len + 1)) * (eq - eq_ema)
eq_ok = use_eq_filter ? eq >= eq_ema : true

// ============================================================================
// DRAWDOWN GUARD
// ============================================================================

var float peak_eq = na
peak_eq := na(peak_eq) ? eq : math.max(peak_eq, eq)
current_dd = (peak_eq - eq) / peak_eq * 100
dd_ok = use_dd_guard ? current_dd < max_dd_pct : true

// ============================================================================
// SCORING (10 conditions x 10 points = 100 max)
// ============================================================================

l_score = (bull_trend ? 10 : 0) + (close > htf_es ? 10 : 0) + (rsi > 45 and rsi < rsi_ob ? 10 : 0) + (hl > 0 ? 10 : 0) + (stoch_up ? 10 : 0) + (adx > adx_thresh ? 10 : 0) + (close > ta.lowest(close, 20) ? 10 : 0) + (volume > vsma * vol_mult ? 10 : 0) + (in_session ? 10 : 0) + (atr > 0 ? 10 : 0)
s_score = (bear_trend ? 10 : 0) + (close < htf_es ? 10 : 0) + (rsi < 55 and rsi > rsi_os ? 10 : 0) + (hl < 0 ? 10 : 0) + (stoch_down ? 10 : 0) + (adx > adx_thresh ? 10 : 0) + (close < ta.highest(close, 20) ? 10 : 0) + (volume > vsma * vol_mult ? 10 : 0) + (in_session ? 10 : 0) + (atr > 0 ? 10 : 0)

buy  = l_score >= 80 and stoch_up and eq_ok and dd_ok
sell = s_score >= 80 and stoch_down and eq_ok and dd_ok

// ============================================================================
// STRATEGY EXECUTION WITH PROPER ENTRY-PRICE-BASED EXITS
// ============================================================================

var float entry_px = na

if buy and strategy.position_size == 0
    entry_px := close
    strategy.entry("Long", strategy.long)

if sell and strategy.position_size == 0
    entry_px := close
    strategy.entry("Short", strategy.short)

// Set exits based on stored entry price (avoids recalculating on subsequent bars)
if strategy.position_size > 0 and not na(entry_px)
    float sl_l = entry_px - atr[1] * sl_mult
    float t1_l = entry_px + atr[1] * tp1_mult
    float t2_l = entry_px + atr[1] * tp2_mult
    float t3_l = entry_px + atr[1] * tp3_mult
    strategy.exit("TP1_L", "Long", qty_percent=tp1_pct, limit=t1_l, stop=sl_l)
    strategy.exit("TP2_L", "Long", qty_percent=tp2_pct, limit=t2_l, stop=sl_l)
    strategy.exit("TP3_L", "Long", limit=t3_l, stop=sl_l)

if strategy.position_size < 0 and not na(entry_px)
    float sl_s = entry_px + atr[1] * sl_mult
    float t1_s = entry_px - atr[1] * tp1_mult
    float t2_s = entry_px - atr[1] * tp2_mult
    float t3_s = entry_px - atr[1] * tp3_mult
    strategy.exit("TP1_S", "Short", qty_percent=tp1_pct, limit=t1_s, stop=sl_s)
    strategy.exit("TP2_S", "Short", qty_percent=tp2_pct, limit=t2_s, stop=sl_s)
    strategy.exit("TP3_S", "Short", limit=t3_s, stop=sl_s)

if strategy.position_size == 0
    entry_px := na

// ============================================================================
// PERFORMANCE METRICS TABLE
// ============================================================================

if barstate.islast
    var table perf = table.new(position.bottom_right, 2, 8, bgcolor=color.new(#1a1a2e, 10), frame_color=color.new(#ffffff, 80), frame_width=1, border_color=color.new(#ffffff, 90), border_width=1)

    net_pnl = strategy.netprofit
    gross_pnl = strategy.grossprofit + strategy.grossloss
    win_rate = strategy.wintrades / math.max(strategy.closedtrades, 1) * 100
    pf = strategy.grossloss != 0 ? math.abs(strategy.grossprofit / strategy.grossloss) : 999
    avg_win = strategy.wintrades > 0 ? strategy.grossprofit / strategy.wintrades : 0
    avg_loss = strategy.losstrades > 0 ? math.abs(strategy.grossloss / strategy.losstrades) : 0

    table.cell(perf, 0, 0, "PERFORMANCE", text_color=#ffaa00, text_size=size.normal, bgcolor=color.new(#1a1a2e, 0))
    table.merge_cells(perf, 0, 0, 1, 0)

    table.cell(perf, 0, 1, "Net Profit", text_color=color.white, text_size=size.small)
    table.cell(perf, 1, 1, "$" + str.tostring(net_pnl, "#.##"), text_color=net_pnl >= 0 ? #00ff88 : #ff4444, text_size=size.small)

    table.cell(perf, 0, 2, "Win Rate", text_color=color.white, text_size=size.small)
    table.cell(perf, 1, 2, str.tostring(win_rate, "#.#") + "%", text_color=win_rate >= 75 ? #00ff88 : win_rate >= 60 ? #ffaa00 : #ff4444, text_size=size.small)

    table.cell(perf, 0, 3, "Profit Factor", text_color=color.white, text_size=size.small)
    table.cell(perf, 1, 3, str.tostring(pf, "#.##"), text_color=pf >= 2 ? #00ff88 : pf >= 1.5 ? #ffaa00 : #ff4444, text_size=size.small)

    table.cell(perf, 0, 4, "Total Trades", text_color=color.white, text_size=size.small)
    table.cell(perf, 1, 4, str.tostring(strategy.closedtrades), text_color=color.white, text_size=size.small)

    table.cell(perf, 0, 5, "Avg Win", text_color=color.white, text_size=size.small)
    table.cell(perf, 1, 5, "$" + str.tostring(avg_win, "#.##"), text_color=#00ff88, text_size=size.small)

    table.cell(perf, 0, 6, "Avg Loss", text_color=color.white, text_size=size.small)
    table.cell(perf, 1, 6, "$" + str.tostring(avg_loss, "#.##"), text_color=#ff4444, text_size=size.small)

    table.cell(perf, 0, 7, "Max DD", text_color=color.white, text_size=size.small)
    table.cell(perf, 1, 7, str.tostring(current_dd, "#.#") + "%", text_color=current_dd < 5 ? #00ff88 : current_dd < 10 ? #ffaa00 : #ff4444, text_size=size.small)

// ============================================================================
// VISUALS
// ============================================================================

plot(ta.ema(close, ema_fast_len), "EMA 21",  color=#00ff88, linewidth=1)
plot(ta.ema(close, ema_mid_len),  "EMA 55",  color=#ffaa00, linewidth=1)
plot(ta.ema(close, ema_slow_len), "EMA 200", color=#ff4444, linewidth=2)

bgcolor(bull_trend ? color.new(#00ff88, 93) : bear_trend ? color.new(#ff4444, 93) : na)

plotshape(buy,  "BUY",  shape.labelup,   location.belowbar, #00ff88, text="BUY",  textcolor=color.white)
plotshape(sell, "SELL", shape.labeldown, location.abovebar, #ff4444, text="SELL", textcolor=color.white)

// Equity curve filter visualization
plot(use_eq_filter ? eq_ema : na, "Equity EMA", color=color.new(#ffaa00, 50), display=display.status_line)

Overview

Gold Dominator Pro reads a higher-timeframe trend from three exponential moving averages and includes RSI, MACD, Stochastic RSI, ADX, ATR, and volume settings. Optional session, equity-curve, and maximum-drawdown guards can restrict trading. Risk inputs define an ATR stop and three scaled ATR take-profit levels with partial closes. The supplied excerpt ends before the complete entry conditions are shown.

Details

Published by

thanvish21 on GitHub

Code credit

GoldDominatorPro v3.0 - STRATEGY VERSION (for backtesting), as written in the script's header

Type

Strategy, Pine Script v5

Draws

On the price chart

Category

Trend, Moving averages, Oscillators & momentum, Volatility & bands

Markets

Gold

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

cryptopine-scripttradingxauusd

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Fast EMAint21ema_fast_len
Medium EMAint55ema_mid_len
Slow EMAint200ema_slow_len
Trend TFtimeframe240htf
RSI Periodint14rsi_len
RSI OBint72rsi_ob
RSI OSint28rsi_os
MACD Fastint12macd_f
MACD Slowint26macd_s
MACD Signalint9macd_sig
StochRSI Kint14stk
StochRSI Dint3std
Show all 29 settings
SettingTypeDefaultVariable
StochRSI Smoothint3sts
ATR Periodint14atr_len
ADX Periodint14adx_len
ADX Thresholdint20adx_thresh
Volume SMAint20vol_sma_len
Volume Multfloat1.2vol_mult
SL ATR Multfloat1.5sl_mult
TP1 ATR Multfloat1.2tp1_mult
TP2 ATR Multfloat2.0tp2_mult
TP3 ATR Multfloat3.0tp3_mult
TP1 Close %float50tp1_pct
TP2 Close %float30tp2_pct
Session Filterbooltrueuse_sess
Equity Curve Filterbooltrueuse_eq_filter
Equity EMA Lengthint20eq_ema_len
Max Drawdown Guardbooltrueuse_dd_guard
Max Drawdown %float10.0max_dd_pct
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

106 stars

This trading strategy combines three Exponential Moving Averages (8, 14, and 50 periods by default) with Stochastic RSI and Average True Range (ATR). It enters a long position when EMA 1 is above EMA 2, EMA 2 is above EMA 3, and the Stochastic RSI %K line cros

Strategy v4 TrendOscillators & momentum
Updated 2 years ago · GPL-3.0 GitHub repository of 3 x EMA + Stochastic RSI + ATR

Momentum Rider DAILY FINAL

by greenpeas007
58 stars

This strategy combines exponential moving averages (EMA 9, 21, 50), RSI, MACD, and Supertrend indicators to enter long positions. It triggers trades using six dynamic setups based on momentum breakouts, EMA crossovers, and pullbacks. Position sizing is compute

Strategy v6 TrendOscillators & momentum Repaints
Updated 4 months ago · Custom licence GitHub repository of Momentum Rider DAILY FINAL

CombinedBinHAndClucV6

by viktors1982
36 stars

CombinedBinHAndClucV6 is a trading strategy based on the popular BinHV45 and ClucMay72018 algorithms. It calculates dual Bollinger Bands, Exponential Moving Averages, Relative Strength Index, Average True Range, and volume metrics across primary and one-hour h

Strategy v4 Volatility & bandsOscillators & momentum Repaints
Updated 2 years ago · None stated GitHub repository of CombinedBinHAndClucV6

BB Swing

by benso87
24 stars

This strategy calculates Bollinger Bands, a configurable moving average slope, Stochastic RSI, ATR, and ADX directly on the price chart. It evaluates trend bias and momentum conditions to generate long and short swing entries using percent-of-equity sizing. Th

Strategy v5 Volatility & bandsOscillators & momentum
Updated 4 years ago · MPL-2.0 GitHub repository of BB Swing

This strategy trades long and short on the price chart using a multi-timeframe TradingLatino setup. It requires EMA 10 to cross or sit above or below EMA 55 on the one-hour, four-hour, and daily charts, together with a positive ADX slope, a directional monitor

Strategy v5 TrendMoving averages
Updated 1 year ago · None stated GitHub repository of Ruckard ABCBitcoin TradingLatino A010

More strategys

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers