
이것은 변동률과 윌리엄스 퍼센트 레인지 (Williams Percent Range) 를 결합한 자기 적응 트렌드 추적 전략이다. 이 전략은 가격 변동 범위와 사용자 정의 카운터를 계산하여 트렌드 판단의 민감도를 조정하여 다른 시장 환경에서 더 나은 적응을 이룬다. 전략의 핵심은 가격 변동의 폭을 관찰하여 윌리엄스 레인지의 매개 변수를 동적으로 조정하여 시장 트렌드의 전환점을 더 정확하게 포착하는 것이다.
전략은 먼저 한 주기의 가격 변동 범위 (Range) 와 이동 평균 (AvgRange) 을 계산한다. 실시간 가격 변화와 평균 변동 범위의 관계를 비교하여 두 개의 카운터 (TrueCount와 TrueCount2) 를 구축하여 눈에 띄는 변동의 발생 빈도를 기록한다. 이 카운터는 윌리엄스 지표의 계산 파라미터를 동적으로 조정하기 위해 사용되며, 전략은 시장 변동 상태에 따라 자동으로 민감도를 조정할 수 있다. 조정된 윌리엄스 지표 값이 예상된 상하를 돌파하면 전략은 그에 따른 구매 또는 판매 신호를 발생시킨다.
이것은 변동률 분석과 트렌드 추적을 결합한 혁신적인 전략이며, 적응 메커니즘을 통해 전략의 안정성과 신뢰성을 향상시킵니다. 일부 고유한 위험이 있지만, 합리적인 매개 변수 설정과 최적화 방향을 구현하면 다양한 시장 환경에서 안정적인 성능을 유지할 수 있습니다. 전략의 프레임워크 디자인은 추가 확장 및 최적화를 허용하며, 좋은 발전 잠재력을 가지고 있습니다.
/*backtest
start: 2024-10-28 00:00:00
end: 2024-11-27 00:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("ASCTrend", shorttitle="ASCTrend", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100)
eternalfg = input(false, title="eternal 確定")
eternal = eternalfg ? 1 : 0
ASClength = input.int(title="ASC Length", minval=4, defval=10)
RISK = input.int(title="RISK", minval=0, defval=3)
// Custom sum function
customSum(source, length) =>
sum = 0.0
for i = 0 to length - 1
sum := sum + source[i]
sum
x1 = 67 + RISK
x2 = 33 - RISK
Range = ta.highest(ASClength) - ta.lowest(ASClength)
AvgRange = ta.sma(Range, ASClength)
CountFg = math.abs(open - close) >= AvgRange * 2.0 ? 1 : 0
TrueCount = customSum(CountFg, ASClength)
CountFg2 = math.abs(close[3] - close) >= AvgRange * 4.6 ? 1 : 0
TrueCount2 = customSum(CountFg2, ASClength - 3)
wpr3RR = ta.wpr(3 + RISK + RISK)
wpr3 = ta.wpr(3)
wpr4 = ta.wpr(4)
WprAbs = 100 + (TrueCount2 > 0 ? wpr4 : TrueCount > 0 ? wpr3 : wpr3RR)
ASC_Trend = 0
ASC_Trend := WprAbs[eternal] < x2[eternal] ? -1 : WprAbs[eternal] > x1[eternal] ? 1 : ASC_Trend[1]
if (ta.crossover(ASC_Trend, 0))
strategy.entry("Long", strategy.long)
if (ta.crossunder(ASC_Trend, 0))
strategy.entry("Short", strategy.short)
plotshape(ta.crossover(ASC_Trend, 0), location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small, text="B", textcolor=color.white)
plotshape(ta.crossunder(ASC_Trend, 0), location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small, text="S", textcolor=color.white)
alertcondition(ta.crossover(ASC_Trend, 0), title="ASC_Trend UP", message="ASC_Trend UP")
alertcondition(ta.crossunder(ASC_Trend, 0), title="ASC_Trend Down", message="ASC_Trend Down")