스윙 거래 전략

저자:차오장, 날짜: 2023-10-11 16:29:37
태그:

전반적인 설명

이것은 유동평균의 크로스오버에 기반한 트렌드를 따르는 전략으로, 스톱 로스/익스피스 관리와 레버리지 효과를 결합하여 여러 시장에서 트렌드를 파악하고 이익을 극대화하는 것을 목표로 합니다.

전략 논리

이 전략은 빠른 및 느린 이동 평균의 교차를 거래 신호로 사용합니다. 빠른 MA가 느린 MA보다 높을 때 길게 이동하고 빠른 MA가 느린 MA보다 낮을 때 짧게 이동합니다.

소규모 트렌드에서 노이즈 트레이드를 필터링하기 위해 200일 MA를 트렌드 필터로 사용합니다. 거래 신호는 가격이 200일 MA보다 높거나 낮을 때만 생성됩니다.

이 전략은 범위 거래 스톱을 사용한다. 진입 후, 고정 비율의 스톱 손실과 수익을 취하는 수준이 설정된다. 예를 들어, 1%의 스톱 손실과 1%의 수익을 취한다. 가격은 스톱 손실 또는 수익을 취하면 포지션이 닫힌다.

레버리지 효과는 거래 수익을 증폭시키기 위해 사용됩니다. 다른 시장 특성에 따라 적절한 레버리지 비율을 선택할 수 있습니다. 예를 들어 10x.

이점 분석

  • 한 가지 장점은 암호화폐, 주식 및 선물 등 여러 시장의 트렌드를 식별할 수 있다는 것입니다. 이 전략은 광범위하게 적용될 수 있습니다.

  • 빠른 / 느린 MA 크로스오버와 트렌드 필터를 사용하면 트렌드 방향을 더 잘 파악하고 트렌드 시장에서 좋은 승률을 달성 할 수 있습니다.

  • 레인지 트레이딩 스톱은 견딜 수 있는 범위 내에서 단일 트레이드 손실을 제어하는 데 도움이 되고 전략의 안정적인 실행을 가능하게 합니다.

  • 레버리지 효과는 거래 수익을 증폭시키고 전략 우위를 최대한 활용합니다.

  • 황소/곰 시장에 대한 다른 배경 색상의 시각 인터페이스 디자인은 직관적인 시장 통찰력을 제공합니다.

위험 분석

  • 전략은 추세를 따르고 있기 때문에 불안정하고 범위 제한 시장에서 낮은 성과를 낼 수 있습니다. 포지션 크기는 통제되어야합니다.

  • 일정한 비율의 스톱 손실/이익 취득은 스톱 아웃 위험이 있습니다. 레벨은 시장의 특정 변동성에 따라 조정되어야 합니다.

  • 레버리지는 포지션 크기와 위험을 증폭시킵니다. 과대 손실을 피하기 위해 레버리지 비율을 제어해야합니다.

  • 이동 평균의 지연 특성으로 인해 거래 신호가 지연될 수 있습니다.

최적화 방향

  • 다른 매개 변수 조합을 테스트하고 최적의 빠른/연속한 MA 길이를 선택합니다.

  • 정확도를 높이기 위해 다른 지표나 모델을 필터 신호로 포함합니다. 예를 들어 ATR 정지, RSI 등.

  • ADX와 같은 다른 트렌드 식별 도구를 연구하여 트렌드 캡처 능력을 더욱 향상시킵니다.

  • 머신러닝 모델을 사용하여 전략 신호를 최적화하고 더 효과적인 출입/출입 지점을 찾습니다.

  • 더 합리적인 스톱을 위해 변동성과 시장 조건에 기반한 동적 스톱 손실/이익 취득을 고려하십시오.

요약

이 전략은 체계적인 트렌드-추천 접근 방식을 사용하여 위험을 제어하고 이익을 증대시키기 위해 스톱 / 수익을 취하고 레버리지를 사용합니다. 안정적인 알파 잠재력이있는 시장에서 널리 적용됩니다. 장기적인 성공을 위해 매개 변수 최적화, 위험 통제 및 전략 반복에 여전히주의를 기울여야합니다.


