
이 전략은 고스카 가중 이동 평균 채널과 무작위 상대적으로 약한 지수 (Stochastic RSI) 를 결합한 트렌드 추적 거래 시스템이다. 이 전략은 고스카 가중 방식에 의해 가격 채널을 구축하고, 무작위 RSI 지표의 교차 신호와 결합하여 입문 및 출구 시기를 결정하여 트렌드를 파악하고 동력을 확인한다. 이 전략은 좋은 수학 기반을 가지고 있으며, 시장 소음을 효과적으로 필터링하여 주요 트렌드를 포착할 수 있다.
이 전략의 핵심 논리는 크게 두 가지로 이루어져 있습니다.
고스 통로 시스템: 고스 가중 이동 평균 ((GWMA) 와 고스 가중 표준 차 ((GWSD) 를 사용하여 가격 통로를 구성한다. GWMA는 최근의 데이터에 더 큰 무게를 부여하고, 평행선이 가격 변화에 대한 반응에 더 민감하게 만든다.
무작위 RSI 시스템: 전통적인 RSI 지표를 무작위적으로 처리하여 K값과 D값을 계산한다. 이 처리 방식은 오버 바이 오버 셀 영역을 더 잘 식별하여 더 정확한 동력 신호를 제공합니다.
거래 신호는 다음과 같은 조건에 의해 생성됩니다.
이 전략은 고스 통로와 무작위 RSI 지표를 결합하여 견고한 수학 기반의 트렌드 추적 시스템을 구축한다. 전략은 트렌드가 뚜렷한 시장에서 우수한 성능을 발휘하지만, 매개 변수 최적화 및 시장 환경에 대한 적응성에 주의를 기울여야 한다. 권장된 최적화 조치를 실행함으로써 전략의 안정성과 수익성을 더욱 향상시킬 수 있다.
/*backtest
start: 2024-02-21 00:00:00
end: 2025-02-18 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Binance","currency":"ETH_USDT"}]
*/
//@version=5
strategy("Gaussian Channel + Stoch RSI Strategy", overlay=true, margin_long=100, margin_short=100, initial_capital=100000, commission_type=strategy.commission.percent, commission_value=0.1, default_qty_type=strategy.percent_of_equity, default_qty_value=100, pyramiding=1)
// User Inputs
length = input.int(20, "Gaussian Length", minval=5)
multiplier = input.float(2.0, "Channel Multiplier", step=0.1)
rsiLength = input.int(14, "RSI Length", minval=1)
stochLength= input.int(14, "Stoch RSI Length", minval=1)
kLength = input.int(3, "Stoch K Smoothing", minval=1)
dLength = input.int(3, "Stoch D Smoothing", minval=1)
// Gaussian Weighted Moving Average Function
f_gaussian(source, length) =>
half = (length - 1) / 2.0
sum = 0.0
norm = 0.0
// Gaussian standard deviation chosen as length/6 for a smooth curve
denom = (length / 6.0) * (length / 6.0)
for i = 0 to length - 1
x = i - half
w = math.exp(-(x * x) / (2 * denom))
sum += source[i] * w
norm += w
sum / norm
// Gaussian Weighted Standard Deviation Function
f_gaussian_std(source, length) =>
half = (length - 1) / 2.0
gavg = f_gaussian(source, length)
sum = 0.0
norm = 0.0
denom = (length / 6.0) * (length / 6.0)
for i = 0 to length - 1
x = i - half
w = math.exp(-(x * x)/(2*denom))
diff = source[i] - gavg
sum += diff * diff * w
norm += w
math.sqrt(sum/norm)
// Compute Gaussian Channel
gaussMid = f_gaussian(close, length)
gaussStd = f_gaussian_std(close, length)
gaussUpper = gaussMid + gaussStd * multiplier
gaussLower = gaussMid - gaussStd * multiplier
// Stochastic RSI Calculation
rsi = ta.rsi(close, rsiLength)
rsiLowest = ta.lowest(rsi, stochLength)
rsiHighest = ta.highest(rsi, stochLength)
stoch = 100 * (rsi - rsiLowest) / math.max(rsiHighest - rsiLowest, 1e-10)
k = ta.sma(stoch, kLength)
d = ta.sma(k, dLength)
// Conditions
// Long entry: Price closes above upper Gaussian line AND Stoch RSI K > D (stochastic is "up")
longCondition = close > gaussUpper and k > d
// Exit condition: Price closes below upper Gaussian line
exitCondition = close < gaussUpper
// Only trade in the specified date range
inDateRange = time >= timestamp("2018-01-01T00:00:00") and time < timestamp("2069-01-01T00:00:00")
// Submit Orders
if inDateRange
if longCondition and strategy.position_size <= 0
strategy.entry("Long", strategy.long)
if exitCondition and strategy.position_size > 0
strategy.close("Long")
// Plot Gaussian Channel
plot(gaussMid, "Gaussian Mid", color=color.new(color.yellow, 0))
plot(gaussUpper, "Gaussian Upper", color=color.new(color.green, 0))
plot(gaussLower, "Gaussian Lower", color=color.new(color.red, 0))