대규모 변동성 돌파 양방향 거래 전략: 포인트 임계값을 기반으로 한 롱 및 숏 진입 시스템

ATR SL TP
생성 날짜: 2024-11-18 16:11:21 마지막으로 수정됨: 2024-11-18 16:11:21
복사: 0 클릭수: 576
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

대규모 변동성 돌파 양방향 거래 전략: 포인트 임계값을 기반으로 한 롱 및 숏 진입 시스템

개요

이 전략은 30분 K 선에 기반한 양방향 거래 시스템으로 가격 변동의 폭을 모니터링하여 거래 기회를 찾습니다. 전략의 핵심은 포인트 절벽을 설정하여 큰 변동성을 식별하고, 브레이크 확인 후 해당 방향으로 거래하는 것입니다. 전략에는 엄격한 시간 관리, 스톱 손실 및 거래 관리 메커니즘이 포함되어 있습니다.

전략 원칙

전략은 유효한 거래 신호를 식별하기 위해 여러 가지 필터링 메커니즘을 사용합니다. 첫째, 전략은 매 30분마다 K 라인 종료 시 엔티티의 변동 범위를 계산합니다. 변동이 기본 경계를 초과하면 잠재적인 거래 기회로 표시됩니다. 거래의 유효성을 보장하기 위해, 전략은 추가적인 완충 지점을 설정합니다. 가격이 이 완충 영역을 돌파 할 때만 실제 거래 신호를 유발합니다. 전략은 동시에 다중 공백 쌍방향 거래를 실현합니다.

전략적 이점

  1. 완벽한 시간 관리: 거래 시간 창을 제한하고, 비활성 시간대의 가짜 신호를 피하십시오.
  2. 양방향 거래 메커니즘: 시장의 양방향 기회를 포착하고 자금의 효율성을 높일 수 있습니다.
  3. 리스크 관리가 완성된: 고정 지점의 스톱 스톱 손실을 사용하여 리스크 평가 및 관리를 용이하게 한다
  4. 높은 수준의 자동화: 신호 인식에서 거래 실행에 이르기까지 모든 과정이 자동화되어 인간의 개입이 줄어들었습니다.
  5. 유연한 매개 변수 설정: 중요한 매개 변수들은 다양한 시장 환경에 적응할 수 있습니다.

전략적 위험

  1. 가짜 브레이크 위험: 큰 변동에 따라 가짜 브레이크가 발생할 수 있으며, 이로 인해 손실이 발생할 수 있습니다.
  2. 변수 감수성: 부적절한 스레드 설정으로 인해 놓친 기회 또는 과도한 거래가 발생할 수 있습니다.
  3. 시장 환경 의존성: 흔들리는 시장에서 자주 스톱로스를 유발할 수 있다.
  4. 슬라이드 포인트 영향: 높은 변동 기간 동안 실제 거래 가격은 신호 가격과 큰 오차가있을 수 있습니다.
  5. 자금 관리 위험: 포지션 관리 장치의 부재로 인해 과대 위험 경로가 발생할 수 있습니다.

전략 최적화 방향

  1. 트렌드 필터를 추가: 더 긴 주기 트렌드 지표와 결합하여 신호 품질을 향상
  2. 동적 변수 최적화: 시장의 변동에 따라 자동으로 절감 및 중지 변수를 조정합니다.
  3. 트랜지먼트 확인 도입: 트랜지먼트 필터링 조건을 증가시키고, 돌파구 신뢰성을 향상시킨다
  4. 정지 손실을 최적화: 동적 정지 손실을 구현하여 다양한 시장 환경에 적응
  5. 포지션 관리에 참여: 신호 강도 및 시장 변동률에 따라 포지션을 동적으로 조정

요약하다

이것은 완전하고 논리적으로 명확하게 설계된 자동화 거래 전략이다. 엄격한 조건 필터링과 위험 통제를 통해 전략은 더 나은 실용성을 가지고 있다. 그러나 여전히 실내에서 충분한 테스트와 최적화가 필요하며, 특히 파라미터 설정과 위험 통제에 대해서는 실제 시장 상황에 따라 조정해야 한다. 전략의 성공적인 운영은 안정적인 시장 환경과 적절한 파라미터 구성이 필요하며, 실내에서 사용하기 전에 충분한 재검토를 수행하는 것이 좋습니다.

