
이 전략의 목적은 20주기 지수 이동 평균 ((EMA) 과 20주기 간단한 이동 평균 ((SMA) 의 교차로 잠재적인 트렌드 역점을 식별하는 것이다. 교차의 방향에 따라 더 많은 또는 더 적은 기회를 결정한다.
이 전략은 ta의 크로스오버와 크로스언더 함수를 사용하여 평행선의 교차를 검출한다.
이 전략은 이동 평균의 트렌드 추적 기능과 평균선 교차의 신호 생성을 결합하여 다음과 같은 장점을 가지고 있다:
이 전략에는 다음과 같은 위험도 있습니다.
대책:
이 전략은 다음과 같은 측면에서 최적화될 수 있습니다.
이 전략은 전체적으로 간단하고 실용적이며, 평선 교차 이론을 사용하여 잠재적인 트렌드 역점을 식별하는 것이 일반적이고 효과적인 전략 아이디어입니다. 그러나 다른 기술 지표, 동적 파라미터 설정, 스톱로드 방식 및 알고리즘 거래 방식 등을 추가함으로써 전략을 개선 할 수있는 여지가 있습니다.
/*backtest
start: 2022-12-28 00:00:00
end: 2024-01-03 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("EMA-SMA Crossover Strategy", overlay=true)
// Define the length of the moving averages
emaLength = 20
smaLength = 20
// Calculate moving averages
emaValue = ta.ema(close, emaLength)
smaValue = ta.sma(close, smaLength)
// Buy condition
buyCondition = ta.crossover(emaValue, smaValue) and close > emaValue
// Short sell condition
sellCondition = ta.crossunder(emaValue, smaValue) and close < emaValue
// Exit conditions for both Buy and Short sell
exitBuyCondition = ta.crossunder(emaValue, smaValue)
exitSellCondition = ta.crossover(emaValue, smaValue)
// Strategy logic
if (buyCondition)
strategy.entry("Buy", strategy.long)
if (sellCondition)
strategy.entry("Sell", strategy.short)
if (exitBuyCondition)
strategy.close("Buy")
if (exitSellCondition)
strategy.close("Sell")
// Plot the moving averages
plot(emaValue, color=color.blue, title="20 EMA")
plot(smaValue, color=color.red, title="20 SMA")