Intraday Trend Breakout Strategy
This is an intraday short-term trend following strategy based on the Supertrend indicator. Users can define the intraday trading session during which the strategy will run. The strategy reverses the position using…
Overview
This is an intraday short-term trend following strategy based on the Supertrend indicator. Users can define the intraday trading session during which the strategy will run.
The strategy reverses the position using double quantity when the signal changes. Any open positions are squared off at the end of the intraday session.
Strategy Logic
Calculate the Supertrend indicator based on user defined multiplier and ATR period.
Plot the Supertrend line as the support and resistance.
Determine long/short conditions. Close above Supertrend line is long condition. Close below Supertrend line is short condition.
Check if current bar is within intraday session defined by user.
Issue long/short signals only when intraday session is active and long/short conditions are met.
Reverse position by taking opposite trade with double quantity when Supertrend direction changes.
Square off open positions when Supertrend direction is unchanged and intraday session ends.
Advantage Analysis
Supertrend identifies trend and reduces false signals.
Combining Supertrend with close price avoids being stopped out prematurely.
Reversing position timely reduces losses.
Intraday session avoids overnight risk.
Forced exit avoids risk of forgetting to square off.
Risk Analysis
Improper Supertrend parameters may lead to poor strategy performance.
Reversing position increases trade frequency and costs.
Forced exit at session end may lead to losses.
Risk 1 can be mitigated through parameter optimization.
Risk 2 can be controlled via stop loss.
Risk 3 can be avoided using stop loss or trend filter.
Enhancement Opportunities
Test different trend indicators like MA, KDJ etc.
Add stop loss logic.
Add trend filter to avoid forced exit losses.
Optimize multiplier and ATR period parameters.
Test on different instruments.
Conclusion
This strategy combines Supertrend and intraday session management to capitalize on short-term trend breaks. Position reversal and forced exit effectively controls risk. Further improvements can be made through parameter optimization, stop loss and trend filtering.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | 0915-1455 | Market session |
| v_input_2 | 4 | Multiplier |
| v_input_3 | 14 | ATR Period |
Source Pine Script
/*backtest
start: 2023-08-18 00:00:00
end: 2023-09-17 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Pritesh-StocksDeveloper
//@version=4
strategy("Supertrend - Intraday", overlay=true, calc_on_every_tick = true)
// ********** Strategy inputs - Start **********
// Used for intraday handling
// Session value should be from market start to the time you want to square-off
// your intraday strategy
// Important: The end time should be at least 2 minutes before the intraday
// square-off time set by your broker
var i_marketSession = input(title="Market session", type=input.session,
defval="0915-1455", confirm=true)
var float i_multiplier = input(title = "Multiplier", type = input.float,
defval = 4, confirm=true)
var int i_atrPeriod = input(title = "ATR Period", type = input.integer,
defval = 14, confirm=true)
// ********** Strategy inputs - End **********
// ********** Supporting functions - Start **********
// A function to check whether the bar or period is in intraday session
barInSession(sess) => time(timeframe.period, sess) != 0
// ********** Supporting functions - End **********
// ********** Strategy - Start **********
[superTrend, dir] = supertrend(i_multiplier, i_atrPeriod)
colResistance = dir == 1 and dir == dir[1] ? color.new(color.red, 0) : color.new(color.red, 100)
colSupport = dir == -1 and dir == dir[1] ? color.new(color.green, 0) : color.new(color.green, 100)
plot(superTrend, color = colResistance, linewidth=2)
plot(superTrend, color = colSupport, linewidth=2)
// Long/short condition
longCondition = close > superTrend
shortCondition = close < superTrend
// See if intraday session is active
bool intradaySession = barInSession(i_marketSession)
// Trade only if intraday session is active
// Long position
// When longCondition and intradaySession both are true
strategy.entry(id = "Long", long = strategy.long,
when = longCondition and intradaySession)
// Short position
// When shortCondition and intradaySession both are true
strategy.entry(id = "Short", long = strategy.short,
when = shortCondition and intradaySession)
// Square-off position (when session is over and position is open)
squareOff = (not intradaySession) and (strategy.position_size != 0)
strategy.close_all(when = squareOff, comment = "Square-off")
// ********** Strategy - End **********Published by ChaoZhang on the FMZ strategy square · last modified 2023-09-18. 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/Intraday-Trend-Breakout-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
- Quantitative Trading Strategy Based on Ichimoku with Multiple SignalsPine Script · Breakout · 1h
- Cross Timeframe SuperTrend Breakout StrategyPine Script · Breakout · 1h
- Triple Pattern Oscillation Trading StrategyPine Script · Breakout · 1h
- Momentum Breakout Moving Average Trading Strategy 436230Pine Script · Breakout · 1d
- Kana Candle Breakout Strategy Based on Moving Average and Support ResistancePine Script · Breakout · 1h
- Market Structure Based Support Resistance Zone Candlestick Breakout StrategyPine Script · Breakout · 1h