
이 전략의 주요 아이디어는 평평한 가동 평균을 사용하여 평평한 가동 평균을 계산하여 가격 동향을 발견하고 가격과 평평한 가동 평균이 갈라졌을 때 더 많이 하고, 죽은 갈라졌을 때 공백을 하는 것이다.
이 전략은 먼저 평평한 이동 평균을 계산하는 함수를 정의합니다. smoothedMovingAvg는 이전 주기 이동 평균 값과 최신 값을 사용하여 특정 무게에 따라 현재 주기 이동 평균을 계산합니다.
그 다음 getHAClose라는 함수를 정의하여, 개시, 최고, 최저, 그리고 종결 가격에 따라 시작 평균 선의 종결 가격을 계산한다.
메인 전략 논리에서는, 먼저 다양한 주기들의 원시 가격을 취득하고, 그 다음에는 smoothedMovingAvg 함수를 사용하여 평평한 이동 평균을 계산하고, 그 다음에는 getHAClose 함수를 사용하여 평평한 시작 종료 가격을 계산한다.
마지막으로, 가격이 상회하여 평평하게 닫힌 가격에 더 많이 할 때, 평평하게 닫힌 가격에 더 많이 할 때, 평평하게 닫힌 가격에 더 많은 것을 할 때, 평평하게 닫힌 가격에 더 많은 것을 할 때, 평평하게 닫힌 가격에 더 많은 것을 할 때, 평평하게 닫힌 가격에 더 많은 것을 할 때, 평평하게 닫힌 가격에 더 많은 것을 할 때.
이 전략의 가장 큰 장점은 평평한 이동 평균을 사용하여 평평한 가시 평균을 계산하여 가격 추세를 더 정확하게 판단하고, 일부 잡음을 필터링하여 흔들림에서 잘못된 신호를 피하는 것입니다. 또한, 가시 평균은 그 자체로 추세를 강조하는 장점이 있으며, 가격과 결합하여 사용하면 판단 정확도를 더욱 향상시킬 수 있습니다.
이 전략의 주요 위험은 다음과 같습니다.
위와 같은 위험에 대해, 우리는 평형 매개 변수를 조정, 스톱 로즈 메커니즘을 도입, 단일 거래 포지션을 감소시키는 등의 방법을 통해 위험을 줄이고 전략의 안정성을 향상시킬 수 있습니다.
이 전략은 다음과 같은 부분에서 최적화될 수 있습니다.
위의 몇 가지 점들을 최적화함으로써, 전략의 곡선 적합성을 더욱 줄일 수 있고, 전략의 적응성과 안정성을 향상시킬 수 있다.
이 전략의 전체적인 아이디어는 명확하고 이해하기 쉽다. 평평한 계몽을 계산하여 가격 흐름을 판단하고, 이에 따라 장기간 조치를 취한다. 최대 장점은 일부 잡음을 필터링하고, 신호 판단의 정확성을 향상시키는 데 있다. 그러나 특정 파라미터 최적화 어려움이 있으며, 빠른 반전을 놓칠 수 있는 위험도 있다. 자조응 메커니즘을 도입하거나, 지표 포괄을 넓히는 등의 수단으로 더 나아가 최적화 할 수 있으며, 깊이 있는 연구의 가치가 있다.
/*backtest
start: 2023-12-01 00:00:00
end: 2023-12-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Smoothed Heiken Ashi Strategy", overlay=true)
// Inputs
g_TimeframeSettings = 'Display & Timeframe Settings'
time_frame = input.timeframe(title='Timeframe for HA candle calculation', defval='', group=g_TimeframeSettings)
g_SmoothedHASettings = 'Smoothed HA Settings'
smoothedHALength = input.int(title='HA Price Input Smoothing Length', minval=1, maxval=500, step=1, defval=10, group=g_SmoothedHASettings)
// Define a function for calculating the smoothed moving average
smoothedMovingAvg(src, len) =>
smma = 0.0
smma := na(smma[1]) ? ta.sma(src, len) : (smma[1] * (len - 1) + src) / len
smma
// Function to get Heiken Ashi close
getHAClose(o, h, l, c) =>
((o + h + l + c) / 4)
// Calculate smoothed HA candles
smoothedHAOpen = request.security(syminfo.tickerid, time_frame, open)
smoothedMA1close = smoothedMovingAvg(request.security(syminfo.tickerid, time_frame, close), smoothedHALength)
smoothedHAClose = getHAClose(smoothedHAOpen, smoothedHAOpen, smoothedHAOpen, smoothedMA1close)
// Plot Smoothed Heiken Ashi candles
plotcandle(open=smoothedHAOpen, high=smoothedHAOpen, low=smoothedHAOpen, close=smoothedHAClose, color=color.new(color.blue, 0), wickcolor=color.new(color.blue, 0))
// Strategy logic
longCondition = close > smoothedHAClose
shortCondition = close < smoothedHAClose
strategy.entry("Buy", strategy.long, when=longCondition)
strategy.close("Buy", when=shortCondition)
plotshape(series=longCondition, title="Buy Signal", color=color.green, style=shape.labelup, location=location.belowbar)
plotshape(series=shortCondition, title="Sell Signal", color=color.red, style=shape.labeldown, location=location.abovebar)