
この戦略は,RSI2指数と移動平均を組み合わせた取引システムである.これは,主にRSI指数がオーバーセール領域の反転信号を監視することによって,潜在的な多額の機会を捕捉し,移動平均をトレンドフィルターとして組み合わせることで,取引の正確性を向上させるためのものです.
戦略の中核となるロジックには、次の重要な要素が含まれます。
これは,RSI超売り反転シグナルを組み合わせて均線トレンドフィルタリングを使用して市場機会を捉える構造が整った,論理的に明確な取引戦略である.戦略の優点は,パラメータの柔軟性,風力制御の合理性にあるが,偽突破リスクとパラメータのセンシビリティの問題にも注意する必要がある.提案された最適化方向によって,戦略には,さらなる改善の余地があり,異なる市場環境下での適応性をさらに向上させることができる.
/*backtest
start: 2024-02-21 00:00:00
end: 2025-02-18 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Binance","currency":"BTC_USDT"}]
*/
//@version=6
strategy("RSI 2 Strategy with Fixed Lines and Moving Average Filter", overlay=true)
// Input parameters
rsiPeriod = input.int(2, title="RSI Period", minval=1)
rsiBuyLevel = input.float(25, title="RSI Buy Level", minval=0, maxval=100)
maxBarsToHold = input.int(5, title="Max Candles to Hold", minval=1)
maPeriod = input.int(50, title="Moving Average Period", minval=1) // Moving Average Period
useMAFilter = input.bool(true, title="Use Moving Average Filter") // Enable/Disable MA Filter
// RSI and Moving Average calculation
rsi = ta.rsi(close, rsiPeriod)
ma = ta.sma(close, maPeriod)
// Moving Average filter conditions
maFilterCondition = useMAFilter ? close > ma : true // Condition: price above MA
// Buy conditions
rsiIncreasing = rsi > rsi[1] // Current RSI greater than previous RSI
buyCondition = rsi[1] < rsiBuyLevel and rsiIncreasing and strategy.position_size == 0 and maFilterCondition
// Variables for management
var int barsHeld = na // Counter for candles after purchase
var float buyPrice = na // Purchase price
// Buy action
if buyCondition and na(barsHeld)
strategy.entry("Buy", strategy.long)
barsHeld := 0
buyPrice := close
// Increment the candle counter after purchase
if not na(barsHeld)
barsHeld += 1
// Sell condition after the configured number of candles
sellCondition = barsHeld >= maxBarsToHold
if sellCondition
strategy.close("Buy")
// Reset variables after selling
barsHeld := na
buyPrice := na