
Это трейдинговая стратегия, основанная на принципе возврата средней стоимости по буринской полосе, которая позволяет получать прибыль в рассрочку с помощью нескольких уровней стоп-стоп. Стратегия совершает сделки, когда цена возвращается после прорыва буринской полосы, и устанавливает 5 различных уровней стоп-стоп для постепенного снижения позиций.
Стратегия основана на 20-циклическом индексе буринской полосы, используя в два раза больше стандартной разницы в качестве колебательного интервала. Когда цена прорывается снизу вниз и закрывается в полосе, вызывается многосигнал; когда цена прорывается сверху вверх и закрывается в полосе, вызывается пустой сигнал. После входа в игру, стратегия использует 5-ступенчатый механизм остановок, устанавливая остановки соответственно на 0,5%, 1%, 1,5%, 2% и 2,5%, причем каждая остановка сглаживает 20% позиции.
Стратегия использует множественные уровни стоп-стоп и динамических стоп-лосс для управления рисками. Преимущество стратегии заключается в ее гибком управлении позициями и механизме контроля риска, но при использовании следует обращать внимание на адаптацию к рыночной среде.
/*backtest
start: 2025-02-19 10:00:00
end: 2025-02-20 00:00:00
period: 5m
basePeriod: 5m
exchanges: [{"eid":"Binance","currency":"BNB_USDT"}]
*/
//@version=5
strategy("Bollinger Band Reentry Strategy", overlay=true)
// Inputs
bbLength = input.int(20, title="Bollinger Band Length")
bbMult = input.float(2.0, title="Bollinger Band Multiplier")
stopLossPerc = input.float(1.0, title="Stop Loss (%)") / 100
tp1Perc = input.float(0.5, title="Take Profit 1 (%)") / 100
tp2Perc = input.float(1.0, title="Take Profit 2 (%)") / 100
tp3Perc = input.float(1.5, title="Take Profit 3 (%)") / 100
tp4Perc = input.float(2.0, title="Take Profit 4 (%)") / 100
tp5Perc = input.float(2.5, title="Take Profit 5 (%)") / 100
allowAddToPosition = input.bool(true, title="Allow Adding to Position")
customSession = input.timeframe("0930-1600", title="Custom Trading Session")
// Calculate Bollinger Bands
basis = ta.sma(close, bbLength)
dev = ta.stdev(close, bbLength)
upperBB = basis + bbMult * dev
lowerBB = basis - bbMult * dev
// Plot Bollinger Bands
plot(upperBB, color=color.red, title="Upper Bollinger Band")
plot(lowerBB, color=color.green, title="Lower Bollinger Band")
plot(basis, color=color.blue, title="Bollinger Band Basis")
// Entry Conditions
longCondition = (ta.crossover(close, lowerBB) or (low < lowerBB and close > lowerBB)) and time(timeframe.period, customSession)
shortCondition = (ta.crossunder(close, upperBB) or (high > upperBB and close < upperBB)) and time(timeframe.period, customSession)
// Execute Trades
if (longCondition)
strategy.entry("Long", strategy.long, when=allowAddToPosition or strategy.position_size == 0)
if (shortCondition)
strategy.entry("Short", strategy.short, when=allowAddToPosition or strategy.position_size == 0)
// Take-Profit and Stop-Loss Levels for Long Trades
if (strategy.position_size > 0)
strategy.exit("TP1", "Long", limit=strategy.position_avg_price * (1 + tp1Perc), qty=strategy.position_size * 0.2) // Take 20% profit
strategy.exit("TP2", "Long", limit=strategy.position_avg_price * (1 + tp2Perc), qty=strategy.position_size * 0.2)
strategy.exit("TP3", "Long", limit=strategy.position_avg_price * (1 + tp3Perc), qty=strategy.position_size * 0.2)
strategy.exit("TP4", "Long", limit=strategy.position_avg_price * (1 + tp4Perc), qty=strategy.position_size * 0.2)
strategy.exit("TP5", "Long", limit=upperBB, qty=strategy.position_size * 0.2) // Take final 20% at opposite band
strategy.exit("Stop Loss", "Long", stop=strategy.position_avg_price * (1 - stopLossPerc))
// Take-Profit and Stop-Loss Levels for Short Trades
if (strategy.position_size < 0)
strategy.exit("TP1", "Short", limit=strategy.position_avg_price * (1 - tp1Perc), qty=strategy.position_size * 0.2)
strategy.exit("TP2", "Short", limit=strategy.position_avg_price * (1 - tp2Perc), qty=strategy.position_size * 0.2)
strategy.exit("TP3", "Short", limit=strategy.position_avg_price * (1 - tp3Perc), qty=strategy.position_size * 0.2)
strategy.exit("TP4", "Short", limit=strategy.position_avg_price * (1 - tp4Perc), qty=strategy.position_size * 0.2)
strategy.exit("TP5", "Short", limit=lowerBB, qty=strategy.position_size * 0.2)
strategy.exit("Stop Loss", "Short", stop=strategy.position_avg_price * (1 + stopLossPerc))
// Alerts
alertcondition(longCondition, title="Long Signal", message="Price closed inside Bollinger Band from below.")
alertcondition(shortCondition, title="Short Signal", message="Price closed inside Bollinger Band from above.")