다중 시간 프레임 추세 추종 전략


생성 날짜: 2024-01-26 15:54:45 마지막으로 수정됨: 2024-01-26 15:54:45
복사: 0 클릭수: 614
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

다중 시간 프레임 추세 추종 전략

개요

이 전략은 다른 시간 주기 (50 바와 200 바) 의 최고 가격과 최저 가격을 계산하여 주요 가격 통로를 형성하며 장기 트렌드 방향을 나타냅니다. 빠른 신호 라인과 느린 신호 라인을 결합하여 단기 트렌드 방향을 판단합니다. 전략은 장기 단기 트렌드 방향이 일치 할 때 입찰을 촉구합니다.

전략 원칙

먼저, 마지막 50 바의 최고 가격과 최저 가격, 그리고 마지막 200 바의 최고 가격과 최저 가격을 계산하여, 두 개의 가격 통로를 형성하여 장기적인 경향 방향을 나타냅니다.

둘째, 마지막 7bar의 최고값과 최저값을 계산하여 빠른 신호 채널을 판단하는 단기 트렌드를 계산하고, 마지막 20bar의 최고값과 최저값을 계산하여 느린 신호 채널을 판단하는 단기 트렌드를 계산한다.

마지막으로, 빠른 신호 채널, 느린 신호 채널 및 장기 가격 채널의 방향이 일치 할 때 입시 신호를 提示한다. 예를 들어 모든 채널이 상승 추세에 있으면 구매를 提示한다. 모든 채널이 하락 추세에 있으면 판매를 提示한다.

우위 분석

이 전략의 가장 큰 장점은 장기 단기 통합 트렌드 방향을 식별할 수 있다는 것입니다. 다른 시간 주기 가격 경로를 확인함으로써 단기 시장 소음으로 혼란을 피하는 것이 효과적입니다.

또한, 전략은 다중 시간 프레임 판단을 채택하여 단기 가격 반전이 발생하더라도 신호를 쉽게 변경하지 않으며 신호의 안정성을 보장합니다.

위험 분석

이 전략의 주요 위험은 장기 단기 트렌드가 역전될 때, 여러 시간 주기 채널 확인이 필요하기 때문에 신호 발생에 약간의 지연이 있을 것이다. 이 때 맹목적으로 따라가면 손실이 확대될 수 있다.

또한, 높은 주파수 거래에 우호적이지 않으며, 단기 가격 변동에 대해 신속하게 반응할 수 없습니다. 급격한 상황에 직면하면, 중단 조건이 부적절하게 설정되면 큰 손실이 발생할 수 있습니다.

최적화 방향

적응적 동적 중지 전략을 추가하는 것을 고려할 수 있으며, 가격이 불리한 방향으로 특정 비율을 돌파 할 때 중지 출전을 통해 위험을 효과적으로 제어 할 수 있습니다.

또한 다양한 길이의 가격 채널을 추가하여 투표 방식으로 최종 신호를 결정하여 판단의 정확도를 높일 수 있습니다.

또는 기계 학습 알고리즘을 사용하여 채널의 매개 변수를 자동으로 최적화하여 현재 시장 환경에 더 적합한 매개 변수를 만듭니다.

요약하다

이 전략의 전체적인 아이디어는 명확하고 이해하기 쉽다. 다중 시간 프레임 가격 통로를 통해 시장 추세를 판단하여 단기 시장 소음을 효과적으로 제거 할 수 있다. 그러나 역전 상황을 처리하고 위험 통제를 강화해야 한다. 손해 방지 전략과 파라미터 최적화를 결합하면 전략의 안정성과 실전 효과를 더욱 강화할 수 있다.

