Sigue la estrategia del oso

El autor:¿ Qué pasa?, Fecha: 2024-02-26 14:12:09
Las etiquetas:

img

Resumen general

La estrategia Follow The Bear (FTB) es una estrategia de negociación de divisas diseñada para capturar un patrón recurrente en la acción del precio del EUR/USD durante el mercado europeo abierto. La estrategia tiene como objetivo aprovechar a los toros del euro atrapados que se ven obligados a relajar sus posiciones largas a medida que el precio comienza a retroceder. Específicamente, vigila las estrellas fugaces o las velas de inversión de martillo en el gráfico de 1 hora del EUR/USD. Una vez detectada y confirmada con filtros adicionales como un RSI sobrecomprado, entrará agresivamente en posiciones cortas con un alto firme por encima de la vela de inversión y un objetivo de ganancia basado en una relación riesgo / recompensa razonable.

Estrategia lógica

La premisa central de la estrategia de FTB se basa en la suposición de que los alcistas del euro y los algoritmos que empujan el precio del EUR/USD hacia arriba quedarán atrapados cuando la tendencia alcista se detenga o se invierta poco después de que el mercado europeo/londrino se abra.

La estrategia tiene como objetivo capitalizar esta teoría bajista observando los patrones de velas de inversión durante la zona horaria europea (por ejemplo, 2am-7am).

Cuando se forma una vela de este tipo, indica que las operaciones en la trampa se enfrentan a la liquidación.

  1. Indicador de volatilidad superior al nivel de sobrecompra de 70
  2. Candela anterior cerrada
  3. La vela actual ha hecho un nuevo máximo reciente

Al pasar todos los filtros, la estrategia entra en posiciones cortas en el cierre de la vela con un stop loss situado justo por encima del máximo y un objetivo de ganancia calculado en función de una relación riesgo/recompensación de 1: 1 (configurable).

Un detalle clave es que la estrategia solo opera durante la sesión europea.

Análisis de ventajas

Como estrategia sencilla de inversión de la media a corto plazo, el enfoque de la FTB tiene varias fortalezas clave:

  1. Captura un patrón de comportamiento negociable con una buena tasa de ganancia
  2. Lógica fácil de entender y optimizar
  3. Evita el ruido diurno al operar durante la noche
  4. Normas de gestión de riesgos bien definidas
  5. Conectividad perfecta para el comercio automático

En general, como estrategia de scalping nocturno de baja frecuencia, la estabilidad y fiabilidad de FTB es bastante atractiva.

Análisis de riesgos

Si bien la estrategia tiene méritos, como con cualquier sistema de negociación, existen riesgos que incluyen:

  1. Diferencias y diferencias más amplias durante la noche
  2. La simplicidad podría llevar a una optimización excesiva
  3. Incumplimiento de la exactitud del patrón en determinados mercados
  4. Viabilidad limitada de los datos históricos
  5. Limitaciones de las pruebas de retroceso

Algunas maneras de abordar los riesgos:

  1. Ajustar el amortiguador de pérdida de parada
  2. Añadir filtros y combinar estrategias
  3. Optimizar la robustez en todas las condiciones del mercado
  4. Utilice un período de prueba posterior más largo
  5. Pruebas a futuro extensas antes de la negociación en vivo

Pistas de optimización

Dado el carácter básico de la estrategia y los riesgos que conlleva, algunos ámbitos a considerar para mejorar:

  1. Cuadro de tiempo múltiple confirmación de señales en 5m o 15m para la robustez
  2. Aprendizaje automático modelo de tren para la pantalla de señales
  3. Paradas dinámicas ajustar las paradas en función de la volatilidad
  4. Aplanamiento del riesgo optimizar el tamaño de la posición para un crecimiento más estable

Conclusión

La estrategia Follow the Bear proporciona un enfoque sencillo para la venta corta a corto plazo mediante la capitalización de los retracements impulsados por los toros del euro atrapados.


