
The Multi-Phase Price Breakthrough and Pullback Trading Strategy is a price action-based trading system that identifies specific price patterns and enters positions at precise breakout points. This strategy monitors the relationships between the opening price, high, low, and closing price of candlesticks, combined with point difference analysis, to capture market momentum shifts. The strategy features a multi-phase judgment mechanism with three different entry condition stages, along with symmetrical long and short trading logic, and fixed stop-loss and take-profit mechanisms.
The core principle of this strategy is to identify and capitalize on continuation opportunities after rapid price movements. Through in-depth code analysis, we can see the strategy follows these principles:
Phase Identification System: The strategy divides trading logic into three phases (phases 1-3), triggering different entry conditions based on the current phase.
Breakout Condition Detection: For long trades, it primarily checks these conditions:
Reverse Logic: Short trades use completely symmetrical reverse logic, monitoring relationships between open prices and lows to determine entry timing.
Stop-Loss and Take-Profit Settings: The strategy employs fixed point-based stop-loss and take-profit rules, setting long stop-losses 301 points below entry price and take-profits 301 points above the previous closing price; short trades use the opposite configuration.
After in-depth code analysis, this strategy demonstrates several notable advantages:
Multi-Stage Judgment Mechanism: Through three different phase judgments, the strategy avoids false signals from single conditions, improving entry accuracy.
Balances Directional Movement and Pullbacks: The strategy focuses on both price breakout momentum (directionality) and potential pullback behavior, balancing offensive and defensive approaches.
Flexible Parameter Adjustment: Through point value parameter settings, the strategy can adapt to markets and instruments with different volatility characteristics, expanding its applicability.
Bidirectional Trading: The strategy includes trading logic for both long and short directions, fully utilizing market opportunities without being limited to single-direction trends.
Built-in Risk Management: Through preset stop-loss and take-profit levels, the risk and potential return of each trade are clearly controlled.
Despite its sophisticated design, the strategy still has these potential risks:
Fixed Point Settings: The fixed point values of 300, 50, 250, and 301 points may not be suitable for all market environments, especially during periods of significant volatility changes. The solution is to dynamically adjust these parameters based on instrument characteristics and current market volatility.
False Breakout Risk: Markets may exhibit false breakouts with quick reversals, leading to incorrect signals. This risk can be reduced by adding confirmation indicators such as volume or other momentum indicators.
Consecutive Loss Potential: In ranging markets, prices may frequently touch breakout thresholds without forming trends, potentially leading to consecutive stop-losses. The solution is to add market environment filters to reduce or pause trading during ranging markets.
Execution Slippage Impact: The strategy relies on precise price points and may face slippage issues in actual trading, especially in less liquid markets. It is recommended to simulate slippage during backtesting and relax entry conditions appropriately in live trading.
Phase Tracking Complexity: The multi-phase design improves accuracy but increases logical complexity, potentially causing delays or errors in trade execution. Regular checking and simplification of logic can improve execution efficiency.
For this strategy, here are several potential optimization directions:
Dynamic Parameter Adjustment: Change fixed point parameters to dynamic parameters based on market volatility (such as ATR indicator), allowing the strategy to better adapt to different market environments. This can reduce trigger thresholds during low volatility periods and increase them during high volatility periods, improving adaptability.
Add Market Environment Filtering: Introduce trend judgment indicators (such as moving average direction or ADX indicator) to execute the strategy only in favorable market environments, avoiding trading under unfavorable conditions.
Optimize Stop-Loss Settings: Consider using trailing stops instead of fixed stops, allowing profitable trades more room to develop while protecting realized profits.
Add Confirmation Factors: When entry signals trigger, add confirmation from volume, market structure, or other technical indicators to reduce the impact of false signals.
Time Filter: Add trading time window filters to avoid highly volatile but directionless market opening and closing periods, focusing on more stable trading timeframes.
Simplify Phase Transition Logic: Redesign phase transition logic to reduce unnecessary state checks, simplify code structure, and improve execution efficiency.
The Multi-Phase Price Breakthrough and Pullback Trading Strategy is a well-structured trading system that identifies favorable trading opportunities through multi-level price action analysis. Its core advantages lie in its multi-phase judgment mechanism, bidirectional trading capability, and built-in risk management system. While it faces issues like fixed parameter adaptability and false breakout risks, through the introduction of dynamic parameters, market environment filtering, and confirmation factors, the strategy’s stability and profitability can be significantly improved.
This strategy is particularly suitable for medium to short-term traders, especially those who focus on price action and wish to enter during the early stages of momentum changes. Through careful parameter adjustment and the addition of appropriate filtering conditions, this strategy can develop into a reliable trading system, providing a stable source of returns for quantitative trading portfolios.
/*backtest
start: 2024-05-13 00:00:00
end: 2025-05-11 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"DOGE_USDT"}]
*/
//@version=5
strategy("Custom Strategy", overlay=true, margin_long=1, margin_short=1, process_orders_on_close=true)
// 参数设置
point_value = input.float(0.0001, title="点值(例如:0.0001代表1个点)")
// 多单逻辑变量
var float long_ref_open = na
var float long_ref_high = na
var bool long_condition1 = false
var bool long_condition2 = false
var int long_phase = 0
// 空单逻辑变量
var float short_ref_open = na
var float short_ref_high = na
var bool short_condition1 = false
var bool short_condition2 = false
var int short_phase = 0
// 多单条件检查
// 多单第一条件检查
if not long_condition1 and not long_condition2
if high[1] - open[1] >= 300 * point_value
if low[1] <= high[1] - 50 * point_value
strategy.entry("Long", strategy.long)
else
long_ref_open := open[1]
long_ref_high := high[1]
long_phase := 1
else if close[1] - open[1] < 300 * point_value
long_phase := 2
// 多单第二条件检查
if long_phase == 1
if low <= long_ref_open + 250 * point_value
strategy.entry("Long", strategy.long)
long_phase := 0
if long_phase == 2
if high - close[1] >= 300 * point_value
if low <= high - 50 * point_value
strategy.entry("Long", strategy.long)
long_phase := 0
else
long_phase := 3
else
long_phase := 0
if long_phase == 3
if low <= open[2] + 250 * point_value
strategy.entry("Long", strategy.long)
long_phase := 0
// 空单条件检查(反向逻辑)
// 空单第一条件检查
if not short_condition1 and not short_condition2
if open[1] - low[1] >= 300 * point_value
if high[1] >= low[1] + 50 * point_value
strategy.entry("Short", strategy.short)
else
short_ref_open := open[1]
short_ref_high := low[1]
short_phase := 1
else if open[1] - close[1] < 300 * point_value
short_phase := 2
// 空单第二条件检查
if short_phase == 1
if high >= short_ref_open - 250 * point_value
strategy.entry("Short", strategy.short)
short_phase := 0
if short_phase == 2
if close[1] - low >= 300 * point_value
if high >= low + 50 * point_value
strategy.entry("Short", strategy.short)
short_phase := 0
else
short_phase := 3
else
short_phase := 0
if short_phase == 3
if high >= open[2] - 250 * point_value
strategy.entry("Short", strategy.short)
short_phase := 0
// 止损止盈逻辑
if strategy.position_size > 0
strategy.exit("Long Exit", "Long", stop = strategy.position_avg_price - 301 * point_value,limit = close[1] + 301 * point_value)
if strategy.position_size < 0
strategy.exit("Short Exit", "Short",stop = strategy.position_avg_price + 301 * point_value, limit = close[1] - 301 * point_value)