0bps

Strategy vault / Breakout

Five Minute Opening Breakout Strategy with Dynamic ATR Based Stop Loss and Take Profit

This strategy is a quantitative trading system based on five-minute opening breakout combined with dynamic ATR-based stop-loss management. It identifies key price levels from the first five-minute candle after market…

Author
ianzeng123
Complexity
Starter · 58 lines
Parameters
0
Backtest bar
5m · intraday
Tested on
SOL/USDT · spot

IMG IMG

Overview

This strategy is a quantitative trading system based on five-minute opening breakout combined with dynamic ATR-based stop-loss management. It identifies key price levels from the first five-minute candle after market open, generates trading signals upon breakouts, and implements dynamic risk control using ATR-based stops.

Strategy Principles

The core logic includes the following key steps:

  1. Determine trading session start time (e.g., NYSE 9:30 AM)
  2. Capture the first five-minute candle, recording its open, high, and low prices
  3. Generate long signals on high breakout and short signals on low breakout
  4. Calculate volatility using 14-period ATR for dynamic stop-loss placement
  5. Implement 1:1.5 risk-reward ratio with stop-loss at 1x ATR and take-profit at 1.5x the breakout range

Strategy Advantages

  1. Precise Timeframe: Focuses on the most active five-minute period after market open
  2. Robust Risk Management: Dynamically adjusts stop-loss levels using ATR
  3. Standardized Execution: Uses clear breakout signals and fixed risk-reward ratio
  4. High Adaptability: ATR indicator automatically adjusts to market volatility
  5. Simple Implementation: Clear strategy logic facilitates testing and execution

Strategy Risks

  1. False Breakout Risk: Opening volatility may generate false signals
  2. Slippage Impact: High volatility periods may face significant slippage
  3. ATR Parameter Sensitivity: 14-period setting may not suit all market conditions
  4. Fixed Multiplier Limitation: 1:1.5 risk-reward ratio may need adjustment
  5. Transaction Cost Consideration: Frequent trading may incur high costs

Optimization Directions

  1. Signal Filtering: Incorporate volume confirmation or momentum indicators
  2. Parameter Adaptation: Develop dynamic ATR period adjustment mechanism
  3. Time Filtering: Add specific timeframe restrictions
  4. Stop-Loss Enhancement: Research market microstructure-based stop methods
  5. Instrument-Specific Optimization: Adjust risk-reward ratios per instrument

Summary

This is a well-structured quantitative trading strategy that achieves controlled risk automated trading through opening price breakout monitoring and ATR dynamic stops. Its core strength lies in its simple yet effective design, though it requires continuous optimization for different market environments and instruments. Traders should conduct thorough backtesting and adjust parameters according to actual conditions before live implementation.

Source Pine Script

/*backtest
start: 2025-02-13 00:00:00
end: 2025-02-19 00:00:00
period: 5m
basePeriod: 5m
exchanges: [{"eid":"Binance","currency":"SOL_USDT"}]
*/

//@version=5
strategy("5-Min Open Candle Breakout", overlay=true)

// Get the current bar's year, month, and day
currentYear = year
currentMonth = month
currentDay = dayofmonth

// Define session start time (adjust based on market)
sessionStart = timestamp(currentYear, currentMonth, currentDay, 9, 30) // 9:30 AM for NYSE

// Identify the first 5-minute candle
isFirstCandle = (time >= sessionStart and time < sessionStart + 300000)  // 5 min = 300,000 ms

var float openPrice = na
var float highPrice = na
var float lowPrice = na

if isFirstCandle
    openPrice := open
    highPrice := high
    lowPrice := low

// Breakout Conditions
longEntry = ta.crossover(close, highPrice)
shortEntry = ta.crossunder(close, lowPrice)

// Define Stop Loss & Take Profit (Ratio 1:1.5)
slFactor = 1.0  // Stop Loss Multiplier
tpFactor = 1.5  // Take Profit Multiplier

atrValue = ta.atr(14)  // Fix: Use ta.atr() instead of atr()

longSL = lowPrice - atrValue * slFactor
longTP = highPrice + (highPrice - lowPrice) * tpFactor

shortSL = highPrice + atrValue * slFactor
shortTP = lowPrice - (highPrice - lowPrice) * tpFactor

// Execute Trades
strategy.entry("Long", strategy.long, when=longEntry)
strategy.exit("Exit Long", from_entry="Long", stop=longSL, limit=longTP)

strategy.entry("Short", strategy.short, when=shortEntry)
strategy.exit("Exit Short", from_entry="Short", stop=shortSL, limit=shortTP)

// Plot High/Low of First Candle
plot(highPrice, title="First 5m High", color=color.green, linewidth=2)
plot(lowPrice, title="First 5m Low", color=color.red, linewidth=2)

Published by ianzeng123 on the FMZ strategy square · last modified 2025-02-27. 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.

in Claude Code, Cursor, Codex & 4 more
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Five-Minute-Opening-Breakout-Strategy-with-Dynamic-ATR-Based-Stop-Loss-and-Take-Profit.md
  1. npx agenkit install engineering-kit in your project
  2. Paste the command into your agent and approve each phase
  3. 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

esc

Try , , or .

↑↓ move↵ open