1Copy the scriptPress Copy script above, or the copy button on the code below.
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
226 lines of Pine Script v6 from pinescript/forex_trading.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.
An RSI filter blocks longs when overbought and shorts when oversold, and a session filter limits trading to a chosen window. Stops and targets are ATR multiples, size is set from a risk percentage of equity, and an optional ATR trailing stop takes over after the first target.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Fast EMA
int
20
fastLen
Slow EMA
int
50
slowLen
Trend EMA (filter)
int
200
trendLen
RSI Filter
bool
true
useRsi
RSI Period
int
14
rsiLen
RSI Overbought (no long)
int
65
rsiOBLevel
RSI Oversold (no short)
int
35
rsiOSLevel
Session Filter
bool
true
useSession
Allowed Session (exchange time)
session
0700-2100
sessionStr
Risk % per trade
float
1.0
riskPct
ATR Period
int
14
atrLen
Stop Loss (× ATR)
float
1.5
slAtr
Show all 17 settings
Setting
Type
Default
Variable
Take Profit (× ATR)
float
2.5
tpAtr
Use trailing stop after TP1
bool
true
useTrail
Trail stop (× ATR)
float
1.0
trailAtr
Allow Long (buy)
bool
true
allowLong
Allow Short (sell)
bool
true
allowShort
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.
Donald - Test Logic Futures is an overlay strategy designed for intraday futures trading. It combines kernel regression functions with exponential moving averages to evaluate price retracements and entry timing. Trades are filtered by session execution windows
Andean Scalping is a Pine Script v5 strategy template designed for backtesting trading signals. It features session and date-range filtering, directional trade toggles for long and short entries, and optional trend filtering tools including higher-timeframe EM
This strategy trades Nikkei 225 futures during a configurable overnight session, defaulting to 19:00–03:00 ET. It builds long and short trend conditions from an 8/21 EMA pair and a 200-period SMA, with RSI, momentum, an ATR-scaled breakout range, and a volume
This strategy plots a 90-period simple moving average from the daily and four-hour charts plus a daily session VWAP on the price chart. It enters long when VWAP is above the daily average and the four-hour VWAP crosses above its average, and short in the oppos
This strategy trades exponential moving average crossovers designed for NQ and MNQ futures contracts on intraday timeframes. It calculates three EMAs (8, 55, and 165 periods) and generates entry signals during a user-defined trading session when previous day v
This strategy trades directional momentum breakouts for crude oil on the price chart. It enters long or short positions when a fast exponential moving average crosses a slow exponential moving average, provided that current Average True Range exceeds its movin