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
295 lines of Pine Script v6 from production/4h-swing-trading/strategy.pine, published under Apache-2.0. Keep the author's credit and licence lines when you reuse it.
Market Structure MACD 4H + Trailing initiates long positions on bullish structure breaks when MACD is positive and above its signal line, and short positions on bearish breaks when MACD is negative and below its signal. Exits rely on configurable ATR-based stop-loss, take-profit, and trailing stop levels displayed on the price chart. Inputs adjust swing detection lengths, MACD periods, and risk multipliers. Because calculations run on every tick, intra-bar execution may repaint during live candle formation.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
CHoCH Detection Period
int
20
len
IDM Detection Period
int
5
shortLen
Stop Loss ATR Multiplier
float
1.5
stopMultiplier
Take Profit ATR Multiplier
float
3.0
tpMultiplier
Use Trailing Stop
bool
true
useTrailingStop
Trail Start ATR Multiplier
float
1.0
trailStartMultiplier
ATR Period
int
14
atrPeriod
MACD Fast
int
12
macdFast
MACD Slow
int
26
macdSlow
MACD Signal
int
9
macdSignal
Show Stop/TP Levels
bool
true
showLevels
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.
TnS_ICT_V20 is a Pine Script v6 strategy that identifies institutional trading opportunities using ICT concepts. It calculates pivot swings as support and resistance levels, OTE zones, and a thermodynamic audit based on free energy and fractal entropy to filte
This strategy overlays a trend moving average and Supertrend bands directly on the price chart while calculating Stochastic RSI values internally. Long positions trigger when price exceeds the moving average, Supertrend signals bullish momentum, and the StochR
Donald - AI Futures 5M 15M Timeframe is an overlay trading strategy designed for intraday futures trading. It utilizes rational quadratic kernel regression to construct dynamic momentum zones and smoothed price boundaries on the main price chart. The strategy
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
This overlay strategy looks for gold scalps from break of structure and change of character. It enters long when a bullish break, a bullish character change, and an optional volume filter align, and short on the opposite set. Optional RSI levels can block trad
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