
你知道吗?这个”布林强盗”策略就像是市场里的狙击手!📈 它不是随便开枪的那种,而是专门瞄准布林带边缘的”越界分子”。当价格像调皮的孩子一样跑出布林带的”安全区域”时,这个策略就会立刻出手抓住反弹机会!
划重点!这个策略的精髓就是”逆向思维”: - 价格跌破下轨 = 超卖了,准备做多!🚀 - 价格冲破上轨 = 超买了,准备做空!📉 就像弹簧一样,压得越狠反弹越猛。布林带就是这个”弹簧”的可视化工具,20日均线是中轴,上下轨是极限位置。
这里最亮眼的设计是什么?分级止盈!不像传统策略”一刀切”,这个策略更像精明的商人: - TP1达到时,先落袋50%利润(3个点)💰 - 剩下50%继续持有,等TP2(5个点)🎯 - 如果行情不给力,还有5个点的止损保护🛡️
这就像卖现货,先卖一半回本,剩下的等更好价格!
避坑指南来了!📋 - 周期选择:20日是经典配置,但你可以根据交易品种调整 - 倍数设置:1.0倍标准差适合大多数情况,波动大的品种可以调到1.5-2.0 - 止盈止损:3/5/5的配置很保守,激进一点可以试试5/8/10
记住:这个策略最适合震荡行情,单边趋势中要小心被”假突破”坑!
如果你是那种喜欢”稳中求胜”的交易者,这个策略简直是为你量身定制的!它不会让你一夜暴富,但能帮你在市场的波动中稳定获利。就像开餐厅一样,不求每天爆满,但要保证每天都有稳定客流!
/*backtest
start: 2024-08-25 00:00:00
end: 2025-01-01 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"ETH_USDT"}]
*/
//@version=6
strategy("Bollinger Bandit + TP Escalonado", overlay=true)
// Configuración básica
length = input.int(20, "Periodo", minval=1)
mult = input.float(1.0, "Multiplicador", minval=0.1, maxval=3.0)
source = input(close, "Fuente")
// Opción para cierre en media
close_on_ma = input.bool(true, "Cierre en Media Móvil")
// SL/TP CONFIGURABLE CON NIVELES FIJOS
use_sltp = input.bool(true, "Usar SL/TP Personalizado", group="Gestión de Riesgo")
sl_points = input.int(5, "Puntos para SL", minval=1, group="Gestión de Riesgo")
tp1_points = input.int(3, "Puntos para TP1", minval=1, group="Gestión de Riesgo")
tp2_points = input.int(5, "Puntos para TP2", minval=1, group="Gestión de Riesgo")
// MOSTRAR TEXTO DE PRECIO
show_price_text = input.bool(true, "Mostrar Precio SL/TP", group="Visualización")
// Cálculo de las Bandas de Bollinger
basis = ta.sma(source, length)
dev = mult * ta.stdev(source, length)
upper = basis + dev
lower = basis - dev
// Detección de cruces
longCondition = ta.crossover(close, lower)
shortCondition = ta.crossunder(close, upper)
// Cálculo de SL/TP con niveles FIJOS EXACTOS - CORREGIDO
var float last_sl_price = na
var float last_tp1_price = na
var float last_tp2_price = na
var int last_entry_bar = 0
var float last_entry_price = na
var bool last_is_long = false
if longCondition or shortCondition
last_entry_price := close
last_is_long := longCondition
if longCondition
// COMPRA: SL = entrada - 5 puntos, TP1 = entrada + 3 puntos, TP2 = entrada + 5 puntos
last_sl_price := last_entry_price - sl_points
last_tp1_price := last_entry_price + tp1_points
last_tp2_price := last_entry_price + tp2_points
else
// VENTA: SL = entrada + 5 puntos, TP1 = entrada - 3 puntos, TP2 = entrada - 5 puntos
last_sl_price := last_entry_price + sl_points
last_tp1_price := last_entry_price - tp1_points
last_tp2_price := last_entry_price - tp2_points
last_entry_bar := bar_index
// Entradas
if (longCondition)
strategy.entry("Long", strategy.long)
if (shortCondition)
strategy.entry("Short", strategy.short)
// DETECCIÓN DE CIERRES CON TEXTO PERSONALIZADO
var bool long_closed_by_sl = false
var bool long_closed_by_tp1 = false
var bool long_closed_by_tp2 = false
var bool short_closed_by_sl = false
var bool short_closed_by_tp1 = false
var bool short_closed_by_tp2 = false
// Para posiciones LARGAS
if (use_sltp and strategy.position_size > 0)
if low <= last_sl_price
strategy.close("Long", comment="LongSL")
long_closed_by_sl := true
else if high >= last_tp1_price and not long_closed_by_tp1
strategy.close("Long", qty_percent=50, comment="LongTP1")
long_closed_by_tp1 := true
else if high >= last_tp2_price and not long_closed_by_tp2
strategy.close("Long", comment="LongTP2")
long_closed_by_tp2 := true
else if (strategy.position_size > 0)
if (ta.crossunder(close, upper))
strategy.close("Long", comment="STOP")
if (close_on_ma and ta.crossunder(close, basis))
strategy.close("Long", comment="STOPMedia")
// Para posiciones CORTAS
if (use_sltp and strategy.position_size < 0)
if high >= last_sl_price
strategy.close("Short", comment="ShortSL")
short_closed_by_sl := true
else if low <= last_tp1_price and not short_closed_by_tp1
strategy.close("Short", qty_percent=50, comment="ShortTP1")
short_closed_by_tp1 := true
else if low <= last_tp2_price and not short_closed_by_tp2
strategy.close("Short", comment="ShortTP2")
short_closed_by_tp2 := true
else if (strategy.position_size < 0)
if (ta.crossover(close, lower))
strategy.close("Short", comment="STOP")
if (close_on_ma and ta.crossover(close, basis))
strategy.close("Short", comment="STOPMedia")
// Reset flags cuando no hay posición
if strategy.position_size == 0
long_closed_by_sl := false
long_closed_by_tp1 := false
long_closed_by_tp2 := false
short_closed_by_sl := false
short_closed_by_tp1 := false
short_closed_by_tp2 := false
// Visualización (manteniendo tus colores y estilo)
plot(basis, "Media", color=color.blue, linewidth=1)
plot(upper, "Banda Superior", color=color.orange, linewidth=2)
plot(lower, "Banda Inferior", color=color.green, linewidth=2)
// Señales de entrada
plotshape(longCondition, "↑ Compra", shape.triangleup, location.belowbar, color=color.green, size=size.tiny)
plotshape(shortCondition, "↓ Venta", shape.triangledown, location.abovebar, color=color.red, size=size.tiny)
// Relleno entre bandas (manteniendo tu estilo)
bgcolor = color.new(color.yellow,80)
fill(plot(upper), plot(lower), bgcolor)