Files
strategies/基于历史回测的多时间周期公平价值缺口突破策略-Multi-timeframe-Fair-Value-Gap-Breakout-Strategy-with-Historical-Backtest.md
2025-04-30 11:10:28 +08:00

8.9 KiB

Name

基于历史回测的多时间周期公平价值缺口突破策略-Multi-timeframe-Fair-Value-Gap-Breakout-Strategy-with-Historical-Backtest

Author

ChaoZhang

Strategy Description

IMG

[trans]

策略概述

该策略是一个结合了多重时间周期分析、公平价值缺口(FVG)和结构突破(BOS)的综合交易系统。它通过在更高时间周期上识别价格结构的突破,同时在较低时间周期上寻找公平价值缺口形成的机会,从而确定潜在的交易入场点。该策略还集成了风险管理系统,包括止损和获利目标的自动设置。

策略原理

策略的核心逻辑建立在三个主要支柱之上:首先,利用更高时间周期(默认1小时或以上)来识别价格结构的突破(BOS),这为交易方向提供了基础框架。其次,在较低时间周期上寻找公平价值缺口(FVG),FVG的形成表明市场在该区域存在潜在的供需不平衡。最后,将这两个条件与当前价格位置相结合,当价格处于有利位置时触发交易信号。系统通过风险收益比和止损因子来管理每笔交易的风险。

策略优势

  1. 多维度分析:通过结合多个时间周期的分析,提高了交易信号的可靠性。
  2. 风险管理完善:内置的风险收益比设置和止损控制机制,确保每笔交易都有明确的风险控制。
  3. 视觉反馈:策略提供了清晰的视觉反馈,包括FVG盒子的显示和潜在交易机会的标记。
  4. 适应性强:通过参数调整,策略可以适应不同的市场条件和交易风格。

策略风险

  1. 假突破风险:市场可能出现假突破,导致错误的交易信号。解决方案是增加信号确认机制。
  2. 信号延迟:由于使用更高时间周期数据,可能存在信号滞后。建议结合其他技术指标进行确认。
  3. 市场波动风险:在高波动期间,FVG的形成可能不够稳定。可以通过调整FVG的观察长度来适应。

策略优化方向

  1. 信号过滤:可以添加成交量确认机制,只有在成交量支持的情况下才确认信号。
  2. 动态参数:可以根据市场波动率动态调整风险收益比和止损因子。
  3. 趋势过滤:增加趋势判断指标,只在趋势方向上开仓。
  4. 时间过滤:添加交易时间段过滤,避免在不利的市场时段交易。

总结

该策略通过综合运用多时间周期分析、价格结构突破和公平价值缺口,构建了一个完整的交易系统。其优势在于多维度的分析方法和完善的风险管理机制,但仍需要交易者根据实际市场情况进行适当的参数优化和风险控制。后续优化可以从信号确认、动态参数调整和市场环境过滤等方面入手,进一步提高策略的稳定性和可靠性。 ||

Strategy Overview

This strategy is a comprehensive trading system that combines multi-timeframe analysis, Fair Value Gap (FVG), and Break of Structure (BOS). It identifies potential trading entries by detecting structure breakouts on higher timeframes while looking for fair value gap opportunities on lower timeframes. The strategy also incorporates a risk management system with automated stop-loss and take-profit settings.

Strategy Principles

The core logic is built on three main pillars: First, it uses a higher timeframe (default 1 hour or above) to identify Break of Structure (BOS), which provides the foundational framework for trading direction. Second, it looks for Fair Value Gaps (FVG) on lower timeframes, indicating potential supply-demand imbalances in those areas. Finally, it combines these conditions with current price position to trigger trading signals when price is in favorable locations. The system manages risk through risk-reward ratios and stop-loss factors.

Strategy Advantages

  1. Multi-dimensional Analysis: Combines multiple timeframe analysis to enhance signal reliability.
  2. Comprehensive Risk Management: Built-in risk-reward settings and stop-loss control mechanisms ensure clear risk management for each trade.
  3. Visual Feedback: Strategy provides clear visual feedback including FVG box display and potential trade opportunity markers.
  4. High Adaptability: Through parameter adjustment, the strategy can adapt to different market conditions and trading styles.

