Strategy · Pine Script v5 · On the chart

XAUUSD Strategy - Hook Trap Guard

by aeiioaeiio

This strategy plots on the gold price chart and combines stochastic, RSI, and three EMAs with ATR.

View on GitHub

GitHub stars2on the repository
Pine versionv5runs as is
Lines of code674
Settings40inputs
LicenceNone stated
Last update4 months ago6 Jun 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above. It reads the file straight from GitHub.
  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

The code stays on GitHub. The author has not published this script under an open licence, so ForexR does not show its code. Copy script reads the file straight from GitHub into your clipboard, so you can still try it on your own chart. Ask the author before reusing the code anywhere else.

Overview

Confirm buys and sells can require an M15 overbought or oversold rejection wick, a Fibonacci or EMA zone, and a no-chase distance from the fast EMA. Optional LSB and LSS scalp legs stay off by default. Stops sit beyond a swing plus an ATR buffer, and targets use separate risk-reward ratios. A dashboard and signal marks are optional. It allows two stacked entries and can restrict trades to closed bars.

Details

Published by

aeiioaeiio on GitHub

Type

Strategy, Pine Script v5

Draws

On the price chart

Category

Oscillators & momentum, Moving averages, Scalping, Screeners & dashboards

Markets

Gold

Timeframes

M1-M5, M15-H1

Risk Notes

  • The strategy can add several entries in the same direction

Settings

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

SettingTypeDefaultVariable
Stoch Periodint5stochLen
Stoch Kint3stochKLen
Stoch Dint3stochDLen
RSI Periodint14rsiLen
EMA Fastint20emaFastLen
EMA Slowint50emaSlowLen
EMA Trendint200emaTrendLen
ATR Periodint14atrLen
Backtest ModestringConfirm Onlymode
Use Closed Bar OnlybooltrueuseConfirmedBar
Enable BUY CONFIRMbooltrueenableBuyConfirm
Enable SELL CONFIRMbooltrueenableSellConfirm
Show all 40 settings
SettingTypeDefaultVariable
Enable LSB SCALPboolfalseenableLsbScalp
Enable LSS SCALPboolfalseenableLssScalp
Show Disabled Scalp Marks for ReviewboolfalseshowDisabledLegs
M15 Sell OB Levelfloat70sellOb
M15 Buy OS Levelfloat30buyOs
M15 Rejection Wick %float0.35wickPct
Require M15 Trigger for ConfirmbooltruerequireM15
Fib Lookbackint50fibLookback
Fib/EMA Zone Tolerance x ATRfloat0.45fibTolAtr
No Chase Distance from EMA20 x ATRfloat1.35noChaseAtr
BUY Confirm TP RRfloat1.5rrBuyConfirm
SELL Confirm TP RRfloat1.6rrSellConfirm
Scalp TP RRfloat0.8rrScalp
Confirm SL Buffer x ATRfloat0.35slAtrBuf
Scalp SL Buffer x ATRfloat0.12scalpSlAtr
Confirm SL Swing Lookbackint8swingLb
Scalp SL Swing Lookbackint3scalpLb
Show DashboardbooltrueshowDash
Show SignalsbooltrueshowSignals
Show Watch MarksbooltrueshowWatch
Show Key FibbooltrueshowFib
Block Trade if SL too wideboolfalseuseRiskBlock
Max SL Distance (price points)float60.0maxSlPoints
Block Trade during ATR SpikebooltrueuseAtrSpikeBlock
ATR Spike MA Lengthint50atrSpikeLen
Max ATR x Average ATRfloat1.55atrSpikeMult
Use Strict BUY QualitybooltrueuseStrictBuyV495
BUY Min H1 RSIfloat42.0buyRsiMinV495
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

5 Minute Scalp

by hasnocool
106 stars

This strategy overlays three exponential moving averages on the price chart, with periods of 9, 50, and 200. It calculates a MACD histogram from a 1-minute timeframe, applies Bollinger Bands to the histogram, and tracks two RSI oscillators of different lengths

Strategy v5 ScalpingMoving averages
Updated 2 years ago · GPL-3.0 GitHub repository of 5 Minute Scalp
104 stars

This overlay strategy combines a machine-learning distance model with a MACD oscillator to open trades on the price chart. It compares recent history using cosine similarity or Euclidean and Lorentzian distance, then filters direction with selectable moving-av

Strategy v5 AI / machine learningOscillators & momentum
Updated 3 years ago · MIT GitHub repository of MLCEL and MACD Strategy
53 stars

This strategy trades EUR/USD on the price chart using a fast and slow exponential moving average crossover filtered by RSI. It enters long when the fast EMA crosses above the slow EMA while RSI is above 50 and below the overbought level, and enters short on th

Strategy v6 TrendMoving averages
Updated 2 months ago · MPL-2.0 GitHub repository of EUR/USD EMA9-21 + RSI Scalping Strategy
13 stars

This strategy plots on the price chart and enters from a moving-average filter, ADX and Gann colours. Price above a 200-period EMA allows only longs; price below allows only shorts. A Gann aqua colour with ADX above a key level opens a long, and a Gann brown c

Strategy v5 TrendOscillators & momentum
Updated 1 year ago · None stated GitHub repository of Ruckard TradingZone ADX Gann
10 stars

The Reverse RSI Strategy is a scalping system designed for forex pairs during specific trading sessions. It combines a smoothed RSI indicator with five Exponential Moving Averages to identify mean-reversion trade opportunities. Position sizing dynamically adju

Strategy v4 Oscillators & momentumMoving averages
Updated 3 years ago · GPL-3.0 GitHub repository of Strategy - Reverse RSI

Scalping 3EMA

by rodrigo-brito
9 stars

This long-only strategy calculates three exponential moving averages with lengths of 50, 100, and 150 periods, plotting them directly on the price chart. It also calculates a 14-period RSI and MACD. The strategy opens long positions when the moving averages al

Strategy v4 TrendOscillators & momentum
Updated 5 years ago · MIT GitHub repository of Scalping 3EMA

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