전략 소스 코드
/*backtest
start: 2023-12-26 00:00:00
end: 2024-01-25 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ZoomerXeus

//@version=4
strategy("Swing High Low Price Channel V.1", overlay=true)

//========================= variable =================================//
dead_channel_source = input(title="Main swing channel source", defval="H/L", options=["H/L"])
fast_signal_length = input(title="Fast Slow Length", type=input.integer, defval=7, maxval=49, minval=1)
slow_signal_length = input(title="Slow Slow Length", type=input.integer, defval=20, maxval=49, minval=1)
is_show_only_dead_channel = input(title="Show main channel only", defval=true)
main_channel_width = input(title="Main line width", defval=2, minval=1)
signal_channel_width = input(title="Signal line width", defval=1, minval=1)

//========================= indicator function =================================//
dead_cross_high_50 = highest(high, 50) 
dead_cross_high_200 = highest(high, 200) 
//========================================
dead_cross_low_50 = lowest(low, 50) 
dead_cross_low_200 = lowest(low, 200) 
//========================================
medain_dead_cross_50 = ((dead_cross_high_50-dead_cross_low_50)*0.5)+dead_cross_low_50
medain_dead_cross_200 = ((dead_cross_high_200-dead_cross_low_200)*0.5)+dead_cross_low_200


//========================================
fasthighest = highest(high, fast_signal_length)
fastlowest = lowest(low, fast_signal_length)
//========================================
slowhighest = highest(high, slow_signal_length)
slowlowest = lowest(low, slow_signal_length)
//========================================

    
//========================= plot =================================//
plot(dead_channel_source == "H/L" ? dead_cross_high_50 : na,title="50 bar highest", color=color.red, linewidth=main_channel_width)
plot(dead_channel_source == "H/L" ? dead_cross_high_200 : na,title="200 bar highest", color=color.aqua, linewidth=main_channel_width)
plot(dead_channel_source == "H/L" ? dead_cross_low_50 : na,title="50 bar lowest", color=color.red, linewidth=main_channel_width)
plot(dead_channel_source == "H/L" ? dead_cross_low_200 : na,title="200 bar lowest", color=color.aqua, linewidth=main_channel_width)
plot(dead_channel_source == "H/L" ? medain_dead_cross_200 : na,title="200 bar middle lowest", color=color.orange, linewidth=main_channel_width)
plot(dead_channel_source == "H/L" ? medain_dead_cross_50 : na,title="50 bar middle lowest", color=color.lime, linewidth=main_channel_width)
//===========================================
plot(is_show_only_dead_channel == false ? fasthighest : na,title="fast signal highest", color=#ff00f9, linewidth=signal_channel_width)
plot(is_show_only_dead_channel == false ? fastlowest : na,title="fast signal lowest", color=#ff00f9, linewidth=signal_channel_width)
plot(is_show_only_dead_channel == false ? slowhighest : na,title="slow signal highest", color=color.white, linewidth=signal_channel_width)
plot(is_show_only_dead_channel == false ? slowlowest : na,title="slow signal lowest", color=color.white, linewidth=signal_channel_width)
//===========================================
plot(crossover(medain_dead_cross_50, medain_dead_cross_200) ? medain_dead_cross_200 : na, title="Dead cross buy plot", style=plot.style_circles, linewidth=6, color=color.lime)
plot(crossunder(medain_dead_cross_50, medain_dead_cross_200) ? medain_dead_cross_200 : na, title="Dead cross sell plot", style=plot.style_circles, linewidth=6, color=color.red)
plot(is_show_only_dead_channel and (medain_dead_cross_50 < medain_dead_cross_200) and high == slowhighest ? high : na, title="Follow trend short term  sell plot zone", style=plot.style_circles, linewidth=3, color=color.orange)
plot(is_show_only_dead_channel and (medain_dead_cross_50 > medain_dead_cross_200) and low == slowlowest ? low : na, title="Follow trend short term buy plot zone", style=plot.style_circles, linewidth=3, color=color.green)
plot(is_show_only_dead_channel and high == slowhighest and (high == dead_cross_high_200) ? high : na, title="Not follow trend short term  sell plot zone", style=plot.style_circles, linewidth=3, color=color.orange)
plot(is_show_only_dead_channel and low == slowlowest and (low == dead_cross_low_200) ? low : na, title="Not follow trend short term buy plot zone", style=plot.style_circles, linewidth=3, color=color.green)

//===================== open close order condition =========================================================//
strategy.entry("strong buy", true, 1, when=low == dead_cross_low_200)
strategy.exit("close strong buy 50%", "strong buy", qty_percent=50, when=high==slowhighest)
strategy.entry("strong sell", false, 1, when=high == dead_cross_high_200)
strategy.exit("close strong sell 50%", "strong sell", qty_percent=50, when=low==slowlowest)