
이 전략은 1/2/4 주기의 간단한 이동 평균 ((SMA) 을 기반으로 한 교차 신호의 거래 시스템이다. 단기 주기 및 중기 주기 평균선과 장기 주기 평균선의 동방향 교차를 관찰함으로써 시장 추세의 전환점을 포착하여 추세를 추적하고 적시에 중단합니다. 전략은 간단하고 효율적으로 설계되어 이해하기 쉽고 실행됩니다.
전략의 핵심은 세 개의 다른 주기 ((1/2/4) 의 간단한 이동 평균을 사용하여 단기 ((1기) 와 중기 ((2기) 의 평균선이 동시에 상향으로 긴 주기 ((4기) 의 평균선을 통과하는지 판단하여 구매 신호를 결정하는 것입니다. 반대로, 단기 및 중기 평균선이 동시에 하향으로 긴 주기 평균선을 통과 할 때 판매 신호를 생성합니다. 이러한 다중 확인 메커니즘은 가짜 신호를 효과적으로 감소시키고 거래의 정확성을 향상시킵니다. 구체적으로, ta.crossover ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
이 전략은 다중 이동 평균의 교차로 시장 추세를 포착하고, 설계 아이디어는 명확하며, 구현 방법은 간단하고 효과적이다. 약간의 지연과 잘못된 신호의 위험이 있지만, 합리적인 매개 변수 최적화와 부가적인 지표의 보완을 통해 더 나은 거래 시스템을 구축 할 수 있습니다. 전략은 확장성이 강하며, 기본 프레임워크를 추가적으로 최적화하고 개선하는 데 적합합니다.
/*backtest
start: 2024-10-20 00:00:00
end: 2025-02-18 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Binance","currency":"BTC_USDT"}]
*/
//@version=6
strategy("1/2/4 Moving Average STR 1.0.0", overlay=true)
o_length = input(1, title="1 Closed")
t_length = input(2, title="2 Closed")
f_length = input(4, title="4 Closed")
// Calculate the simple moving averages.
ma_o = ta.sma(close, o_length)
ma_t = ta.sma(close, t_length)
ma_f = ta.sma(close, f_length)
// Plot the moving averages on the chart.
plot(ma_o, color=color.green, title="1 MA")
plot(ma_t, color=color.red, title="2 MA")
plot(ma_f, color=color.blue, title="4 MA")
// Assign the crossover and crossunder results to global variables.
crossover_o = ta.crossover(ma_o, ma_f)
crossover_t = ta.crossover(ma_t, ma_f)
crossunder_o = ta.crossunder(ma_o, ma_f)
crossunder_t = ta.crossunder(ma_t, ma_f)
// Generate signals based on the global crossover variables.
// Buy signal: both 1 and 2 SMAs cross over the 4 SMA on the same bar.
buy_signal = crossover_o and crossover_t
// Sell signal: both 1 and 2 SMAs cross under the 4 SMA on the same bar.
sell_signal = crossunder_o and crossunder_t
// Enter trades based on the signals.
// For a long position, enter on a buy signal and exit when a sell signal occurs.
if buy_signal
strategy.entry("Long", strategy.long)
if sell_signal
strategy.close("Long")
// For a short position, enter on a sell signal and exit when a buy signal occurs.
if sell_signal
strategy.entry("Short", strategy.short)
if buy_signal
strategy.close("Short")