세션 브레이크아웃을 기반으로 한 단기 스프레드 거래 전략


생성 날짜: 2023-09-20 17:00:16 마지막으로 수정됨: 2023-09-20 17:00:16
복사: 1 클릭수: 724
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

개요

이 전략은 다중 시간 프레임의 다중 공백 정지판과 결합하여 세션 시간 동안 단선 돌파구를 포착하여 확산 거래를 한다.

전략 원칙

  1. 당일과 단기간의 다중 공중 궤도를 계산하여 두 시간 프레임의 돌파구를 형성한다.

  2. 오직 사용자 정의된 거래 시간 내에 거래한다. 이 시간대는 브레이크 포트에 들어가기 시작하며, 이 시간대는 평점으로 끝난다.

  3. 가격 계산 실시간 EMA는 입시 가격으로 . 가격 중궤도를 넘으면 돌파 신호를 발생 .

  4. 돌파구 밖의 손실선을 설정한다. 돌파구가 실패했을 때 손실을 멈춘다.

  5. 가격이 중간 궤도 근처로 돌아갔을 때, 파격이 실패했다고 확인하고 상쇄한다.

우위 분석

  1. 여러 시간 프레임과 함께, 가짜 돌파구를 효과적으로 필터링 할 수 있습니다.

  2. 중요한 뉴스를 피하기 위해 거래시간을 제한합니다.

  3. EMA는 가격 추적을 순차적으로 하고, 적시에 시장에 진입한다.

  4. 스톱 라인을 설정하면 위험을 조절할 수 있습니다.

  5. 시간대에 따라 필수적으로 청산하면 밤새 위험을 피할 수 있다.

위험 분석

  1. 단선 뚫림이 발생할 수 있는 상황

  2. 일부 돌파구들은 시기가 끝날 때까지 완전히 수익을 내지 못할 수도 있습니다.

  3. 시간대가 잘못 설정되어도 거래 기회를 놓칠 수 있습니다.

  4. 모든 돌파구가 예상 수익을 달성할 수 있다고 보장할 수 없습니다.

  5. 최적화 파라미터를 적용할 때 문제가 발생할 수 있습니다.

최적화 방향

  1. 다양한 돌파변수들을 테스트하여 최적의 조합을 찾는다.

  2. 다른 지표들을 평가하여 진입의 정확성을 높여라.

  3. 거래 시기를 최적화하여 수익과 위험 사이의 균형을 찾습니다.

  4. 이 연구의 목적은 수익을 잠금하는 데에 있어 ‘마비방지 전략’과 연계되는 방법을 연구하는 것이다.

  5. 다양한 품종의 파라미터 설정의 차이를 테스트한다.

  6. 기계학습 알고리즘의 동적 최적화 매개 변수.

요약하다

이 전략은 제한된 세션 뚫림으로 단선 스프레드 거래를 시도한다. 가짜 뚫림과 위험 관리에 대한 최적화를 통해 실용적이고 효율적인 단선 거래 전략으로 개선할 수 있다.

