Strategy vault / Trend following
Supertrend Blind Following Strategy
This strategy shows what would happen if you blindly follow the Supertrend indicator. As we know, Supertrend does not appear immediately and we need to wait for the next bar to decide whether to enter a position. So…

Overview
This strategy shows what would happen if you blindly follow the Supertrend indicator. As we know, Supertrend does not appear immediately and we need to wait for the next bar to decide whether to enter a position. So you can see what will happen if you take a position after Supertrend finally formed. This indicator is extremely dangerous without other tools and can give very serious drawdowns. Take care of yourself...
Strategy Logic
This strategy uses the Supertrend indicator to determine price trend. Supertrend is built based on the Average True Range and midpoints of high and low prices.
When the close price is above the upper rail, it represents a sustained uptrend; when the close price is below the lower rail, it represents a sustained downtrend.
This strategy sets two parameters: Factor and Pd. Factor controls the width of the Supertrend channel, and Pd controls the period length to calculate ATR. Based on these two parameters, the upper and lower rails can be constructed.
Upper Rail Formula: hl2 - (Factor * ATR(Pd)) Lower Rail Formula: hl2 + (Factor * ATR(Pd))
Where hl2 represents the midpoint of high and low prices.
Then compare the current close price with the upper and lower rails to determine if it's an uptrend or a downtrend, and output a boolean Trend variable.
Plot the upper and lower rails of Supertrend based on Trend. And place entry and exit signals when Trend status changes.
Set strategy's entry logic based on the signals.
Advantage Analysis
This strategy has the following advantages:
Uses Supertrend indicator, which can clearly determine price trend and pivot points.
Sets clear entry and exit logic.
Visualizes entry timing with arrows.
Simple and easy to understand strategy logic.
Risk Analysis
This strategy has the following risks:
Blindly following Supertrend without other auxiliary indicators and money management may lead to huge drawdowns.
No stop loss set, unable to control single loss.
Signals may lag, unable to enter in time around turning points.
Improper parameter settings may cause Supertrend channel to be too wide or too narrow.
Risk Management Measures:
Combine with other indicators like MACD, KDJ for effectiveness validation, avoid blind following.
Set reasonable stop loss to maximize control over single loss.
Adjust parameters to make Supertrend channel reasonable, prevent too wide or too narrow.
Optimization Directions
This strategy can be optimized in the following aspects:
Add auxiliary indicators for effectiveness validation to prevent failure. For example, MACD indicator can be considered.
Set reasonable stop loss logic. Can set percentage stop loss based on ATR.
Optimize hyperparameters Factor and Pd to find best parameter combinations. For example, traversal methods can be used to find optimal parameters.
Optimize entry timing to avoid signal lag. For example, momentum indicators can be introduced to adjust entry timing based on strength and weakness.
Add position sizing strategies. For example, fixed fractional position sizing can be adopted.
Conclusion
This strategy uses Supertrend indicator to determine price trend and find turning points. Blindly following Supertrend without auxiliary indicators and stop loss means brings huge risks. We proposed improvements in aspects like risk management, stop loss strategies, parameter optimization, entry timing, etc, which can significantly enhance the stability and profitability of the strategy.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | 3 | Factor |
| v_input_2 | 7 | Pd |
Source Pine Script
/*backtest
start: 2022-12-06 00:00:00
end: 2023-12-12 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=2
strategy("Supertrend blind follow", overlay=true)
Factor=input(3, minval=1,maxval = 100)
Pd=input(7, minval=1,maxval = 100)
Up=hl2-(Factor*atr(Pd))
Dn=hl2+(Factor*atr(Pd))
TrendUp=close[1]>TrendUp[1]? max(Up,TrendUp[1]) : Up
TrendDown=close[1]<TrendDown[1]? min(Dn,TrendDown[1]) : Dn
Trend = close > TrendDown[1] ? 1: close< TrendUp[1]? -1: nz(Trend[1],1)
Tsl = Trend==1? TrendUp: TrendDown
linecolor = Trend == 1 ? green : red
plot(Tsl, color = linecolor , style = line , linewidth = 2,title = "SuperTrend")
plotshape(cross(close,Tsl) and close>Tsl , "Up Arrow", shape.triangleup,location.belowbar,green,0,0)
plotshape(cross(Tsl,close) and close<Tsl , "Down Arrow", shape.triangledown , location.abovebar, red,0,0)
//plot(Trend==1 and Trend[1]==-1,color = linecolor, style = circles, linewidth = 3,title="Trend")
plotarrow(Trend == 1 and Trend[1] == -1 ? Trend : na, title="Up Entry Arrow", colorup=lime, maxheight=60, minheight=50, transp=0)
plotarrow(Trend == -1 and Trend[1] == 1 ? Trend : na, title="Down Entry Arrow", colordown=red, maxheight=60, minheight=50, transp=0)
longCondition = cross(close,Tsl) and close>Tsl
if (longCondition)
strategy.entry("long", strategy.long)
shortCondition = cross(Tsl,close) and close<Tsl
if (shortCondition)
strategy.entry("short", strategy.short)
Published by ChaoZhang on the FMZ strategy square · last modified 2023-12-13. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.
Build this with AgenKit
A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Supertrend-Blind-Following-Strategy.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- Get tests, backtest, risk controls and a paper-trading switch
Understand it first
Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.
Related specs
- Multi Indicator Dynamic Trend Following Strategy Based on EMA and SMAPine Script · Trend following · 1d
- Samsuga SuperTrend MACD StrategyPine Script · Trend following · 1h
- Best Supertrend CCI Multi Timeframe Trading StrategyPine Script · Trend following · 10m
- Trend Confirmation Tracking StrategyPine Script · Trend following · 1h
- Advanced Supertrend Indicator Trading Mechanism Optimization StrategyPine Script · Trend following · 1d
- Fixed Range Volume Profile And Anchored VWAP Trend Identification Strategy With Dynamic Stop LossPine Script · Trend following · 1h