
The First Candle Breakout - Dynamic Trailing Stop & EOD Close Strategy is an intraday trading strategy that uses the price range of the first candle after market opening as significant support and resistance levels. This strategy enters the market after price breaks above or below the first candle’s high or low points, employs a dynamic trailing stop loss mechanism based on the first candle’s price range, and forces position closure at a specific time each day to avoid overnight risk.
This strategy is based on the market observation that the price range formed by the first candle after market opening often has significant technical importance. The core logic of the strategy is as follows:
The strategy adopts a confirmation-based entry mechanism, meaning it only enters trades after the price has actually broken through the first candle’s high or low, rather than entering immediately when the price just touches these levels, which helps reduce the risk of false breakouts.
Despite its numerous advantages, the strategy still has some potential risks:
Addressing the above risks, the strategy can be optimized in the following directions:
The First Candle Breakout - Dynamic Trailing Stop & EOD Close Strategy is an intraday trading strategy based on the price range of the first candle after market opening. It enters trades based on confirmed price breakout signals, employs a dynamic trailing stop loss mechanism based on market volatility to manage risk, and forces position closure at a fixed time each day to avoid overnight risk.
The strategy’s advantages include clear entry signals, dynamic risk management, avoidance of false breakouts and overnight risks, adaptation to market volatility, limited overtrading, and fully automated execution. However, it also faces challenges such as false breakout risks, potentially unreasonable stop distances, missing major market moves, strong time dependency, lack of profit targets, and parameter sensitivity.
Through adding filtering conditions, optimizing stop loss mechanisms, introducing partial profit-taking, adding overnight holding conditions, incorporating time filters, optimizing parameter adaptation, integrating market environment recognition, considering multi-timeframe analysis, and adding money management modules, the strategy’s stability and profitability can be further enhanced.
Overall, this is a clearly structured and logically sound intraday trading strategy, suitable for traders who wish to conduct intraday trading through automated systems with strict risk control. With targeted optimization and appropriate parameter adjustments, this strategy has the potential to achieve stable performance across different market environments.
/*backtest
start: 2025-03-24 00:00:00
end: 2025-03-31 00:00:00
period: 1m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"TRX_USDT"}]
*/
//@version=5
strategy("First Candle Breakout - Trailing Stop & EOD Close", overlay=true)
// User Inputs
startHour = input(9, "Start Hour (Exchange Time)")
startMinute = input(15, "Start Minute (Exchange Time)")
endHour = input(15, "End Hour (Exchange Time)") // Market closing hour
endMinute = input(30, "End Minute (Exchange Time)")
trailStopMultiplier = input(1.5, "Trailing Stop Multiplier") // 1.5x first candle range
// Variables to store the first candle's high & low
var float firstCandleHigh = na
var float firstCandleLow = na
var bool tradeTaken = false // Ensures only one trade per day
var int tradeDirection = 0 // 1 for long, -1 for short
var float trailStopLevel = na // Trailing stop level
// Identify first candle's high & low
if (hour == startHour and minute == startMinute and bar_index > 1)
firstCandleHigh := high
firstCandleLow := low
tradeTaken := false // Reset trade flag at start of day
tradeDirection := 0 // Reset trade direction
trailStopLevel := na // Reset trailing stop
// Calculate first candle range
firstCandleRange = firstCandleHigh - firstCandleLow
trailStopDistance = firstCandleRange * trailStopMultiplier
// Buy condition: Close above first candle high AFTER the first candle closes
longCondition = not na(firstCandleHigh) and close > firstCandleHigh and not tradeTaken and hour > startHour
if (longCondition)
strategy.entry("Buy", strategy.long, comment="Buy")
trailStopLevel := close - trailStopDistance // Set initial trailing stop
tradeTaken := true
tradeDirection := 1
// Sell condition: Close below first candle low AFTER the first candle closes
shortCondition = not na(firstCandleLow) and close < firstCandleLow and not tradeTaken and hour > startHour
if (shortCondition)
strategy.entry("Sell", strategy.short, comment="Sell")
trailStopLevel := close + trailStopDistance // Set initial trailing stop
tradeTaken := true
tradeDirection := -1
// Update trailing stop for long trades
if (tradeDirection == 1 and not na(trailStopLevel))
trailStopLevel := nz(trailStopLevel, close - trailStopDistance) // Initialize if na
trailStopLevel := math.max(trailStopLevel, close - trailStopDistance) // Adjust trailing stop up
if (close <= trailStopLevel) // Stop loss hit
strategy.close("Buy", comment="Trailing SL Hit")
// Update trailing stop for short trades
if (tradeDirection == -1 and not na(trailStopLevel))
trailStopLevel := nz(trailStopLevel, close + trailStopDistance) // Initialize if na
trailStopLevel := math.min(trailStopLevel, close + trailStopDistance) // Adjust trailing stop down
if (close >= trailStopLevel) // Stop loss hit
strategy.close("Sell", comment="Trailing SL Hit")
// Close trade at end of day if still open
if (tradeTaken and hour == endHour and minute == endMinute)
strategy.close_all(comment="EOD Close")