
この戦略は,高加減の移動平均チャネルとランダムな相対的に弱い指数 (Stochastic RSI) を組み合わせたトレンド追跡取引システムである.この戦略は高加減の方法によって価格チャネルを構築し,ランダムなRSI指標の交差信号と組み合わせて,入場と出場のタイミングを決定し,トレンドの把握と動力の確認を実現する.この戦略は,優れた数学的な基礎を有し,市場ノイズを効果的にフィルターし,主要なトレンドを捕捉することができる.
戦略の核心的な論理は以下の2つの部分から成り立っています.
高斯通道システム:高斯加重移動平均 ((GWMA) と高斯加重標準差 ((GWSD) を使用して価格通道を構築する.GWMAは最近のデータにより大きな重みを与え,均線が価格変化に対する反応をより敏感にする.通道上下はGWSDを倍数因子で掛けることで決定する.
ランダムな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))