이 전략은 3개의 이동 평균의 금叉死叉 형태를 기반으로 거래한다. 빠른 이동 평균 상의 중간선을 통과하고 중간선 상의 느린 선을 통과할 때 더 많이 거래한다. 빠른 이동 평균 아래의 중간선을 통과하고 중간선 아래의 느린 선을 통과할 때 공백한다.
구체적으로, 이 전략은 세 개의 다른 주기 이동 평균 사이의 교차를 사용하여 거래한다. 빠른 선은 현재 단기 경향을 나타냅니다. 중기 선은 중기 경향을 나타냅니다. 느린 선은 장기 경향을 나타냅니다.
포지션 보유 시간을 조정하고, 평균선 변수를 최적화하고, 손실을 막는 전략을 도입하는 등의 방법으로 위험을 관리할 수 있다.
이 전략은 삼평선 교차 판단 트렌드 방향에 기초하여 포지션을 보유한다. 장점은 거래 신호가 간단하고 명확하며 구성성이 강하다는 것이다. 단점은 지연이 쉽고 변수 최적화가 필요하다는 것이다. 변수 조정, 손실 중지 전략 등으로 효과를 높일 수 있으며 철회 위험을 제어할 수 있다. 이 전략은 거래자가 이동 평균의 응용과 다중평선 교차의 거래 사고방식을 숙지하도록 돕는다.
/*backtest
start: 2023-08-21 00:00:00
end: 2023-09-20 00:00:00
period: 3h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// © DaynTrading
//@version=4
// strategy(
// title="Simple Moving Average Cross",
// overlay=true,
// initial_capital=5000,
// default_qty_type=strategy.percent_of_equity,
// default_qty_value=2,
// commission_type=strategy.commission.percent,
// commission_value=0.075,
// pyramiding=0
// )
sma_top_input = input(title="SMA Top", type=input.integer, defval=20)
sma_mid_input = input(title="SMA Mid", type=input.integer, defval=50)
sma_low_input = input(title="SMA Low", type=input.integer, defval=200)
bars_long = input(title="Long: After trigger, how many bars to wait?", type=input.integer, defval=5)
bars_short = input(title="Short: After trigger, how many bars to wait?", type=input.integer, defval=5)
sma_top = sma(close, sma_top_input)
sma_mid = sma(close, sma_mid_input)
sma_low = sma(close, sma_low_input)
long = sma_top > sma_mid and sma_mid > sma_low
short = sma_top < sma_mid and sma_mid < sma_low
long_condition = long and long[bars_long] and not long[bars_long + 1]
short_condition = short and short[bars_short] and not short[bars_short + 1]
close_long = sma_top < sma_mid and sma_mid < sma_low and not long[bars_long + 1]
close_short = sma_top > sma_mid and sma_mid > sma_low and not short[bars_short + 1]
plot(sma_top, title="SMA Top", color=#95f252, linewidth=2)
plot(sma_mid, title="SMA Mid", color=#FF1493, linewidth=2)
plot(sma_low, title="SMA Low", color=#6a0dad, linewidth=2)
strategy.entry("LongPosition", strategy.long, when = long_condition)
strategy.entry("ShortPosition", strategy.short, when = short_condition)
strategy.close("LongPosition", when = close_short)
strategy.close("ShortPosition", when = close_long)