/*backtest
start: 2023-09-10 00:00:00
end: 2023-10-10 00:00:00
period: 2h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

////////////////////////////////////////////////////////////////////////////////
// Bozz Strategy
// Developed for Godstime
// Version 1.1
// 11/28/2021
////////////////////////////////////////////////////////////////////////////////

//@version=4
// strategy("Bozz Strategy", "", true, default_qty_type=strategy.percent_of_equity, default_qty_value=100, margin_long=0, margin_short=0)

// ----------------------------- Inputs ------------------------------------- //
source_ma_type = input("EMA", "Source MA Type", options=["SMA", "EMA"])
source_ma_length = input(50, "Source MA Length")
fast_ma_length = input(20, "Fast MA Length")
slow_ma_length = input(50, "Slow MA Length")
use_trend_filter = input(true, "Trend Filter")
trend_filter_ma_type = input("EMA", "Trend Filter MA Type", options=["SMA", "EMA"])
trend_filter_ma_length = input(200, "Trend Filter MA Period")
show_mas = input(true, "Show MAs")
swing_trading_mode = input(false, "Swing Trading")

// -------------------------- Calculations ---------------------------------- //
fast_ma = ema(close, fast_ma_length)
slow_ma = ema(close, slow_ma_length)
source_ma = source_ma_type == "EMA"? ema(close, source_ma_length): 
                                     sma(close, source_ma_length)
trend_filter_ma = trend_filter_ma_type == "EMA"? ema(close, trend_filter_ma_length): 
                                                 sma(close, trend_filter_ma_length)

// --------------------------- Conditions ----------------------------------- //
uptrend = not use_trend_filter or close > trend_filter_ma
buy_cond = crossover(fast_ma, slow_ma) and uptrend

downtrend = not use_trend_filter or close < trend_filter_ma
sell_cond = crossunder(fast_ma, slow_ma) and downtrend

// ---------------------------- Plotting ------------------------------------ //
bgcolor(use_trend_filter and downtrend? color.red: use_trend_filter? color.green: na)
plot(show_mas? fast_ma: na, "Fast MA", color.green)
plot(show_mas? slow_ma: na, "Slow MA", color.red)
plot(show_mas? source_ma: na, "Source MA", color.purple)
plot(show_mas? trend_filter_ma: na, "Trend Filter MA", color.blue)


// ---------------------------- Trading  ------------------------------------ //
// Inputs
sl_perc = input(1.0, "Stop Loss (in %)", group="Backtest Control")/100
tp_perc = input(1.0, "Take Profit (in %)", group="Backtest Control")/100
leverage = input(10, "Leverage", maxval=100, group="Backtest Control")
bt_start_time = input(timestamp("2021 01 01"), "Backtest Start Time", input.time, group="Backtest Control")
bt_end_time = input(timestamp("2021 12 31"), "Backtest End Time", input.time, group="Backtest Control")

// Trading Window
in_trading_window = true
trade_qty = (strategy.equity * leverage) / close 

// Long Side
strategy.entry("Long Entry", strategy.long,  when=buy_cond and in_trading_window)
long_tp = strategy.position_avg_price * (1 + tp_perc)
long_sl = strategy.position_avg_price * (1 - sl_perc)
if not swing_trading_mode
    strategy.exit("Long Exit", "Long Entry", limit=long_tp, stop=long_sl)

// Short Side
strategy.entry("Short Entry", strategy.short, when=sell_cond and in_trading_window)
short_tp = strategy.position_avg_price * (1 - tp_perc)
short_sl = strategy.position_avg_price * (1 + sl_perc)
if not swing_trading_mode
    strategy.exit("Short Exit", "Short Entry", limit=short_tp, stop=short_sl)

// End of trading window close
strategy.close_all(when=not in_trading_window)

더 많은