고빈도 양적 대화 거래 전략: 돌파 신호에 기반한 적응형 동적 포지션 관리 시스템


생성 날짜: 2024-12-12 14:59:28 마지막으로 수정됨: 2024-12-12 14:59:28
복사: 1 클릭수: 437
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

고빈도 양적 대화 거래 전략: 돌파 신호에 기반한 적응형 동적 포지션 관리 시스템

개요

이 전략은 런던과 미국 거래 시간에 가격 돌파 기회를 잡는 데 초점을 맞춘 고주파 수량 거래 시스템입니다. 그것은 사용자 정의 거래 시간 (Kill Zones), 동적 포지션 관리 및 정밀한 주문 관리를 통해 안정적인 거래 수익을 달성합니다. 전략의 핵심은 특정 시간 동안의 가격 행동을 분석하여 회귀 주기의 높고 낮은 데이터를 결합하여 완전한 거래 프레임 워크를 구축하는 것입니다.

전략 원칙

이 전략은 다음과 같은 핵심 원칙에 따라 작동합니다.

  1. 시간대 선택: 전략은 런던과 미국 거래 시간에 초점을 맞추고 있으며, 이러한 시간대는 일반적으로 유동성과 변동성이 높습니다.
  2. 브레이크 신호: 현재의 종식 가격과 개시 가격의 관계를 분석하고 이전 시점의 높음과 낮음과 비교하여 잠재적인 브레이크 기회를 식별합니다.
  3. 동적 포지션: 계정 이자, 위험 비율 및 스톱로스 거리를 기반으로 동적으로 계산하는 각 거래의 포지션 크기.
  4. 주문 관리: 주문이 만료된 주문의 잠재적인 위험을 방지하기 위해 자동 취소 메커니즘을 구현합니다.
  5. 리스크/이익 비율: 개인 리스크 선호도에 따라 리스크/이익 비율을 설정할 수 있다.

전략적 이점

  1. 정확한 시간 관리: 거래 시간을 사용자 정의하여 가장 유동적인 시간에 거래하는 것을 보장합니다.
  2. 지능형 포지션 관리: 포지션 크기를 동적으로 계산하여 각 거래의 리스크 을 효과적으로 제어합니다.
  3. 유연한 변수 구성: 거래자는 개인 요구에 따라 변수를 조정할 수 있습니다.
  4. 완벽한 위험 제어: 중지, 중지 및 주문 지체 취소와 같은 다중 위험 제어 메커니즘을 포함한다.
  5. 높은 자동화: 신호 생성에서 주문 관리에 이르기까지 모든 과정이 자동화되어 인간의 개입이 줄어들었습니다.

전략적 위험

  1. 시장의 변동 위험: 높은 변동 기간 동안 잘못된 침입 신호를 유발할 수 있다.
  2. 슬라이드 리스크: 하이프렌크 트레이딩에서의 슬라이드는 전략의 성능에 영향을 줄 수 있다.
  3. 허위 돌파 위험: 시장에서 허위 돌파가 발생하여 거래 손실이 발생할 수 있습니다.
  4. 유동성 위험: 특정 시간에 유동성이 부족하면 주문 실행에 영향을 미칠 수 있습니다.

전략 최적화 방향

  1. 변동율 필터를 도입: 시장 변동율을 분석하여 진입 시기를 최적화한다.
  2. 트렌드 필터를 추가: 더 긴 트렌드 지표와 결합하여 거래 방향의 정확성을 향상시킵니다.
  3. 최적화 시간 창: 역사 데이터 분석에 따라 거래 시기를 정밀하게 조정합니다.
  4. 포지션 관리를 개선: 변동율에 기반한 동적 포지션 조정 메커니즘을 추가하는 것을 고려하십시오.

요약하다

이 전략은 시간, 가격, 포지션 등 여러 차원의 관리 방법을 통합하여 완전한 고주파 거래 시스템을 구축한다. 그것의 핵심 장점은 거래 시기를 정확하게 파악하고 완벽한 위험 관리 장치에 있습니다. 그러나 동시에 거래자는 시장 환경의 변화에 주의 깊게 관찰하고, 파라미터 설정을 제때 조정해야합니다.