Strategy Risks

  1. False Breakout Risk: Markets may exhibit false breakouts leading to incorrect trading signals. Solution is to add signal confirmation mechanisms.
  2. Signal Delay: Due to the use of higher timeframe data, there may be signal lag. Recommended to combine with other technical indicators for confirmation.
  3. Market Volatility Risk: During high volatility periods, FVG formation may not be stable. Can be addressed by adjusting the FVG observation length.

Strategy Optimization Directions

  1. Signal Filtering: Add volume confirmation mechanism to confirm signals only when supported by volume.
  2. Dynamic Parameters: Dynamically adjust risk-reward ratio and stop-loss factor based on market volatility.
  3. Trend Filtering: Add trend identification indicators to only take positions in trend direction.
  4. Time Filtering: Add trading session filters to avoid trading during unfavorable market periods.

Summary

This strategy constructs a complete trading system through the comprehensive use of multi-timeframe analysis, price structure breakouts, and fair value gaps. Its strengths lie in its multi-dimensional analysis approach and comprehensive risk management mechanisms, but traders still need to optimize parameters and control risks according to actual market conditions. Further optimization can focus on signal confirmation, dynamic parameter adjustment, and market environment filtering to further improve strategy stability and reliability.[/trans]

Source (PineScript)

/*backtest
start: 2024-01-17 00:00:00
end: 2025-01-15 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT","balance":49999}]
*/

//@version=5
strategy("ICT Strategy with Historical Backtest", overlay=true)

// === Настройки ===
tf = input.timeframe("60", title="Higher Timeframe (1H or above)")  // Таймфрейм для анализа BOS
fvg_length = input(3, title="FVG Lookback Length")                   // Длина для поиска FVG
risk_reward = input(2, title="Risk-Reward Ratio")                    // Риск-вознаграждение
show_fvg_boxes = input(true, title="Show FVG Boxes")                 // Показывать FVG
stop_loss_factor = input.float(1.0, title="Stop Loss Factor")         // Множитель для стоп-лосса

// === Переменные для анализа ===
var float bos_high = na
var float bos_low = na

// Получаем данные с более старшего таймфрейма
htf_high = request.security(syminfo.tickerid, tf, high)
htf_low = request.security(syminfo.tickerid, tf, low)
htf_close = request.security(syminfo.tickerid, tf, close)

// Определение BOS (Break of Structure) на старшем таймфрейме
bos_up = ta.highest(htf_high, fvg_length) > ta.highest(htf_high[1], fvg_length)
bos_down = ta.lowest(htf_low, fvg_length) < ta.lowest(htf_low[1], fvg_length)

// Обновляем уровни BOS
if (bos_up)
    bos_high := ta.highest(htf_high, fvg_length)
if (bos_down)
    bos_low := ta.lowest(htf_low, fvg_length)

// === Определение FVG (Fair Value Gap) ===
fvg_up = low > high[1] and low[1] > high[2]
fvg_down = high < low[1] and high[1] < low[2]

// Визуализация FVG (Fair Value Gap)
// if (show_fvg_boxes)
//     if (fvg_up)
//         box.new(left=bar_index[1], top=high[1], right=bar_index, bottom=low, bgcolor=color.new(color.green, 90), border_color=color.green)
//     if (fvg_down)
//         box.new(left=bar_index[1], top=high, right=bar_index, bottom=low[1], bgcolor=color.new(color.red, 90), border_color=color.red)

// === Логика сделок ===
// Условия для входа в Лонг
long_condition = bos_up and fvg_up and close < bos_high
if (long_condition)
    strategy.entry("Long", strategy.long, stop=low * stop_loss_factor, limit=low + (high - low) * risk_reward)

// Условия для входа в Шорт
short_condition = bos_down and fvg_down and close > bos_low
if (short_condition)
    strategy.entry("Short", strategy.short, stop=high * stop_loss_factor, limit=high - (high - low) * risk_reward)

// === Надписи для прогнозируемых сделок ===
if (long_condition)
    label.new(bar_index, low, text="Potential Long", color=color.green, style=label.style_label_up, textcolor=color.white, size=size.small)

if (short_condition)
    label.new(bar_index, high, text="Potential Short", color=color.red, style=label.style_label_down, textcolor=color.white, size=size.small)

Detail

https://www.fmz.com/strategy/478698

Last Modified

2025-01-17 14:45:10