Estratégia avançada de negociação de quebra de padrões múltiplos

DOJI PIN BAR HAMMER BREAKOUT CANDLESTICK RSI
Data de criação: 2025-02-20 13:33:36 última modificação: 2025-02-20 13:33:36
cópia: 0 Cliques: 349
2
focar em
319
Seguidores

Estratégia avançada de negociação de quebra de padrões múltiplos Estratégia avançada de negociação de quebra de padrões múltiplos

Visão geral

A estratégia é um sistema de negociação avançado baseado em identificação de formas de múltiplas tecnologias, integrando a análise de formas de barras e princípios de negociação de ruptura. A estratégia é capaz de identificar e negociar várias formas clássicas de barras, incluindo a forma de estrela cruzada ((Doji), linha de maçã ((Hammer) e a forma de agulha P ((in Bar), ao mesmo tempo em que combina com o sistema de confirmação de binários para aumentar a confiabilidade do sinal de negociação.

Princípio da estratégia

A lógica central da estratégia baseia-se nos seguintes elementos-chave:

  1. Sistemas de reconhecimento de formas - Identificam, por meio de cálculos matemáticos precisos, três formas-chave do diagrama: a estrela-cruz, a linha de alfinete e a forma de agulha. Cada forma tem seus critérios de reconhecimento únicos, como a relação proporcional entre a entidade e a linha de sombra.
  2. Mecanismo de confirmação de ruptura - Um sistema de confirmação de dupla linha que requer que o segundo eixo rompa o ponto alto do eixo anterior (fazer mais) ou o ponto baixo (fazer menos) para reduzir o sinal falso.
  3. Determinação de preço de alvo - Usando um período de retrocesso ajustável (de 20 ciclos por defeito) para determinar o máximo ou o mínimo mais recente como preço de alvo, para que a estratégia seja dinamicamente adaptável.

Vantagens estratégicas

  1. Identificação de múltiplos formatos - aumenta significativamente as potenciais oportunidades de transação ao monitorar simultaneamente vários formatos de tecnologia.
  2. Mecanismo de confirmação de sinais - O sistema de confirmação de dupla barra reduz efetivamente o risco de sinais falsos.
  3. Visualizar os blocos de negociação - Use quadros coloridos para marcar os blocos de negociação, para tornar o objetivo de negociação mais intuitivo.
  4. Ajustamento flexível de parâmetros - os parâmetros como o período de retrocesso podem ser ajustados de acordo com diferentes condições de mercado.

Risco estratégico

  1. Risco de flutuação do mercado - Falso sinal de ruptura pode ocorrer durante a alta volatilidade.
  2. Risco de deslizamento - Em mercados com pouca liquidez, o preço de transação real pode estar muito distante do preço do sinal.
  3. Risco de reversão de tendência - em mercados de forte tendência, sinais de reversão podem causar grandes perdas.

Direção de otimização

  1. Introdução de confirmação de transação - Recomenda-se a inclusão de análise de transação no sistema de identificação de formas para aumentar a confiabilidade do sinal.
  2. Mecanismo de Stop Loss Dinâmico - O Stop Loss Dinâmico pode ser configurado com base no ATR ou na taxa de flutuação.
  3. Filtragem de cenário de mercado - Adicione um indicador de intensidade de tendência e filtre os sinais de reversão durante uma forte tendência.
  4. Optimização de quadros de tempo - Considere a confirmação de sinais em vários quadros de tempo.

Resumir

A estratégia estabelece um sistema de negociação completo, combinando análise de formações de múltiplas técnicas e princípios de negociação de ruptura. Sua vantagem reside na confirmação multidimensional do sinal e no ajuste flexível dos parâmetros, mas também requer atenção à volatilidade do mercado e ao risco de liquidez. A estabilidade e a confiabilidade da estratégia podem ser ainda melhoradas com a orientação de otimização recomendada.

Código-fonte da estratégia
/*backtest
start: 2024-02-21 00:00:00
end: 2025-02-18 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Binance","currency":"ETH_USDT"}]
*/

//@version=5
strategy("Target(Made by Karan)", overlay=true)

// Input for lookback period
lookbackPeriod = input.int(20, title="Lookback Period for Recent High/Low", minval=1)

// --- Pattern Identification Functions ---

// Identify Doji pattern
isDoji(open, high, low, close) =>
    bodySize = math.abs(close - open)
    rangeSize = high - low
    bodySize <= rangeSize * 0.1  // Small body compared to total range

// Identify Hammer pattern
isHammer(open, high, low, close) =>
    bodySize = math.abs(close - open)
    lowerShadow = open - low
    upperShadow = high - close
    bodySize <= (high - low) * 0.3 and lowerShadow > 2 * bodySize and upperShadow <= bodySize * 0.3  // Long lower shadow, small upper shadow

// Identify Pin Bar pattern
isPinBar(open, high, low, close) =>
    bodySize = math.abs(close - open)
    rangeSize = high - low
    upperShadow = high - math.max(open, close)
    lowerShadow = math.min(open, close) - low
    (upperShadow > bodySize * 2 and lowerShadow < bodySize) or (lowerShadow > bodySize * 2 and upperShadow < bodySize)  // Long shadow on one side

// --- Candle Breakout Logic ---

// Identify the first green candle (Bullish)
is_first_green_candle = close > open

// Identify the breakout above the high of the first green candle
breakout_green_candle = ta.crossover(close, high[1]) and is_first_green_candle[1]

// Identify the second green candle confirming the breakout
second_green_candle = close > open and breakout_green_candle[1]

// Find the recent high (for the target)
recent_high = ta.highest(high, lookbackPeriod)  // Use adjustable lookback period

// Plot the green rectangle box if the conditions are met and generate buy signal
var float start_price_green = na
var float end_price_green = na

if second_green_candle
    start_price_green := low[1]  // Low of the breakout green candle
    end_price_green := recent_high  // The most recent high in the lookback period
    strategy.entry("Buy", strategy.long)  // Buy signal

// --- Red Candle Logic ---

// Identify the first red candle (Bearish)
is_first_red_candle = close < open

// Identify the breakdown below the low of the first red candle
breakdown_red_candle = ta.crossunder(close, low[1]) and is_first_red_candle[1]

// Identify the second red candle confirming the breakdown
second_red_candle = close < open and breakdown_red_candle[1]

// Find the recent low (for the target)
recent_low = ta.lowest(low, lookbackPeriod)  // Use adjustable lookback period

// Plot the red rectangle box if the conditions are met and generate sell signal
var float start_price_red = na
var float end_price_red = na

if second_red_candle
    start_price_red := high[1]  // High of the breakout red candle
    end_price_red := recent_low  // The most recent low in the lookback period
    strategy.entry("Sell", strategy.short)  // Sell signal

// --- Pattern Breakout Logic for Doji, Hammer, Pin Bar ---

// Detect breakout of Doji, Hammer, or Pin Bar patterns
var float start_price_pattern = na
var float end_price_pattern = na

// Check for Doji breakout
if isDoji(open, high, low, close) and ta.crossover(close, high[1])
    start_price_pattern := low[1]  // Low of the breakout Doji
    end_price_pattern := recent_high  // The most recent high in the lookback period
    box.new(left = bar_index[1], right = bar_index, top = end_price_pattern, bottom = start_price_pattern, border_color = color.new(color.blue, 0), bgcolor = color.new(color.blue, 80))
    strategy.entry("Buy Doji", strategy.long)  // Buy signal for Doji breakout

// Check for Hammer breakout
if isHammer(open, high, low, close) and ta.crossover(close, high[1])
    start_price_pattern := low[1]  // Low of the breakout Hammer
    end_price_pattern := recent_high  // The most recent high in the lookback period
    box.new(left = bar_index[1], right = bar_index, top = end_price_pattern, bottom = start_price_pattern, border_color = color.new(color.blue, 0), bgcolor = color.new(color.blue, 80))
    strategy.entry("Buy Hammer", strategy.long)  // Buy signal for Hammer breakout

// Check for Pin Bar breakout
if isPinBar(open, high, low, close) and ta.crossover(close, high[1])
    start_price_pattern := low[1]  // Low of the breakout Pin Bar
    end_price_pattern := recent_high  // The most recent high in the lookback period
    box.new(left = bar_index[1], right = bar_index, top = end_price_pattern, bottom = start_price_pattern, border_color = color.new(color.blue, 0), bgcolor = color.new(color.blue, 80))
    strategy.entry("Buy Pin Bar", strategy.long)  // Buy signal for Pin Bar breakout

// Check for bearish Doji breakout
if isDoji(open, high, low, close) and ta.crossunder(close, low[1])
    start_price_pattern := high[1]  // High of the breakdown Doji
    end_price_pattern := recent_low  // The most recent low in the lookback period
    box.new(left = bar_index[1], right = bar_index, top = start_price_pattern, bottom = end_price_pattern, border_color = color.new(color.orange, 0), bgcolor = color.new(color.orange, 80))
    strategy.entry("Sell Doji", strategy.short)  // Sell signal for Doji breakdown

// Check for bearish Hammer breakout
if isHammer(open, high, low, close) and ta.crossunder(close, low[1])
    start_price_pattern := high[1]  // High of the breakdown Hammer
    end_price_pattern := recent_low  // The most recent low in the lookback period
    box.new(left = bar_index[1], right = bar_index, top = start_price_pattern, bottom = end_price_pattern, border_color = color.new(color.orange, 0), bgcolor = color.new(color.orange, 80))
    strategy.entry("Sell Hammer", strategy.short)  // Sell signal for Hammer breakdown

// Check for bearish Pin Bar breakout
if isPinBar(open, high, low, close) and ta.crossunder(close, low[1])
    start_price_pattern := high[1]  // High of the breakdown Pin Bar
    end_price_pattern := recent_low  // The most recent low in the lookback period
    box.new(left = bar_index[1], right = bar_index, top = start_price_pattern, bottom = end_price_pattern, border_color = color.new(color.orange, 0), bgcolor = color.new(color.orange, 80))
    strategy.entry("Sell Pin Bar", strategy.short)  // Sell signal for Pin Bar breakdown

// Optional: Plot shapes for the green sequence of candles
plotshape(series=is_first_green_candle, location=location.belowbar, color=color.green, style=shape.labelup, text="1st Green")
plotshape(series=breakout_green_candle, location=location.belowbar, color=color.blue, style=shape.labelup, text="Breakout")
plotshape(series=second_green_candle, location=location.belowbar, color=color.orange, style=shape.labelup, text="2nd Green")

// Optional: Plot shapes for the red sequence of candles
plotshape(series=is_first_red_candle, location=location.abovebar, color=color.red, style=shape.labeldown, text="1st Red")
plotshape(series=breakdown_red_candle, location=location.abovebar, color=color.blue, style=shape.labeldown, text="Breakdown")
plotshape(series=second_red_candle, location=location.abovebar, color=color.orange, style=shape.labeldown, text="2nd Red")