전략 소스 코드
/*backtest
start: 2023-08-20 00:00:00
end: 2023-09-19 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=3
strategy("Breakout Scalper", overlay=true)

// -------------------------------------------------------------------------------------------------
// INPUTS
// -------------------------------------------------------------------------------------------------
// Period of the "fast" donchian channel
fast_window = input(title="Fast Window",  defval=13, minval=1)
// Used for the volatility (atr) period
slow_window = input(title="Slow Window",  defval=52, minval=1)
// Period of EMA used as the current price
instant_period = input(title="Instant Period",  defval=3, minval=1)
// Minimum ratio of cloud width to ATR in order for trade to be active
cloud_min_percent = input(title="Minimum Cloud ATR Multiplier", type=float, defval=1.0, minval=0)
// Session where we allow trades to be active
trading_sesh = input(title="Trading Session",  defval='1000-1500')
// -------------------------------------------------------------------------------------------------

// -------------------------------------------------------------------------------------------------
// SESSION TIMING
// -------------------------------------------------------------------------------------------------
is_newbar(t) =>
    na(t[1]) and not na(t) or t[1] < t

day_time = time("D")
sess_time = time(timeframe.period, trading_sesh)
day_open_bar = is_newbar(day_time)
sess_open_bar = is_newbar(sess_time)
sess_close_bar = na(sess_time) and not na(sess_time[1])
sess_is_open = false
sess_is_open := sess_open_bar ? true : (sess_close_bar ? false : sess_is_open[1])
// -------------------------------------------------------------------------------------------------

// -------------------------------------------------------------------------------------------------
// DONCHIANS
// -------------------------------------------------------------------------------------------------
slow_high = na
slow_high := day_open_bar ? high : (high > slow_high[1] ? high : slow_high[1])
slow_low = na
slow_low := day_open_bar ? low : (low < slow_low[1] ? low : slow_low[1])
slow_mid = (slow_high + slow_low) / 2

fast_low = max(slow_low, lowest(fast_window))
fast_high = min(slow_high, highest(fast_window))
fast_mid = (fast_low + fast_high) / 2
// -------------------------------------------------------------------------------------------------


// -------------------------------------------------------------------------------------------------
// TREND CLOUD
// -------------------------------------------------------------------------------------------------
cloud_width = fast_mid - slow_mid
slow_atr = atr(slow_window)
cloud_percent = cloud_width / slow_atr
cloud_color = cloud_percent > cloud_min_percent ? green : (cloud_percent < -cloud_min_percent ? red : gray)

fp = plot(fast_mid, title="Fast MidR", color=green)
sp = plot(slow_mid, title="Slow MidR", color=red)
fill(fp, sp, color=cloud_color)
// -------------------------------------------------------------------------------------------------


// -------------------------------------------------------------------------------------------------
// INSTANT PRICE
// -------------------------------------------------------------------------------------------------
instant_price = ema(close, instant_period)
plot(instant_price, title="Instant Price", color=black, transp=50)
// -------------------------------------------------------------------------------------------------


// -------------------------------------------------------------------------------------------------
// ENTRY SIGNALS & STOPS
// -------------------------------------------------------------------------------------------------
buy_entry_signal = sess_is_open and (instant_price > fast_mid) and (cloud_percent > cloud_min_percent)
sell_entry_signal = sess_is_open and (instant_price < fast_mid) and (cloud_percent < -cloud_min_percent)
buy_close_signal = sess_close_bar or (cloud_percent < 0)
sell_close_signal = sess_close_bar or (cloud_percent > 0)

entry_buy_stop = slow_high
entry_sell_stop = slow_low
exit_buy_stop = max(slow_low, fast_low)
exit_sell_stop = min(slow_high, fast_high)

entry_buy_stop_color = (strategy.position_size == 0) ? (buy_entry_signal ? green : na) : na
plotshape(entry_buy_stop, location=location.absolute, color=entry_buy_stop_color, style=shape.circle)
entry_sell_stop_color = (strategy.position_size == 0) ? (sell_entry_signal ? red : na) : na
plotshape(entry_sell_stop, location=location.absolute, color=entry_sell_stop_color, style=shape.circle)
exit_buy_stop_color = (strategy.position_size > 0) ? red : na
plotshape(exit_buy_stop, location=location.absolute, color=exit_buy_stop_color, style=shape.xcross)
exit_sell_stop_color = (strategy.position_size < 0) ? green : na
plotshape(exit_sell_stop, location=location.absolute, color=exit_sell_stop_color, style=shape.xcross)
// -------------------------------------------------------------------------------------------------


// -------------------------------------------------------------------------------------------------
// STRATEGY EXECUTION
// -------------------------------------------------------------------------------------------------
strategy.entry("long", strategy.long, stop=entry_buy_stop, when=buy_entry_signal)
strategy.cancel("long", when=not buy_entry_signal)
strategy.exit("stop", "long", stop=exit_buy_stop)
strategy.entry("short", strategy.short, stop=entry_sell_stop, when=sell_entry_signal)
strategy.cancel("short", when=not sell_entry_signal)
strategy.exit("stop", "short", stop=exit_sell_stop)
strategy.close("long", when=buy_close_signal)
strategy.close("short", when=sell_close_signal)
// -------------------------------------------------------------------------------------------------