Gold Trend Dip
A rule-based intraday strategy for gold. On 3-minute bars it counts how many of the last 20 close-to-close changes were up and how many were down.
- Market
- gold, under any of the names it trades as.
- Runs on
- any accepted symbol, 3-minute chart (required).
Free on request during the launch period.
Open on TradingView

Screenshots show what the script draws. They show no results — TradingView's own Strategy Tester report on the script page is the only place those appear.
The rules, in full
- Count the last 20 bar-to-bar close changes: up (close above the previous close) vs down. If they are equal, nothing happens.
- Long: more up than down, and the bar closes below the lowest of the 3 previous closes.
- Short: more down than up, and the bar closes above the highest of the 3 previous closes.
- Decisions only on bars that close between 08:00 and 12:30 ET (both included) and before 13:25 ET. These are wall-clock ET times on every symbol: on an exchange in another part of the world the window lands at a different local hour, and you would have to choose and test your own.
- Entry: market order on the next bar's open.
- Stop = 0.35 x U from the entry fill, rounded up to whole ticks of that symbol. Target = the same distance (1:1). U = median high-low range of the previous 20 daily bars of that symbol. The target counts only when price trades 1 tick through it.
- After a signal, no new signal for 150 minutes. At most 3 signals per session (in practice 2 fit). Each signal is its own trade with its own stop and target, so trades can overlap.
- No hedging: a signal opposite to an open trade is skipped, but it still counts toward the daily limit and starts the 150-minute wait.
- Any trade still open is closed at market at 16:09 ET (order sent on the bar closing at or after 16:09 ET, filled at the next bar's open). On a session where no bar closes that late - an early-close futures day, or every day on an ETF - no such order is sent and the trade carries over with its stop and target still working. Change "Hard close" to a time your symbol actually reaches.
That is the whole rule set, exactly as published. Nothing is held back for subscribers.
What you see on the chart
- Green ▲ LONG label below or red ▼ SHORT label above the entry bar (the bar after the signal, where the Strategy Tester fills the order at the open); hover for the real fill price, stop and target. The signal bar background lights up green or red (optional), gray when no order was sent.
- Small gray "LONG skipped" / "SHORT skipped" label when a signal is opposite to an open trade. With "Enable trading" off the signal label is gray and reads "(no order)".
- "EXIT +/- pts" label at the real exit bar and fill price; hover for the reason (Target hit, Stop hit or Time exit) and the net result of that trade in the account currency.
- While a trade is open: white entry line, red stop line, green target line (for the most recent open trade), each named with its price at the right edge, with light red (risk) and light green (target) zones.
- Light blue shading over the decision window.
- Compact status box (top right): the symbol and how it was read (gold futures / spot / CFD gold / gold ETF); state (WAITING, ARMED with the trigger close, IN LONG / IN SHORT with stop and target, Done for today, or OFF on a non-gold symbol or wrong timeframe); U and stop/target distance; signals today and on chart; a short yellow note if none yet; an orange reminder on spot / CFD and ETF symbols about Properties and the hard close. Hover a row for more. "Show details" adds window, hard close, last setup and history loaded.
- Banner in the middle of the chart: red on a symbol that is not gold (no orders unless the market lock is overridden), yellow when the chart is not 3-minute (no signals).
Alerts
1. Open a 3-minute gold chart - XAUUSD, GOLD, GC1!, MGC1!, GLD... - and add the strategy.
2. Create Alert: Condition = this strategy, then "alert() function calls only". TradingView calls this a technical alert, and a free Basic account cannot create one - Basic allows 3 price alerts and no technical alerts at all, so the Create Alert dialog will not let you save it. Essential is the lowest plan that works (20 technical alerts); Plus 100, Premium 400. On Essential and Plus an alert also expires after two months and has to be created again; on Premium and Ultimate it does not expire. Phone notifications themselves are free on every plan - tick "Notify on app" and have the TradingView app installed and signed in on the same account.
3. Each message is one short line: what happened and at what price first, then the exchange and ticker, then the numbers, separated by "|". Nothing else to read.
LONG 3886.9 on COMEX:GC1! | SL 3858.4 | TP 3943.9 | fills next open
EXIT 3904.2 on COMEX:GC1! | Target hit | +17.3 pts | position 0
EXIT at market on OANDA:XAUUSD | hard close 16:09 ET
SHORT SKIPPED on AMEX:GLD | opposite position open
ARMED on OANDA:XAUUSD | LONG if close < 3880.1
The ticker is in every line, so you can watch several gold symbols at once and still tell them apart at a glance. Alerts are per chart: create one on each symbol you want watched.
4. Messages fire once per bar close. Three toggles in the Alerts group: entry signals (LONG / SHORT and SKIPPED), exits (EXIT and hard close) and setup armed (off by default). Entry alerts still fire when "Enable trading" is off, but not on non-gold symbols unless the market lock is overridden.
5. Free Basic plan, the nearest workaround: the status box's last row prints a "Price alert" level - the price a 3-minute bar has to CLOSE through for a signal (both sides while the direction is unsettled, one once the box says ARMED). A Basic account cannot alert on the strategy, but it can set a plain price alert on the symbol at that number (Alt+A, Condition = the symbol, "Crossing", Notify on app). Be clear about what it is: it rings when price TOUCHES the level, so it fires earlier and more often than the rule trades, and the level is the extreme of the last 3 closes, so it moves with every bar. Treat it as "go and look at the chart", never as a signal.
Settings
- Enable trading: off = signals, labels and alerts only, no orders.
- Skip signals opposite to an open position (on). If you turn it off, an opposite signal closes and reverses the open trades.
- Override market lock (allow non-gold symbols): off by default. Gold is recognised by its contract root or ticker together with the instrument type, so the three families listed at the top (futures roots, XAU / GOLD spot and CFD quotes, the named bullion ETFs) are accepted while a mining share or a mining ETF is not. Turning the override on does not change any rule - it only lets orders through on a symbol the lock rejected, including a bullion ETF that is not on the list, and the times, the window and the hard close are still the New York ones you would have to set yourself.
- Signal, Session Settings and Exit groups: count length 20, pullback 3 closes, 3 signals per session (maximum 3), 150-minute wait, 08:00-12:30 ET window, 13:25 ET last decision, 16:09 ET hard close, 0.35 x U stop, 1:1 target, U from 20 sessions. These are the defaults the strategy is designed around; changing them changes the strategy. The hard close is the one you are expected to adjust per instrument.
- Alerts, Display Options and Colors.
- Properties default to 100,000 USD initial capital, 1 contract per signal, pyramiding 3, 1.20 commission per contract per side (a micro-futures figure), 1 tick slippage and 5% margin. Enter your own size and cost for the instrument you trade - these defaults are wrong for spot, for CFDs, for ETFs and for full-size GC.
Limits, and what this cannot do
- Pine fills at the next bar's open plus 1 tick and estimates the price path inside each bar (a bar touching both stop and target is a guess); results on chart bars can differ from live fills.
- Different gold symbols are different data: a spot feed, a futures contract and an ETF do not print the same bars, do not keep the same hours and do not start their daily bar at the same time, so the same rule produces a different trade list on each. Read each one on its own chart.
- U comes from TradingView daily bars and can differ around futures contract rolls and short holiday sessions.
- On early-close days, change "No decisions from" and "Hard close" by hand.
- The script only sees its own trades.
Educational tool. Not financial advice. Past behaviour does not predict future results.
Before you decide
The script page on TradingView carries TradingView's own Strategy Tester report, generated by TradingView from this script. We do not write those numbers and we do not repeat them here. Read them at the source: Gold Trend Dip on TradingView.