
쌍평평선 교차전략은 고전적인 트렌드 추적 전략이다. 이 전략은 두 개의 다른 주기의 이동 평균을 사용하여 시장 트렌드를 포착하며, 빠른 평평선 상에서 느린 평평선을 통과하면 다중 신호가 발생하고, 빠른 평평선 아래에서 느린 평평선을 통과하면 공백 신호가 발생한다. 이 전략의 핵심 아이디어는 빠른 평평선이 가격 변화에 더 민감하고, 시장 트렌드의 변화에 더 빨리 반응하며, 느린 평평선은 시장의 장기적인 추세에 반응한다. 두 개의 평평선을 교차함으로써 시장 트렌드의 전환을 판단하여 거래를 할 수 있다.
이 전략 코드에는 두 개의 이동 평균이 사용된다. 하나는 빠른 평균 (기본 14 기간) 이며 하나는 느린 평균 (기본 28 기간). 이동 평균 유형은 간단한 이동 평균 (SMA), 지수 이동 평균 (EMA), 가중 이동 평균 (WMA) 및 상대 이동 평균 (RMA) 을 선택할 수 있다.
이 전략의 주요 논리는 다음과 같습니다.
이러한 논리를 통해, 전략은 시장의 주요 트렌드를 추적할 수 있으며, 상승 트렌드에서 다중 상위 포지션을 보유, 하향 트렌드에서 빈 상위 포지션을 보유 또는 빈 포지션을 대기할 수 있다. 평행선 주기 및 유형은 다른 시장과 거래 품종에 따라 조정 및 최적화 할 수 있다.
이러한 위험들에 대해 다음과 같은 조치를 취할 수 있습니다.
이러한 최적화는 전략의 적응성과 안정성을 높여 다른 시장 상황에 더 잘 적응시킬 수 있다. 그러나 과도한 최적화는 전략이 지나치게 적합하여 실체에서 좋지 않은 성능을 발휘할 수 있다는 점도 주의해야 한다. 샘플 외의 데이터에서 추가 검증이 필요하다.
쌍평선 교차 전략은 두 개의 다른 주기 이동 평균의 교차를 통해 거래 신호를 생성하는 클래식 트렌드 추적 전략이다. 그것은 논리적으로 간단하고 구현하기 쉬운 추세 시장에 적합하다. 그러나 불안한 시장에서 빈번한 거래와 연속적인 손실이 발생할 수 있다. 따라서 이 전략을 사용할 때 시장 특성에 따라 평선 주기 매개 변수를 최적화하고 합리적으로 중지 손해를 설정해야합니다.
/*backtest
start: 2024-02-09 00:00:00
end: 2024-03-10 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © z4011
//@version=5
strategy("#2idagos", overlay=true, margin_long=100, margin_short=100)
allowShorting = input.bool(true, "Allow Shorting")
fastMALength = input.int(14, "Fast MA Length")
slowMALength = input.int(28, "Slow MA Length")
fastMAType = input.string("Simple", "Fast MA Type", ["Simple", "Exponential", "Weighted", "Relative"])
slowMAType = input.string("Simple", "Fast MA Type", ["Simple", "Exponential", "Weighted", "Relative"])
float fastMA = switch fastMAType
"Simple" => ta.sma(close, fastMALength)
"Exponential" => ta.ema(close, fastMALength)
"Weighted" => ta.wma(close, fastMALength)
"Relative" => ta.rma(close, fastMALength)
plot(fastMA, color = color.aqua, linewidth = 2)
float slowMA = switch slowMAType
"Simple" => ta.sma(close, slowMALength)
"Exponential" => ta.ema(close, slowMALength)
"Weighted" => ta.wma(close, slowMALength)
"Relative" => ta.rma(close, slowMALength)
plot(slowMA, color = color.blue, linewidth = 2)
longCondition = ta.crossover(fastMA, slowMA)
if (longCondition)
strategy.entry("Long", strategy.long)
shortCondition = ta.crossunder(fastMA, slowMA) and allowShorting
if (shortCondition)
strategy.entry("Short", strategy.short)
closeCondition = ta.crossunder(fastMA, slowMA) and not allowShorting
if (closeCondition)
strategy.close("Long", "Close")