
이 전략은 잠재적인 구매/판매 신호를 식별하기 위해 초점 평형 그래프 클라우드와 단기 ((55)) 와 장기 ((200)) 간단한 이동 평균 ((SMA) 를 결합한다. 구매 신호는 클라우드와 장기 SMA보다 높고, 상단 SMA를 통과한 후 다시 단기 SMA를 통과해야 한다. 판매 신호는 클라우드와 장기 SMA를 통과한 후 다시 단기 SMA를 통과해야 한다.
이 전략은 다음과 같은 원칙에 기초하고 있습니다.
프로그램은 먼저 필요한 1차 클라우드 컴포넌트를 계산한다 (변환선, 기준선, 선행 스파인 A와 B), 그리고 단기 및 장기 SMA를. 그리고 가격의 클라우드 및 평행선에 대한 위치를 식별하기 위해 여러 조건을 정의한다. 모든 구매/판매 조건이 충족되면, 프로그램은 각각 구매 및 판매 신호를 발생시킨다.
이 “한 구름 다중 평평선 거래 전략”은 일회성 차트 구름과 간단한 이동 평균을 결합하여, 이미 확립된 추세에서 반등 평평선으로의 낮은 위험 진입 기회를 찾습니다. 이 전략은 가로수지 시장과 주요 뉴스 이벤트 기간 동안의 거래를 필터링하여 가짜 신호 위험을 줄여서 전반적인 성능을 향상시킬 수 있습니다. 이 전략은 주로 1시간과 2시간 등의 시간 프레임에서 좋은 성능을 보이는 중장기 거래자에게 적합합니다.
/*backtest
start: 2023-05-11 00:00:00
end: 2024-05-16 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Ichimoku Cloud and Moving Average Strategy", shorttitle="ICMA", overlay=true)
// Input parameters
shortMA = input.int(55, title="Short-term Moving Average Length")
longMA = input.int(200, title="Long-term Moving Average Length")
// Calculate moving averages
shortSMA = ta.sma(close, shortMA)
longSMA = ta.sma(close, longMA)
// Ichimoku Cloud settings
conversionPeriod = input.int(9, title="Conversion Line Period")
basePeriod = input.int(26, title="Base Line Period")
spanBPeriod = input.int(52, title="Span B Period")
displacement = input.int(26, title="Displacement")
// Calculate Ichimoku Cloud components
conversionLine = ta.sma(high + low, conversionPeriod) / 2
baseLine = ta.sma(high + low, basePeriod) / 2
leadSpanA = (conversionLine + baseLine) / 2
leadSpanB = ta.sma(high + low, spanBPeriod) / 2
// Plot Ichimoku Cloud components
plot(leadSpanA, color=color.blue, title="Leading Span A")
plot(leadSpanB, color=color.red, title="Leading Span B")
// Entry conditions
aboveCloud = close > leadSpanA and close > leadSpanB
belowCloud = close < leadSpanA and close < leadSpanB
aboveShortMA = close > shortSMA
aboveLongMA = close > longSMA
belowShortMA = close < shortSMA
belowLongMA = close < longSMA
// Buy condition (Price retests 55 moving average after being above it)
buyCondition = aboveCloud and aboveLongMA and close[1] < shortSMA and close > shortSMA
// Sell condition (Price retests 55 moving average after being below it)
sellCondition = belowCloud and belowLongMA and close[1] > shortSMA and close < shortSMA
// Strategy entry and exit
strategy.entry("Buy", strategy.long, when = buyCondition)
strategy.entry("Sell", strategy.short, when = sellCondition)
// Plot moving averages
plot(shortSMA, color=color.green, title="Short-term SMA")
plot(longSMA, color=color.red, title="Long-term SMA")
// Plot buy and sell signals
plotshape(series=buyCondition, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small, title="Buy Signal")
plotshape(series=sellCondition, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small, title="Sell Signal")