1Copy the scriptPress Copy script above. It reads the file straight from GitHub.
2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
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
Optional filters require the histogram to exceed a threshold, price to sit on the matching side of a simple moving average, and a simplified three-bar divergence check. The default exit closes on the opposite crossover; take-profit, stop-loss, or trailing exits are selectable. Position size is a percentage of equity. It draws on the price chart. No specific timeframe is stated, and divergence is off by default.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Fast EMA Length
int
12
fast_length
Slow EMA Length
int
26
slow_length
Signal Line Length
int
9
signal_length
Require Histogram Confirmation
bool
true
use_histogram_confirm
Histogram Threshold
float
0.0
histogram_threshold
Use Trend Filter
bool
true
use_trend_filter
Trend SMA Period
int
50
trend_period
Exit Mode
string
Opposite Signal
exit_mode
Take Profit %
float
2.0
tp_percent
Stop Loss %
float
1.0
sl_percent
Trailing Offset %
float
0.5
trail_offset_pct
Position Size %
float
100.0
position_size_pct
Show all 14 settings
Setting
Type
Default
Variable
Enable Divergence Detection
bool
false
use_divergence
Divergence Lookback
int
14
lookback_divergence
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.
This overlay strategy combines a Cipher B WaveTrend oscillator with two optional moving averages on the price chart. It exposes WaveTrend channel and average lengths, overbought and oversold levels, buy, sell and gold dots, and regular or hidden divergence mar
Divergenced B004 is a Pine Script strategy that plots on the price chart and looks for divergences in the Squeeze Momentum Indicator. It shorts when a green-section squeeze value falls while price rises, and longs when a red-section squeeze value rises while p
This strategy executes long positions by combining a 200-period EMA trend filter, Stochastic RSI oversold crosses, and Williams Alligator retracements, supplemented by RSI divergence detection. It triggers long entries when the price trades above the 200 EMA w
This strategy draws on the price chart and manages long and short entries around pivot trendlines. It filters signals with three configurable moving averages, Stochastic RSI, a higher-timeframe Stochastic RSI, and optional RSI divergence. A session window can
This strategy calculates a customizable MACD oscillator and histogram using either simple or exponential moving averages. It identifies pivot highs and pivot lows on the MACD histogram to detect momentum divergences against price action. Historical pivot point
This strategy plots a range filter and high and low target bands on the price chart, and colors bars from filter direction. Inputs cover a backtest date window, WaveTrend Cipher B channel and average lengths, overbought and oversold levels, divergence threshol