
この戦略は,単純移動平均 ((SMA),サポートレジスタンスレベル,取引量増加の3つの技術指標を組み合わせて,総合的な取引戦略を構築する.戦略の主な考え方は,価格がSMA平均線を突破し,サポートレジスタンスレベルを突破し,取引量の拡大に伴い取引を行うことであり,同時に,リスクを制御するために停止条件を設定する.
この戦略は,SMA平均線,サポートレジスタンスと取引量指標を組み合わせて,包括的な取引戦略を構築する.戦略の優点は,トレンドの機会を捕捉し,取引リスクを制御することにある.しかしながら,戦略には,市場の極端な状況への適応能力の改善のような一定の限界があります.将来,他の技術指標の導入,サポートレジスタンス計算方法の最適化,取引量指標の平滑化,および停止損失の最適化などの条件によって戦略の改善が可能で,その安定性と収益性を向上させることができる.
/*backtest
start: 2023-06-08 00:00:00
end: 2024-06-13 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
strategy("Advanced Entry Conditions with Support/Resistance, SMA, and Volume", overlay=true)
// Inputs
length = input(20, title="SMA Length")
stopLossPerc = input(1, title="Stop Loss Percentage", type=input.float) / 100
leftBars = input(15, title="Left Bars")
rightBars = input(15, title="Right Bars")
distanceThresh = input(1, title="Distance Threshold from Support/Resistance", type=input.float) / 100
// Calculations
smaValue = sma(close, length)
highUsePivot = fixnan(pivothigh(leftBars, rightBars)[1])
lowUsePivot = fixnan(pivotlow(leftBars, rightBars)[1])
// Volume Calculation
volumeIncrease = volume > volume[1]
// Entry Conditions
longEntryCondition = close[0] > close[1] and close[1] > smaValue and close[0] > smaValue and close[0] > lowUsePivot and close[1] > lowUsePivot and abs(close[0] - highUsePivot) > distanceThresh and volumeIncrease
shortEntryCondition = close[0] < close[1] and close[1] < smaValue and close[0] < smaValue and close[0] < lowUsePivot and close[1] < lowUsePivot and abs(close[0] - highUsePivot) > distanceThresh and volumeIncrease
// Calculate stop loss levels
longStopLoss = close * (1 - stopLossPerc)
shortStopLoss = close * (1 + stopLossPerc)
// Strategy Logic
strategy.entry("Long", strategy.long, when=longEntryCondition)
strategy.exit("Exit Long", "Long", stop=longStopLoss)
strategy.entry("Short", strategy.short, when=shortEntryCondition)
strategy.exit("Exit Short", "Short", stop=shortStopLoss)
// Plotting
plot(smaValue, color=color.blue, title="SMA")
plot(highUsePivot, color=color.red, linewidth=2, title="Resistance")
plot(lowUsePivot, color=color.green, linewidth=2, title="Support")
plotshape(series=longEntryCondition, location=location.belowbar, color=color.green, style=shape.labelup, title="Long Entry")
plotshape(series=shortEntryCondition, location=location.abovebar, color=color.red, style=shape.labeldown, title="Short Entry")
// Background Color
bgcolor(longEntryCondition ? color.new(color.green, 90) : shortEntryCondition ? color.new(color.red, 90) : na)