
트렌드 필터 이동평균선 교차량화 전략은 중장선 수량화 거래 전략이다. 이 전략은 빠른 이동평균선과 느린 이동평균선의 교차로를 통해 시장의 트렌드 방향을 판단하고, 효과적인 트렌드를 판단하는 전제 하에 입문한다. 또한, 이 전략은 더 긴 주기의 이동평균선을 트렌드 필터로 설정하고, 가격이 이 이동평균선을 돌파했을 때만 효과적인 거래 신호를 형성할 수 있다.
이 전략은 주로 이동 평균선의 교차 원칙에 기초한다. 구체적으로, 두 개의 다른 주기의 이동 평균선이 각각 계산되며, 전형적으로 20일선과 50일선으로 설정된다. 20일선이 아래에서 위로 50일선을 돌파할 때 구매 신호가 발생하고, 20일선이 위로부터 아래로 50일선을 돌파할 때 판매 신호가 발생한다. 이러한 간단한 교차 신호는 중장선에서의 돌파구를 포착할 수 있다고 여겨진다.
또한, 이 전략은 200 일 이동 평균을 전체 트렌드의 판단 지표로 설정한다. 가격 200 일 경계를 넘었을 때만 위의 간단한 교차 신호는 유효하다고 여겨진다. 이것은 트렌드 필터링 메커니즘을 구성하여 전체 시장에서 무효 신호를 많이 생성하는 것을 피할 수 있다.
중장선 조작, 너무 자주 거래하는 것을 피하고 거래 비용과 미끄러짐 위험을 줄이는 것.
이동평선교차 판단은 명확하고 이해하기 쉬운 구현이다.
트렌드 필터 메커니즘은 대부분의 무효 신호를 필터링하여 승률을 높일 수 있습니다.
이동 평균선 변수를 유연하게 조정할 수 있으며, 다른 품종과 시간 주기에도 적용된다.
단편적 손실을 제어하기 위해 스톱로스 스톱을 설정할 수 있다.
평균선 근처에서 가격이 흔들렸을 때, 무효 신호가 여러 번 발생하여 과도한 거래가 발생할 수 있다.
장기 주기 평균선은 시장에 뒤쳐져 있고, 트렌드 전환점을 놓칠 수 있다.
더 긴 역사 데이터가 필요한 이동 평균 지표를 구축하기 위해, 새로운 품종이나 짧은 주기를 적용할 수 없습니다.
정책의 매개 변수는 반복적으로 테스트되고 최적화되어야 하며, 잘못 설정되면 정책이 실패할 수 있다.
위험과 대응하는 방법:
더 긴 주기 평균선을 사용하거나 트렌드 필터 조건을 추가하십시오.
에너지 지표, 변동률 지표 등과 같은 다른 지표와 결합하여 큰 추세를 판단하십시오.
이동 평균 주기 변수의 자기 적응력을 향상한다.
매개 변수 최적화 및 피드백 메커니즘을 추가하고, 전략 매개 변수를 동적으로 조정한다.
다른 종류의 이동 평균을 시도해 보세요.
모바일 평균주기 기능이 추가되었다.
변동률 계열의 지표와 결합하여 트렌드 단위를 판단하여 이동 평균선 교차의 효과를 높인다.
기계 학습 알고리즘을 추가하여 전략 파라미터를 자동으로 최적화합니다.
다종 조합 전략을 탐색하고, 종 간의 연관성을 활용하여 수익을 창출하십시오.
트렌드 필터링 이동 평행선 교차 전략은 전체적으로 간단한 실용적인 중장선 수량화 전략이다. 그것은 평행선 교차를 통해 중장선 트렌드를 판단하고, 그 다음 트렌드 필터링과 함께 무효 신호를 줄인다. 이 전략은 이해하기 쉽고 구현할 수 있으며, 수량화 거래의 초보자에게 적합하다. 그것의 가능한 개선 공간은 이동 평행선의 최적화와 다른 지표 및 기계 학습 알고리즘과의 통합이다.
/*backtest
start: 2023-11-23 00:00:00
end: 2023-11-30 00:00:00
period: 1m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
////////////////////////////////////////////////////////////////////////////////
// Booz Strategy
// Developed for Godstime
// Version 1.1
// 11/28/2021
////////////////////////////////////////////////////////////////////////////////
//@version=4
strategy("Booz Strategy", "", true)
// ----------------------------- 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 = 1
// Long Side
strategy.entry("Long Entry", strategy.long, trade_qty, 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, trade_qty, 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)