
この戦略は,相対的に強い指数 ((RSI)) をベースにしたスマートな取引システムで,複数の移動平均とブリン帯の指標を組み合わせて,市場のオーバーバイオーバーセール領域を識別して,選択時に取引する.戦略の核心は,RSIの突破と逆転の信号を介して,異なるタイプの移動平均と組み合わせてトレンド確認を行い,効率的な波段操作を実現する.この戦略は,強力な適応性を持ち,異なる市場環境に応じてパラメータを調整することができる.
戦略は14サイクルRSIを中心指標として採用し,RSIと30/70の2つの重要なレベルの交差状況を監視することによって取引信号を生成する.RSIが30を突破すると,システムは市場が超売りから看板に転じると判断し,多信号を触発する.RSIが70を下回ると,システムは市場が超買いから看板に転じると判断し,平仓信号を触発する.同時に,戦略は多種な平均線 ((SMA,EMA,SMMA,WMA,VMA) とブリン帯を補助指標として導入し,トレンドの方向と市場の変動性を確認する.
この戦略は,RSI指標によって市場のオーバーバイオーバーセルの機会を捕捉し,複数の技術指標と組み合わせてシグナルを確認し,優れた実用性と信頼性を有する.戦略の設計は,リスク管理を十分に考慮し,パラメータの最適化と指標の組み合わせにより,異なる市場環境に適応することができます.トレーダーは,実用化する前に十分なフィットバックを検証し,特定の市場の特徴に応じてパラメータ設定を調整することをお勧めします.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-12-10 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy(title="Demo GPT - Relative Strength Index", shorttitle="RSI Strategy", overlay=false, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_value=0.1, slippage=3)
// Inputs
rsiLengthInput = input.int(14, minval=1, title="RSI Length", group="RSI Settings")
rsiSourceInput = input.source(close, "Source", group="RSI Settings")
calculateDivergence = input.bool(false, title="Calculate Divergence", group="RSI Settings", tooltip="Calculating divergences is needed in order for divergence alerts to fire.")
// RSI Calculation
change = ta.change(rsiSourceInput)
up = ta.rma(math.max(change, 0), rsiLengthInput)
down = ta.rma(-math.min(change, 0), rsiLengthInput)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
// RSI Plots
rsiPlot = plot(rsi, "RSI", color=#7E57C2)
rsiUpperBand = hline(70, "RSI Upper Band", color=#787B86)
midline = hline(50, "RSI Middle Band", color=color.new(#787B86, 50))
rsiLowerBand = hline(30, "RSI Lower Band", color=#787B86)
fill(rsiUpperBand, rsiLowerBand, color=color.rgb(126, 87, 194, 90), title="RSI Background Fill")
plot(50, color=na, editable=false, display=display.none)
// Moving Averages
maTypeInput = input.string("SMA", "Type", options=["None", "SMA", "SMA + Bollinger Bands", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="Moving Average")
maLengthInput = input.int(14, "Length", group="Moving Average")
bbMultInput = input.float(2.0, "BB StdDev", minval=0.001, maxval=50, step=0.5, group="Moving Average")
enableMA = maTypeInput != "None"
isBB = maTypeInput == "SMA + Bollinger Bands"
// MA Calculation
ma(source, length, MAtype) =>
switch MAtype
"SMA" => ta.sma(source, length)
"SMA + Bollinger Bands" => ta.sma(source, length)
"EMA" => ta.ema(source, length)
"SMMA (RMA)" => ta.rma(source, length)
"WMA" => ta.wma(source, length)
"VWMA" => ta.vwma(source, length)
smoothingMA = enableMA ? ma(rsi, maLengthInput, maTypeInput) : na
smoothingStDev = isBB ? ta.stdev(rsi, maLengthInput) * bbMultInput : na
plot(smoothingMA, "RSI-based MA", color=color.yellow, display=enableMA ? display.all : display.none)
bbUpperBand = plot(smoothingMA + smoothingStDev, title="Upper Bollinger Band", color=color.green, display=isBB ? display.all : display.none)
bbLowerBand = plot(smoothingMA - smoothingStDev, title="Lower Bollinger Band", color=color.green, display=isBB ? display.all : display.none)
fill(bbUpperBand, bbLowerBand, color=isBB ? color.new(color.green, 90) : na, title="Bollinger Bands Background Fill", display=isBB ? display.all : display.none)
// Trade Logic
longCondition = ta.crossover(rsi, 30)
exitCondition = ta.crossunder(rsi, 70)
// Start Date & End Date
startDate = input(timestamp("2018-01-01 00:00"), "Start Date", group="Date Range")
endDate = input(timestamp("2069-12-31 23:59"), "End Date", group="Date Range")
inDateRange = true
// Execute Trades
if (longCondition and inDateRange)
strategy.entry("Long", strategy.long)
if (exitCondition and inDateRange)
strategy.close("Long")