전략 소스 코드
/*backtest
start: 2024-10-01 00:00:00
end: 2024-10-31 23:59:59
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy("Big Candle Breakout Strategy Both Side", overlay=true)  

// Input for the point move threshold
point_move_in = input.int(100, title="Point Move Threshold")
point_target = input.int(100, title="Point Target")
point_stoploss = input.int(100, title="Point Stop Loss")
point_buffer = input.int(5, title="Point Buffer")

point_move = point_buffer + point_move_in

// Define the start and end times for trading
start_hour = 9
start_minute = 15
end_hour = 14
end_minute = 30

// Function to check if the current time is within the allowed trading window
in_time_range = (hour(time('30')) > start_hour or (hour(time('30')) == start_hour and minute(time('30')) >= start_minute)) and (hour(time('30')) < end_hour or (hour(time('30')) == end_hour and minute(time('30')) <= end_minute))

// Retrieve the open, high, low, and close prices of 30-minute candles
open_30m = request.security(syminfo.tickerid, "30", open)
high_30m = request.security(syminfo.tickerid, "30", high)
low_30m = request.security(syminfo.tickerid, "30", low)
close_30m = request.security(syminfo.tickerid, "30", close)

// Calculate the range of the candle
candle_range_long = (close_30m - open_30m)
candle_range_short = (open_30m - close_30m)

// Determine if the candle meets the criteria to be marked
big_candle_long = candle_range_long >= point_move_in
big_candle_short = candle_range_short >= point_move_in

// Variables to store the state of the trade
var float long_entry_price = na
var float long_target_price = na
var float long_stop_loss_price = na

var float short_entry_price = na
var float short_target_price = na
var float short_stop_loss_price = na

// Check if there are no active trades
no_active_trades = (strategy.opentrades == 0)

// Long entry condition
if (big_candle_long and na(long_entry_price) and in_time_range and no_active_trades)
    long_entry_price := high_30m+point_buffer
    long_target_price := long_entry_price + point_target
    long_stop_loss_price := long_entry_price - point_stoploss
    strategy.entry("Buy", strategy.long, stop=long_entry_price, limit=long_target_price)

plot(long_entry_price, style=plot.style_linebr, color=color.blue, linewidth=2, title="Entry Price")
plot(long_target_price, style=plot.style_linebr, color=color.green, linewidth=2, title="Target Price")
plot(long_stop_loss_price, style=plot.style_linebr, color=color.red, linewidth=2, title="Stop Loss Price")

// Short entry condition
if (big_candle_short and na(short_entry_price) and in_time_range and no_active_trades)
    short_entry_price := low_30m - point_buffer
    short_target_price := short_entry_price - point_target
    short_stop_loss_price := short_entry_price + point_stoploss
    strategy.entry("Sell", strategy.short, stop=short_entry_price, limit=short_target_price)

plot(short_entry_price, style=plot.style_linebr, color=color.blue, linewidth=2, title="Short Entry Price")
plot(short_target_price, style=plot.style_linebr, color=color.green, linewidth=2, title="Short Target Price")
plot(short_stop_loss_price, style=plot.style_linebr, color=color.red, linewidth=2, title="Short Stop Loss Price") 

// Long exit conditions
if (not na(long_entry_price))
    strategy.exit("Long Exit", from_entry="Buy", limit=long_target_price, stop=long_stop_loss_price)
   
// Short exit conditions
if (not na(short_entry_price))
    strategy.exit("Short Exit", from_entry="Sell", limit=short_target_price, stop=short_stop_loss_price)

// Reset trade status
if (strategy.position_size == 0)
    long_entry_price := na
    long_target_price := na
    long_stop_loss_price := na

    short_entry_price := na
    short_target_price := na
    short_stop_loss_price := na

// Plot the big candle and entry/exit levels
plotshape(series=big_candle_long, location=location.abovebar, style=shape.circle, color=color.green)
plotshape(series=big_candle_short, location=location.abovebar, style=shape.circle, color=color.red)

//plot(long_entry_price, style=plot.style_stepline, color=color.blue, linewidth=2, title="Entry Price")
//plot(long_target_price, style=plot.style_stepline, color=color.green, linewidth=2, title="Target Price")
//plot(long_stop_loss_price, style=plot.style_stepline, color=color.red, linewidth=2, title="Stop Loss Price")