/*backtest
start: 2024-02-18 00:00:00
end: 2024-02-25 00:00:00
period: 3h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ZenAndTheArtOfTrading / PineScriptMastery
// FTB Strategy (PineConnector Version)
// Last Updated: 21st July, 2021
// @version=4
strategy("[2021] FTB Strategy", shorttitle="FTB", overlay=true)

// Risk Settings
var g_risk      = "Risk Settings"
pips            = input(title="Stop Pips", type=input.float, defval=2.0, group=g_risk, tooltip="How many pips above high to put stop loss")
rr              = input(title="Risk:Reward", type=input.float, defval=1.0, group=g_risk, tooltip="This determines the risk:reward profile of the setup")
// Filters
var g_filter    = "Filter Settings"
timezone        = input(title="Timezone", type=input.session, defval="0200-0700", group=g_filter, tooltip="Which timezone to search for FTB signals in")
days            = input(title="Days To Trade", defval="13457", group=g_filter, tooltip="Which days to trade this strategy on (Monday & Friday disabled by default)")
useRsiFilter    = input(title="RSI OB/OS?", type=input.bool, defval=true, group=g_filter, tooltip="If true then the RSI must be considered overbought before a signal is valid")
useCloseFilter  = input(title="Previous Bar Must Be Bullish?", type=input.bool, defval=false, group=g_filter, tooltip="If true then the previous bar must have closed bullish")
useHighFilter   = input(title="High Filter", type=input.bool, defval=false, group=g_filter, tooltip="If true then the signal bar must be the highest bar over X bars")
highLookback    = input(title="High Lookback", type=input.integer, defval=10, group=g_filter, tooltip="This is for setting the High Filter lookback distance")
fib             = input(title="Candle Close %", defval=0.5, group=g_filter, tooltip="For identifying shooting star candles (0.5 = must close <= 50% mark of candle size)")
rsiLen          = input(title="RSI Length", type=input.integer, defval=3, group=g_filter, tooltip="RSI length")
rsiOB           = input(title="RSI OB", type=input.float, defval=70.0, group=g_filter, tooltip="RSI overbought threshold")
// PineConnector Settings
var g_pc        = "PineConnector Settings"
pc_id           = input(title="License ID", defval="YOUR_ID", type=input.string, group=g_pc, tooltip="This is your PineConnector license ID")
pc_risk         = input(title="Risk Per Trade", defval=1, step=0.5, type=input.float, group=g_pc, tooltip="This is how much to risk per trade (% of balance or lots)")
pc_prefix       = input(title="MetaTrader Prefix", defval="", type=input.string, group=g_pc, tooltip="This is your broker's MetaTrader symbol prefix")
pc_suffix       = input(title="MetaTrader Suffix", defval="", type=input.string, group=g_pc, tooltip="This is your broker's MetaTrader symbol suffix")
pc_spread       = input(title="Spread", defval=0.5, type=input.float, group=g_pc, tooltip="Enter your average spread for this pair (used for offsetting limit order)")
pc_limit        = input(title="Use Limit Order?", defval=true, type=input.bool, group=g_pc, tooltip="If true a limit order will be used, if false a market order will be used")

// Generate PineConnector alert string
var symbol = pc_prefix + syminfo.ticker + pc_suffix
var limit = pc_limit ? "limit" : ""
pc_entry_alert(direction, sl, tp) =>
    price = pc_limit ? "price=" + tostring(pc_spread) + "," : ""
    pc_id + "," + direction + limit + "," + symbol + "," + price + "sl=" + tostring(sl) + ",tp=" + tostring(tp) + ",risk=" + tostring(pc_risk)

// Get RSI filter
rsiValue = rsi(close, rsiLen)
rsiFilter = not useRsiFilter or rsiValue >= rsiOB

// Check high & close filter
highFilter = not useHighFilter or high == highest(high, highLookback)
closeFilter = not useCloseFilter or close[1] > open[1]

// InSession() determines if a price bar falls inside the specified session
inSession(sess) => na(time(timeframe.period, sess + ":" + days)) == false

// Calculate 50% mark of candle size
bearFib = (high - low) * fib + low

// Check filters
filters = inSession(timezone) and closeFilter and high > high[1] and rsiFilter and highFilter and open != close

// Detect valid shooting star pinbar pattern
var takenTradeAlready = false
star = true

// Calculate stops & targets
shortStopPrice = high + (syminfo.mintick * pips * 10)
shortStopDistance = shortStopPrice - close
shortTargetPrice = close - (shortStopDistance * rr)

// Save stops & targets for the current trade
var tradeStopPrice = 0.0
var tradeTargetPrice = 0.0

// If we detect a valid shooting star, save our stops & targets, enter short and generate alert
if star and barstate.isconfirmed
    tradeStopPrice := shortStopPrice
    tradeTargetPrice := shortTargetPrice
    takenTradeAlready := true
    alertString = pc_entry_alert("sell", tradeStopPrice, tradeTargetPrice)
    alert(alertString, alert.freq_once_per_bar_close)
    strategy.entry(id="Short", long=strategy.short, when=strategy.position_size == 0, comment=alertString)

// If we have exited the FTB session then reset our takenTradeAlready flag for the next session
if not inSession(timezone) and inSession(timezone)[1]
    takenTradeAlready := false
    
// If price has exceeded target then cancel limit order if it's still active
if pc_limit and low <= tradeTargetPrice and strategy.position_size == 0
    alert(pc_id + ",cancelshort," + symbol)
    tradeTargetPrice := na

// Draw stops & targets
plot(star ? tradeStopPrice : na, color=color.red, style=plot.style_linebr, title="SL")
plot(star ? shortTargetPrice : na, color=color.green, style=plot.style_linebr, title="TP")
// Draw short signals
plotshape(star ? 1 : na, style=shape.triangledown, color=color.red)
// Change background color to highlight detection zone
bgcolor(color=inSession(timezone) ? color.new(color.red,80) : na, title="Session")

// Exit trade whenever our stop or target is hit
strategy.exit(id="Short Exit", from_entry="Short", limit=tradeTargetPrice, stop=tradeStopPrice, when=strategy.position_size != 0)

Más.