전략 소스 코드
/*backtest
start: 2019-12-23 08:00:00
end: 2024-12-10 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=6
strategy("ENIGMA ENDGAME Strategy", overlay=true, margin_long=100, margin_short=100)

// Description: 
// The ENIGMA ENDGAME strategy leverages price action breakouts within specific kill zones (London and US sessions) to capture profitable opportunities. 
// The strategy uses dynamic position sizing based on account equity, precise entry logic via buy-stop and sell-stop orders, and robust risk management to achieve consistent profitability. 
// Features include:
// - Customizable kill zones for session-specific trading.
// - Risk management with dynamic position sizing based on user-defined percentages.
// - Multiple entry opportunities with lookback-based high/low tracking.
// - Automatic pending order cancellation to avoid stale trades.
// - Adjustable risk-reward ratios for optimal profit-taking.

// Define customizable kill zones for London and US sessions
london_start_hour = input.int(2, minval=0, maxval=23, title="London Start Hour (UTC)")
london_end_hour = input.int(5, minval=0, maxval=23, title="London End Hour (UTC)")
us_start_hour = input.int(8, minval=0, maxval=23, title="US Start Hour (UTC)")
us_end_hour = input.int(11, minval=0, maxval=23, title="US End Hour (UTC)")

// Risk management parameters
risk_percentage = input.float(0.1, title="Risk Percentage per Trade (%)", step=0.01)
account_balance = strategy.equity

// Define lookback parameters
lookback_period = 3
cancel_after_bars = input.int(5, title="Cancel Pending Orders After Bars")

// User-defined risk-reward ratio
risk_reward_ratio = input.float(1.0, title="Risk-Reward Ratio", minval=0.1, step=0.1)

// Kill zone function
in_kill_zone = (hour(time) >= london_start_hour and hour(time) < london_end_hour) or (hour(time) >= us_start_hour and hour(time) < us_end_hour)

// Calculate Position Size Based on Risk
calc_position_size(entry_price, stop_loss) =>
    // This function calculates the position size based on the account equity, risk percentage, and stop-loss distance.
    risk = account_balance * (risk_percentage / 100)
    stop_loss_distance = math.abs(entry_price - stop_loss)
    // Validate stop-loss distance
    stop_loss_distance := stop_loss_distance < syminfo.mintick * 10 ? syminfo.mintick * 10 : stop_loss_distance
    position_size = risk / stop_loss_distance
    // Clamp position size
    math.min(position_size, 10000000000.0) // Limit to Pine Script max qty

// Initialize arrays to store high/low levels
var float[] buy_highs = array.new_float(0)
var float[] sell_lows = array.new_float(0)
var int[] pending_orders = array.new_int(0)

// Buy and Sell Arrow Conditions
bullish_arrow = close > open and close > high[1] and in_kill_zone // Triggers buy logic when price action breaks out in the upward direction within a kill zone.
bearish_arrow = close < open and close < low[1] and in_kill_zone // Triggers sell logic when price action breaks out in the downward direction within a kill zone.

// Store Highs and Place Buy-Stops
if bullish_arrow
    array.clear(buy_highs) // Clears previous data to store new highs.
    for i = 1 to lookback_period
        array.push(buy_highs, high[i]) // Tracks highs from the lookback period.
    
    // Place buy-stop orders
    for high_level in buy_highs
        stop_loss = low - syminfo.mintick * 10 // 1 pip below the low
        take_profit = high_level + (high_level - stop_loss) * risk_reward_ratio // Calculate take-profit based on the risk-reward ratio.
        strategy.entry("Buy", strategy.long, stop=high_level, qty=calc_position_size(high_level, stop_loss))
        strategy.exit("Take Profit", "Buy", limit=take_profit, stop=stop_loss)

// Store Lows and Place Sell-Stops
if bearish_arrow
    array.clear(sell_lows) // Clears previous data to store new lows.
    for i = 1 to lookback_period
        array.push(sell_lows, low[i]) // Tracks lows from the lookback period.
    
    // Place sell-stop orders
    for low_level in sell_lows
        stop_loss = high + syminfo.mintick * 10 // 1 pip above the high
        take_profit = low_level - (stop_loss - low_level) * risk_reward_ratio // Calculate take-profit based on the risk-reward ratio.
        strategy.entry("Sell", strategy.short, stop=low_level, qty=calc_position_size(low_level, stop_loss))
        strategy.exit("Take Profit", "Sell", limit=take_profit, stop=stop_loss)

// Cancel Pending Orders After Defined Bars
if array.size(pending_orders) > 0
    for i = 0 to array.size(pending_orders) - 1
        if bar_index - array.get(pending_orders, i) >= cancel_after_bars
            array.remove(pending_orders, i) // Removes outdated pending orders.

// Alerts for debugging
alertcondition(bullish_arrow, title="Buy Alert", message="Buy signal generated.")
alertcondition(bearish_arrow, title="Sell Alert", message="Sell signal generated.")