该策略结合了简单移动平均线(SMA)、支撑阻力位和交易量增加这三个技术指标,构建了一个全面的交易策略。策略的主要思路是在价格突破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)