Estrategia de combinación de 123 puntos de inversión y de giro

El autor:¿ Qué pasa?, Fecha: 2024-01-16 15:48:44
Las etiquetas:

img

Resumen general

Esta estrategia combina la estrategia de patrón de inversión 123 y la estrategia de punto de giro para lograr una mayor tasa de ganancia. La estrategia de patrón de inversión 123 identifica puntos de inversión de tendencia, mientras que la estrategia de punto de giro determina los niveles clave de soporte y resistencia. Al combinar los dos, puede capturar tendencias al tiempo que identifica precios de entrada y salida específicos.

Estrategia lógica

123 Estrategia de reversión del patrón

Esta estrategia identifica los puntos de inversión de tendencia utilizando el indicador del Oscilador Estocástico. Se hace largo cuando el precio de cierre es superior al del cierre anterior durante 2 días consecutivos y el STO lento de 9 períodos es inferior a 50; se hace corto cuando el precio de cierre es inferior al del cierre anterior durante 2 días consecutivos y el STO rápido de 9 períodos es superior a 50.

Estrategia de punto de inflexión

Esta estrategia calcula 3 niveles de soporte y 3 niveles de resistencia basados en los precios altos, bajos y cerrados del día anterior. Punto de giro = (alto + bajo + cerrado) / 3 Apoyo 1 = 2Punto de giro Alto Resistencia 1 = 2Punto de pivote bajo Apoyo 2 = Punto de pivote (resistencia 1 soporte 1) Resistencia 2 = Punto de pivote + (Resistencia 1 Soporte 1) Apoyo 3 = Bajo 2*(Alto Punto de pivote) Resistencia 3 = Alto + 2*(Punto de pivote Bajo) Luego identifica la entrada y la salida en función de los niveles de soporte y resistencia.

Ventajas

  1. Combina los puntos fuertes de dos tipos diferentes de estrategias para lograr una mayor tasa de ganancia
  2. El patrón 123 identifica eficazmente las inversiones de tendencia a corto plazo
  3. Los puntos de pivote utilizan los niveles clave de S/R para filtrar las roturas falsas

Riesgos y cobertura

  1. El doble STO puede retrasarse y perder inversiones a corto plazo
  2. Los puntos de pivote no siempre pueden mantenerse, las rupturas pueden continuar
  3. Los parámetros pueden ajustarse o combinarse con otros indicadores para cubrir riesgos

Direcciones de optimización

  1. Impactos de ensayo de diferentes conjuntos de parámetros
  2. Combinar con otros indicadores/patrones para mejorar el rendimiento
  3. Incorporar el aprendizaje automático para optimizar dinámicamente los parámetros

Resumen de las actividades

Esta estrategia combina ingeniosamente la identificación de tendencias y los niveles clave de precios, lo que le permite detectar reversiones mientras utiliza S / R para filtrar las señales.


/*backtest
start: 2023-12-16 00:00:00
end: 2024-01-15 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 21/04/2021
// This is combo strategies for get a cumulative signal. 
//
// First strategy
// This System was created from the Book "How I Tripled My Money In The 
// Futures Market" by Ulf Jensen, Page 183. This is reverse type of strategies.
// The strategy buys at market, if close price is higher than the previous close 
// during 2 days and the meaning of 9-days Stochastic Slow Oscillator is lower than 50. 
// The strategy sells at market, if close price is lower than the previous close price 
// during 2 days and the meaning of 9-days Stochastic Fast Oscillator is higher than 50.
//
// Second strategy
// Pivot points simply took the high, low, and closing price from the previous period and 
// divided by 3 to find the pivot. From this pivot, traders would then base their 
// calculations for three support, and three resistance levels. The calculation for the most 
// basic flavor of pivot points, known as ‘floor-trader pivots’, along with their support and 
// resistance levels.
//
// WARNING:
// - For purpose educate only
// - This script to change bars colors.
////////////////////////////////////////////////////////////
Reversal123(Length, KSmoothing, DLength, Level) =>
    vFast = sma(stoch(close, high, low, Length), KSmoothing) 
    vSlow = sma(vFast, DLength)
    pos = 0.0
    pos := iff(close[2] < close[1] and close > close[1] and vFast < vSlow and vFast > Level, 1,
	         iff(close[2] > close[1] and close < close[1] and vFast > vSlow and vFast < Level, -1, nz(pos[1], 0))) 
	pos


PP2(res,SellFrom,BuyFrom) =>
    pos = 0.0
    xHigh  = security(syminfo.tickerid,res, high)
    xLow   = security(syminfo.tickerid,res, low)
    xClose = security(syminfo.tickerid,res, close)
    vPP = (xHigh+xLow+xClose) / 3
    vS1 = 2*vPP - xHigh 
    vR1 = 2*vPP-xLow
    vS2 = vPP - (vR1 - vS1)
    vR2 = vPP + (vR1 - vS1)
    vS3 = xLow - 2 * (xHigh - vPP)
    vR3 = xHigh + 2 * (vPP - xLow) 
    S =  iff(BuyFrom == "S1", vS1, 
          iff(BuyFrom == "S2", vS2,
           iff(BuyFrom == "S3", vS3,0)))
    B =  iff(SellFrom == "R1", vR1, 
          iff(SellFrom == "R2", vR2,
           iff(SellFrom == "R3", vR3,0)))
    pos := iff(close > B, 1,
             iff(close < S, -1, nz(pos[1], 0))) 
    pos

strategy(title="Combo Backtest 123 Reversal & Pivot Point V2)", shorttitle="Combo", overlay = true)
line1 = input(true, "---- 123 Reversal ----")
Length = input(14, minval=1)
KSmoothing = input(1, minval=1)
DLength = input(3, minval=1)
Level = input(50, minval=1)
//-------------------------
line2 = input(true, "---- Pivot Point V2 ----")
res = input(title="Resolution", type=input.resolution, defval="D")
SellFrom = input(title="Sell from ", defval="R1", options=["R1", "R2", "R3"])
BuyFrom = input(title="Buy from ", defval="S1", options=["S1", "S2", "S3"])
reverse = input(false, title="Trade reverse")
posReversal123 = Reversal123(Length, KSmoothing, DLength, Level)
posPP2 = PP2(res,SellFrom,BuyFrom)
pos = iff(posReversal123 == 1 and posPP2 == 1 , 1,
	   iff(posReversal123 == -1 and posPP2 == -1, -1, 0)) 
possig = iff(reverse and pos == 1, -1,
          iff(reverse and pos == -1 , 1, pos))	   
if (possig == 1 ) 
    strategy.entry("Long", strategy.long)
if (possig == -1 )
    strategy.entry("Short", strategy.short)	 
if (possig == 0) 
    strategy.close_all()
barcolor(possig == -1 ? #b50404: possig == 1 ? #079605 : #0536b3 )

Más.