Super BitMoon estrategia de negociación de impulso cuantitativo

El autor:¿ Qué pasa?, Fecha: 15 de septiembre de 2023 16:13:05
Las etiquetas:

Esta estrategia se llama Super BitMoon. Es una estrategia de comercio de impulso cuantitativo a corto plazo adecuada para Bitcoin. La estrategia tiene capacidades largas y cortas, lo que le permite operar cuando Bitcoin rompe los niveles clave de soporte o resistencia.

Cómo funciona la estrategia:

  1. Utilice el indicador ATR para calcular el rango de volatilidad reciente y los niveles de stop loss.
  2. Utilice el promedio móvil ponderado (WVF) y las bandas de Bollinger para determinar si Bitcoin está sobrecomprado o sobrevendido.
  3. Si el RSI está por debajo de dos líneas de sobreventa, presenta una oportunidad para comprar la caída.

Reglas específicas de comercio:

  1. Si WVF cruza por debajo de la banda superior de Bollinger, y el precio está por encima del nivel de stop loss ATR, compra Bitcoin.
  2. Si el RSI cae por debajo de 50 o 30 líneas de sobreventa, corta Bitcoin.

Ventajas de esta estrategia:

  1. Tiene capacidades tanto largas como cortas para el comercio bidireccional.
  2. Utiliza paradas ATR para controlar el riesgo y limitar las pérdidas.
  3. Utiliza WVF, Bandas de Bollinger y RSI juntos para mejorar la precisión de la señal.

Riesgos de esta estrategia:

  1. Los parámetros incorrectos de Bollinger y RSI pueden generar malas señales.
  2. Los picos o caídas repentinos de precios pueden desencadenar un stop loss.
  3. Los costes de transacción afectan a la rentabilidad.

En resumen, Super BitMoon es una sólida estrategia de impulso cuantitativo ideal para el comercio de combinaciones de indicadores a corto plazo, con características de tendencia y reversión media.


/*backtest
start: 2023-09-07 00:00:00
end: 2023-09-08 09:00:00
period: 5m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
strategy("Super BitMoon v1", overlay=false, commission_value = 0.25, default_qty_type=strategy.percent_of_equity, default_qty_value = 100)

/////////////////////////////////////////////////////////////
//START - SET DATE RANGE

// === BACKTEST RANGE ===
FromMonth = input(defval = 1, title = "From Month", minval = 1)
FromDay   = input(defval = 1, title = "From Day", minval = 1)
FromYear  = input(defval = 2011, title = "From Year")
ToMonth   = input(defval = 12, title = "To Month", minval = 1)
ToDay     = input(defval = 31, title = "To Day", minval = 1)
ToYear    = input(defval = 2018, title = "To Year")

startDate = time > timestamp(FromYear, FromMonth, FromDay, 00, 00)
endDate = time < timestamp(ToYear, ToMonth, ToDay, 23, 59)
withinTimeRange = true

/////////////////////////////////////////////////////////////
//END - SET DATE RANGE



/////////////////////////////////////////////////////////////
//START - INDICATORS

//ATR STOPS TREND FILTER
length = input(5, title="ATR Stop's Length")
mult = input(1, minval=0.01, title="ATR Stop's Multiple")
atr_ = atr(length)
max1 = max(nz(max_[1]), close)
min1 = min(nz(min_[1]), close)
is_uptrend_prev = nz(is_uptrend[1], true)
stop = is_uptrend_prev ? max1 - mult * atr_ : min1 + mult * atr_
vstop_prev = nz(vstop[1])
vstop1 = is_uptrend_prev ? max(vstop_prev, stop) : min(vstop_prev, stop)
is_uptrend = close - vstop1 >= 0
is_trend_changed = is_uptrend != is_uptrend_prev
max_ = is_trend_changed ? close : max1
min_ = is_trend_changed ? close : min1
vstop = is_trend_changed ? is_uptrend ? max_ - mult * atr_ : min_ + mult * atr_ : vstop1

//SYNTHETIC VIX
pd = input(10, title="Synthetic VIX's Length")
bbl = input(2, title="Synthetic VIX's Bollinger Band's Length")
mult2 = input(0.01, minval=0.01, title="Synthetic VIX's Bollinger Band's Std Dev")
wvf = ((highest(close, pd)-low)/(highest(close, pd)))*100
sDev = mult2 * stdev(wvf, bbl)
midLine = sma(wvf, bbl)
upperBand = midLine + sDev

//RSI
rsi = rsi(close, input(10,title="RSI's Length"))
os1 = input(50,title="RSI's Oversold Level 1")
os2 = input(50,title="RSI's Oversold Level 2")

/////////////////////////////////////////////////////////////
//END - INDICATORS



/////////////////////////////////////////////////////////////
//START - TRADING RULES
direction = input(defval=1, title = "Strategy Direction", minval=-1, maxval=1)
strategy.risk.allow_entry_in(direction == 0 ? strategy.direction.all : (direction < 0 ? strategy.direction.short : strategy.direction.long))

condition1 = crossunder(wvf, upperBand) and close > vstop and withinTimeRange
condition2 = crossunder(rsi, os1) and withinTimeRange
condition3 = crossunder(rsi, os2) and withinTimeRange

strategy.entry("BUY", strategy.long, when = condition1)
strategy.entry("SELL", strategy.short, when = condition2 or condition3)

/////////////////////////////////////////////////////////////
//END - TRADING RULES

Más.