I use TradingView daily for my USDJPY momentum trading, and the SuperTrend concept underpins a lot of how I think about trend direction. The default built-in SuperTrend is fine for quick checks, but a custom implementation lets you add filters, alerts, and multi-timeframe confirmation that the built-in version simply can't do.
What Is the SuperTrend Indicator?
The SuperTrend is an ATR-based (Average True Range) trend-following indicator that plots a dynamic line above or below price. When price is above the line, the trend is bullish. When price is below, the trend is bearish. Flip points generate buy and sell signals.
The math is straightforward:
- Upper Band = (High + Low) / 2 + Multiplier ร ATR
- Lower Band = (High + Low) / 2 โ Multiplier ร ATR
- If the close is above the upper band, the trend flips bullish (SuperTrend = lower band)
- If the close is below the lower band, the trend flips bearish (SuperTrend = upper band)
| Parameter | Default | Effect |
|---|---|---|
| ATR Period | 10 | Number of bars used to calculate volatility. Higher = smoother, fewer signals |
| Multiplier | 3.0 | How far the bands sit from the midpoint. Higher = wider bands, fewer false signals |
Why Build a Custom SuperTrend Instead of Using the Built-In?
TradingView includes a built-in ta.supertrend() function and a default SuperTrend indicator. So why bother writing your own?
strategy() script gives you net profit, win rate, max drawdown, profit factor, and trade-by-trade results in TradingView's Strategy Tester.
3. Alert automation. Custom scripts let you create alerts that fire on your exact conditions, which you can pipe to webhooks for automated execution on exchanges like OKX or through your broker's API.
4. Multi-timeframe confirmation. You can request the SuperTrend value from a higher timeframe and only take signals that align with the bigger picture โ something the built-in indicator doesn't support natively.
5. Visual customization. Add buy/sell labels, background coloring, dashboard panels, or combine SuperTrend with other indicators in a single script (important for free-tier users who are limited to 3 indicators per chart on TradingView).
Step 1: Basic SuperTrend Indicator in Pine Script v6
Let's start with a clean SuperTrend indicator. This version uses TradingView's built-in ta.supertrend() function for the core calculation, then adds visual signals on top.
//@version=6
indicator("Custom SuperTrend", overlay=true)
// โโโ INPUTS โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
atrPeriod = input.int(10, "ATR Period", minval=1)
multiplier = input.float(3.0, "Multiplier", minval=0.1, step=0.1)
// โโโ SUPERTREND CALCULATION โโโโโโโโโโโโโโโโโโโโโโโโ
[supertrend, direction] = ta.supertrend(multiplier, atrPeriod)
// direction: -1 = bullish (price above), +1 = bearish (price below)
isBullish = direction < 0
isBearish = direction > 0
// โโโ PLOT โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
plot(supertrend, "SuperTrend",
color=isBullish ? color.green : color.red,
linewidth=2, style=plot.style_linebr)
// โโโ BUY / SELL SIGNALS โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
buySignal = isBullish and not isBullish[1]
sellSignal = isBearish and not isBearish[1]
plotshape(buySignal, "Buy", shape.triangleup,
location.belowbar, color.green, size=size.small)
plotshape(sellSignal, "Sell", shape.triangledown,
location.abovebar, color.red, size=size.small)
// โโโ BACKGROUND โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
bgcolor(isBullish ? color.new(color.green, 93) : color.new(color.red, 93))
What this does:
- Plots the SuperTrend line in green during uptrends, red during downtrends
- Shows triangle markers at the exact bar where the trend flips
- Adds a subtle background tint so you can see trend zones at a glance
Step 2: Convert to a Backtestable Strategy
Now let's turn this into a strategy() so you can see actual backtest performance numbers in TradingView's Strategy Tester.
//@version=6
strategy("SuperTrend Strategy", overlay=true,
default_qty_type=strategy.percent_of_equity,
default_qty_value=100,
initial_capital=10000,
commission_type=strategy.commission.percent,
commission_value=0.1)
// โโโ INPUTS โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
atrPeriod = input.int(10, "ATR Period", minval=1)
multiplier = input.float(3.0, "Multiplier", minval=0.1, step=0.1)
// โโโ SUPERTREND CALCULATION โโโโโโโโโโโโโโโโโโโโโโโโ
[supertrend, direction] = ta.supertrend(multiplier, atrPeriod)
isBullish = direction < 0
isBearish = direction > 0
buySignal = isBullish and not isBullish[1]
sellSignal = isBearish and not isBearish[1]
// โโโ STRATEGY ENTRIES โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
if buySignal
strategy.entry("Long", strategy.long)
if sellSignal
strategy.close("Long")
// โโโ PLOT โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
plot(supertrend, "SuperTrend",
color=isBullish ? color.green : color.red,
linewidth=2, style=plot.style_linebr)
plotshape(buySignal, "Buy", shape.triangleup,
location.belowbar, color.green, size=size.small)
plotshape(sellSignal, "Sell", shape.triangledown,
location.abovebar, color.red, size=size.small)
After adding this to your chart, click the Strategy Tester tab at the bottom of TradingView to see performance metrics. Pay attention to:
- Net Profit โ total P&L including commissions
- Profit Factor โ gross profit รท gross loss (above 1.5 is solid)
- Max Drawdown โ the worst peak-to-trough decline
- Win Rate โ percentage of profitable trades
commission_value=0.1 line above adds a realistic 0.1% per trade. Always include commission โ it's the difference between a profitable backtest and a real-world loss.
> Tip: The Strategy Tester is available on all TradingView plans, but the number of bars it processes differs by plan. Essential and above give you more historical data for longer backtests.
Step 3: Add an RSI Filter to Reduce False Signals
The SuperTrend alone generates plenty of whipsaw signals during sideways markets. Adding an RSI filter is one of the simplest ways to cut the noise: only take long entries when RSI confirms momentum is behind the move.
//@version=6
strategy("SuperTrend + RSI Filter", overlay=true,
default_qty_type=strategy.percent_of_equity,
default_qty_value=100,
initial_capital=10000,
commission_type=strategy.commission.percent,
commission_value=0.1)
// โโโ INPUTS โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
atrPeriod = input.int(10, "ATR Period", minval=1)
multiplier = input.float(3.0, "Multiplier", minval=0.1, step=0.1)
rsiLength = input.int(14, "RSI Length", minval=1)
rsiLongMin = input.int(50, "RSI Min for Long", minval=1, maxval=100)
rsiShortMax = input.int(50, "RSI Max for Short", minval=1, maxval=100)
// โโโ CALCULATIONS โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
[supertrend, direction] = ta.supertrend(multiplier, atrPeriod)
rsi = ta.rsi(close, rsiLength)
isBullish = direction < 0
isBearish = direction > 0
buySignal = isBullish and not isBullish[1] and rsi > rsiLongMin
sellSignal = isBearish and not isBearish[1] and rsi < rsiShortMax
// โโโ STRATEGY ENTRIES โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
if buySignal
strategy.entry("Long", strategy.long)
if sellSignal
strategy.close("Long")
strategy.entry("Short", strategy.short)
// Exit short on next buy signal
if isBullish and not isBullish[1]
strategy.close("Short")
// โโโ PLOTS โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
plot(supertrend, "SuperTrend",
color=isBullish ? color.green : color.red,
linewidth=2, style=plot.style_linebr)
plotshape(buySignal, "Buy", shape.triangleup,
location.belowbar, color.green, size=size.small)
plotshape(sellSignal, "Sell", shape.triangledown,
location.abovebar, color.red, size=size.small)
// โโโ RSI PANEL (optional) โโโโโโโโโโโโโโโโโโโโโโโโโโ
// Uncomment these lines to see RSI in a separate panel:
// plot(rsi, "RSI", color.purple)
// hline(rsiLongMin, "RSI Filter Level", color.gray)
What the RSI filter does:
- A buy signal only fires if RSI is above 50, confirming upward momentum
- A sell signal only fires if RSI is below 50, confirming downward momentum
- This cuts out many low-conviction flip signals in choppy markets
Step 4: Multi-Timeframe SuperTrend Confirmation
One of the most powerful upgrades you can make to any trend indicator is adding a higher-timeframe filter. The idea: only trade in the direction of the bigger trend. If the daily SuperTrend is bullish, only take long signals on the 4-hour chart.
//@version=6
strategy("SuperTrend MTF Strategy", overlay=true,
default_qty_type=strategy.percent_of_equity,
default_qty_value=100,
initial_capital=10000,
commission_type=strategy.commission.percent,
commission_value=0.1)
// โโโ INPUTS โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
atrPeriod = input.int(10, "ATR Period", minval=1)
multiplier = input.float(3.0, "Multiplier", minval=0.1, step=0.1)
htfInput = input.timeframe("D", "Higher Timeframe")
// โโโ CURRENT TIMEFRAME SUPERTREND โโโโโโโโโโโโโโโโโโ
[supertrend, direction] = ta.supertrend(multiplier, atrPeriod)
isBullish = direction < 0
isBearish = direction > 0
// โโโ HIGHER TIMEFRAME SUPERTREND โโโโโโโโโโโโโโโโโโโ
htfDirection = request.security(syminfo.tickerid, htfInput,
ta.supertrend(multiplier, atrPeriod)[1])
// [1] prevents lookahead bias โ uses the CONFIRMED bar value
htfBullish = htfDirection < 0
// โโโ FILTERED SIGNALS โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
buySignal = isBullish and not isBullish[1] and htfBullish
sellSignal = isBearish and not isBearish[1] and not htfBullish
if buySignal
strategy.entry("Long", strategy.long)
if sellSignal
strategy.close("Long")
// โโโ PLOTS โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
plot(supertrend, "SuperTrend",
color=isBullish ? color.green : color.red,
linewidth=2, style=plot.style_linebr)
plotshape(buySignal, "Buy (MTF Confirmed)", shape.triangleup,
location.belowbar, color.green, size=size.normal)
plotshape(sellSignal, "Sell", shape.triangledown,
location.abovebar, color.red, size=size.small)
// HTF trend background
bgcolor(htfBullish ? color.new(color.green, 95) : color.new(color.red, 95))
Important: The [1] offset on the request.security() call is critical. Without it, you get lookahead bias โ the strategy would "cheat" by using higher-timeframe data that wasn't available yet in real time. Always offset by 1 bar for confirmed data.
The subtle green/red background shows the higher-timeframe trend direction at a glance. Large green triangles mark buy signals that have multi-timeframe confluence โ these are the highest-conviction setups.
> Note: Multi-timeframe data requests require TradingView Essential or higher. Free plan users are limited in their request.security() calls.
Step 5: Add Stop Loss and Take Profit
No strategy is complete without risk management. Here's how to add a percentage-based stop loss and take profit to the SuperTrend strategy:
//@version=6
strategy("SuperTrend + Risk Management", overlay=true,
default_qty_type=strategy.percent_of_equity,
default_qty_value=100,
initial_capital=10000,
commission_type=strategy.commission.percent,
commission_value=0.1)
// โโโ INPUTS โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
atrPeriod = input.int(10, "ATR Period", minval=1)
multiplier = input.float(3.0, "Multiplier", minval=0.1, step=0.1)
slPercent = input.float(2.0, "Stop Loss %", minval=0.1, step=0.1)
tpPercent = input.float(4.0, "Take Profit %", minval=0.1, step=0.1)
useTrailSL = input.bool(false, "Use Trailing Stop")
trailPercent = input.float(1.5, "Trail %", minval=0.1, step=0.1)
// โโโ SUPERTREND โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
[supertrend, direction] = ta.supertrend(multiplier, atrPeriod)
isBullish = direction < 0
isBearish = direction > 0
buySignal = isBullish and not isBullish[1]
sellSignal = isBearish and not isBearish[1]
// โโโ ENTRIES WITH SL/TP โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
if buySignal
strategy.entry("Long", strategy.long)
if useTrailSL
strategy.exit("Trail", "Long",
trail_points=close * trailPercent / 100 / syminfo.mintick,
trail_offset=close * trailPercent / 100 / syminfo.mintick)
else
strategy.exit("SL/TP", "Long",
stop=close * (1 - slPercent / 100),
limit=close * (1 + tpPercent / 100))
if sellSignal
strategy.close("Long")
// โโโ PLOTS โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
plot(supertrend, "SuperTrend",
color=isBullish ? color.green : color.red,
linewidth=2, style=plot.style_linebr)
plotshape(buySignal, "Buy", shape.triangleup,
location.belowbar, color.green, size=size.small)
plotshape(sellSignal, "Sell", shape.triangledown,
location.abovebar, color.red, size=size.small)
Risk management options in this script:
- Fixed SL/TP: Default 2% stop loss and 4% take profit gives a 1:2 risk-reward ratio
- Trailing Stop: Toggle on to use a trailing stop instead โ the stop follows price up but never moves down
- SuperTrend Exit: The
sellSignalclose acts as an additional exit โ if the trend reverses before SL/TP is hit, you exit on the trend flip
Step 6: Full Production Strategy โ Complete Code
Here's the complete strategy that combines everything: SuperTrend + RSI filter + multi-timeframe confirmation + risk management + a dashboard panel showing key statistics.
//@version=6
strategy("SuperTrend Pro Strategy", overlay=true,
default_qty_type=strategy.percent_of_equity,
default_qty_value=100,
initial_capital=10000,
commission_type=strategy.commission.percent,
commission_value=0.1,
max_bars_back=5000)
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
// INPUTS
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
grpST = "SuperTrend Settings"
atrPeriod = input.int(10, "ATR Period", minval=1, group=grpST)
multiplier = input.float(3.0, "Multiplier", minval=0.1, step=0.1, group=grpST)
grpFilter = "Filters"
useRSI = input.bool(true, "Use RSI Filter", group=grpFilter)
rsiLength = input.int(14, "RSI Length", minval=1, group=grpFilter)
rsiMin = input.int(50, "RSI Min for Long", group=grpFilter)
useMTF = input.bool(false, "Use Multi-Timeframe Filter", group=grpFilter)
htfInput = input.timeframe("D", "Higher Timeframe", group=grpFilter)
grpRisk = "Risk Management"
slPercent = input.float(2.0, "Stop Loss %", minval=0.1, step=0.1, group=grpRisk)
tpPercent = input.float(4.0, "Take Profit %", minval=0.1, step=0.1, group=grpRisk)
allowShort = input.bool(false, "Allow Short Trades", group=grpRisk)
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
// CALCULATIONS
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
[supertrend, direction] = ta.supertrend(multiplier, atrPeriod)
rsi = ta.rsi(close, rsiLength)
isBullish = direction < 0
isBearish = direction > 0
// Higher timeframe filter
htfBullish = true
if useMTF
htfDir = request.security(syminfo.tickerid, htfInput,
ta.supertrend(multiplier, atrPeriod)[1])
htfBullish := htfDir < 0
// Signal generation
rawBuy = isBullish and not isBullish[1]
rawSell = isBearish and not isBearish[1]
rsiOK = useRSI ? rsi > rsiMin : true
mtfOK = useMTF ? htfBullish : true
buySignal = rawBuy and rsiOK and mtfOK
sellSignal = rawSell
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
// STRATEGY LOGIC
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
if buySignal
strategy.entry("Long", strategy.long)
strategy.exit("SL/TP Long", "Long",
stop=close * (1 - slPercent / 100),
limit=close * (1 + tpPercent / 100))
if sellSignal
strategy.close("Long")
if allowShort
strategy.entry("Short", strategy.short)
strategy.exit("SL/TP Short", "Short",
stop=close * (1 + slPercent / 100),
limit=close * (1 - tpPercent / 100))
if buySignal and strategy.position_size < 0
strategy.close("Short")
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
// VISUALS
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
plot(supertrend, "SuperTrend",
color=isBullish ? color.green : color.red,
linewidth=2, style=plot.style_linebr)
plotshape(buySignal, "Buy", shape.triangleup,
location.belowbar, color.green, size=size.normal)
plotshape(sellSignal, "Sell", shape.triangledown,
location.abovebar, color.red, size=size.small)
bgcolor(useMTF and not htfBullish ? color.new(color.red, 95) : na)
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
// DASHBOARD
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
var table dash = table.new(position.top_right, 2, 5,
bgcolor=color.new(color.black, 80),
border_width=1)
if barstate.islast
table.cell(dash, 0, 0, "SuperTrend Pro", text_color=color.white,
text_size=size.small)
table.cell(dash, 1, 0, "", text_color=color.white)
table.cell(dash, 0, 1, "Trend", text_color=color.gray,
text_size=size.small)
table.cell(dash, 1, 1, isBullish ? "โฒ BULL" : "โผ BEAR",
text_color=isBullish ? color.green : color.red,
text_size=size.small)
table.cell(dash, 0, 2, "RSI", text_color=color.gray,
text_size=size.small)
table.cell(dash, 1, 2, str.tostring(rsi, "#.0"),
text_color=rsi > 50 ? color.green : color.red,
text_size=size.small)
table.cell(dash, 0, 3, "SuperTrend", text_color=color.gray,
text_size=size.small)
table.cell(dash, 1, 3, str.tostring(supertrend, "#.##"),
text_color=color.white, text_size=size.small)
table.cell(dash, 0, 4, "ATR Period", text_color=color.gray,
text_size=size.small)
table.cell(dash, 1, 4, str.tostring(atrPeriod),
text_color=color.white, text_size=size.small)
This is the full production-ready script. Add it to your chart, open the Strategy Tester, and start experimenting with the inputs.
Best SuperTrend Settings for Different Markets
There's no universal "best" setting โ it depends on what you're trading and your timeframe. Here are starting points based on common configurations:
| Market | Timeframe | ATR Period | Multiplier | Notes |
|---|---|---|---|---|
| Forex (USDJPY, EURUSD) | 4H | 10 | 3.0 | Default works well for major pairs |
| Forex (GBPJPY, volatile) | 4H | 10 | 3.5 | Wider multiplier for volatile crosses |
| Crypto (BTC, ETH) | 1H | 10 | 2.0 | Tighter settings catch faster crypto moves |
| Crypto (altcoins) | 1H | 7 | 2.0 | Shorter ATR period for faster reactions |
| Stocks (large cap) | Daily | 14 | 3.0 | Longer ATR period smooths daily noise |
| Indices (S&P 500) | 4H | 10 | 3.0 | Standard settings work on liquid indices |
1. Apply the strategy to your target instrument and timeframe
2. Open Strategy Tester โ click the Optimization icon (gear with sparkle) 3. Set ATR Period range: 5 to 20, step 1 4. Set Multiplier range: 1.5 to 5.0, step 0.5 5. Run the optimization and sort by Profit Factor (not just Net Profit)A word of caution: don't over-optimize. If your best settings only work on the last 100 bars, they'll fall apart on live data. Look for parameter ranges where performance is consistently good, not just the single best configuration.
Setting Up Alerts for Live Trading
Once you're satisfied with the backtest results, set up alerts to trade live. Here's how to add alert conditions to the strategy:
// Add these lines to your strategy script:
alertcondition(buySignal, "SuperTrend Buy", "SuperTrend flipped BULLISH on {{ticker}} ({{interval}})")
alertcondition(sellSignal, "SuperTrend Sell", "SuperTrend flipped BEARISH on {{ticker}} ({{interval}})")
To create an alert:
1. Right-click the indicator name on your chart 2. Select Add Alert 3. Choose the condition (SuperTrend Buy or SuperTrend Sell) 4. Set the frequency โ "Once Per Bar Close" is usually what you want (it waits for the bar to close before firing, preventing false signals from intra-bar price spikes) 5. Configure notifications: push, email, webhook, or all threeFor automated execution, use the Webhook URL field to send alert data to your exchange. If you're trading on OKX, check out their Signal Bot which accepts TradingView webhooks directly.
For a detailed walkthrough on alert frequencies and troubleshooting, see our guide on TradingView alert "Once Per Bar Close" explained.
Common Mistakes and How to Avoid Them
After building and testing dozens of Pine Script strategies, here are the mistakes I see most often:
1. No Commission in Backtests
If your strategy shows 200% profit with 0% commission, it might actually lose money in real trading. Always set commission_value to at least 0.05% for stocks, 0.1% for crypto, or 0.02% for forex.
2. Lookahead Bias in Multi-Timeframe Requests
If you use request.security() without the [1] offset, your strategy "sees the future" by using the current higher-timeframe bar's value before it closes. Always offset:
// WRONG โ lookahead bias
htfValue = request.security(syminfo.tickerid, "D", ta.supertrend(3, 10))
// RIGHT โ uses confirmed previous bar
htfValue = request.security(syminfo.tickerid, "D", ta.supertrend(3, 10)[1])
3. Over-Optimization
Finding the "perfect" ATR period and multiplier on historical data guarantees nothing about the future. Instead of optimizing to a single value, look for robust ranges โ if your strategy is profitable with multipliers from 2.5 to 3.5, you're on solid ground. If it only works at exactly 2.73, you've curve-fitted.
4. Ignoring Trending vs. Ranging Markets
The SuperTrend is a trend-following indicator. By definition, it underperforms in range-bound markets. Adding a filter like ADX (Average Directional Index) can help:
adx = ta.adx(14)
isStrong = adx > 25 // Only trade when trend strength is sufficient
buySignal = isBullish and not isBullish[1] and isStrong
5. Trading Every Signal
Not every SuperTrend flip is worth trading. Combine it with volume, RSI, or higher-timeframe direction to filter for the best setups. The multi-timeframe version in Step 4 above is a good starting point.
SuperTrend vs. Other Trend Indicators
How does SuperTrend compare to other popular trend-following tools?
| Feature | SuperTrend | Moving Average Crossover | Parabolic SAR | Ichimoku Cloud |
|---|---|---|---|---|
| Simplicity | โ โ โ โ โ | โ โ โ โ | โ โ โ | โ โ |
| Signal clarity | Clear buy/sell | Crossover points | Dot flip | Complex multi-signal |
| Lag | Medium | High (depends on MA period) | Low | Medium-High |
| False signals in ranges | Moderate | High | Very High | Low |
| Customization | 2 parameters | 2 MA periods | 2 parameters | 5+ parameters |
| Pine Script complexity | Simple | Simple | Simple | Complex |
What's Next
You now have a production-ready SuperTrend strategy in Pine Script v6. Here's how to take it further:
1. Backtest on your target market โ apply the script, run the Strategy Tester, and evaluate performance before risking real capital
2. Experiment with filters โ try different RSI thresholds, add volume confirmation, or combine with our RSI Divergence indicator 3. Set up multi-timeframe confirmation โ toggle on the MTF filter to align with the daily or weekly trend 4. Automate with alerts โ configure webhook alerts to execute trades automatically 5. Combine with other scripts โ merge SuperTrend with EMA or MACD into a single all-in-one indicator to save indicator slots on your TradingView planIf you're migrating Pine Script v5 code to v6, check our Pine Script v5 to v6 migration checklist โ there are breaking changes that can silently alter your strategy's behavior.
For live trading execution, you can connect TradingView alerts to Interactive Brokers via their API or to OKX using their Signal Bot feature. See our guide on TradingView webhook to Google Sheets for a free trade logging setup.
---
*Disclaimer: This tutorial is for educational purposes only. Past backtest performance does not guarantee future results. Always test strategies on paper trading before using real capital. The author uses TradingView and Interactive Brokers for personal trading.*