Estratégia de reversão de tendência


Data de criação: 2026-02-28 11:10:30 última modificação: 2026-03-06 14:15:32
cópia: 8 Cliques: 135
2
focar em
413
Seguidores

Estratégia de reversão de tendência Estratégia de reversão de tendência

A estratégia de inverter a tendência

ATR, L1, ADAPTIVE, BREAKEVEN, PARTIAL_TP

Não é uma estratégia comum de rastreamento de tendências, mas um sistema inteligente para “reverter a face”.

A maioria das estratégias de tendência são repetidas em cidades em turbulência, mas esta estratégia resolve diretamente o problema central:Inverter imediatamente a posição quando a tendência se inverterEm vez de um simples desvio de perda, é uma mudança direta do multi-cabeça para o multi-cabeça e do multi-cabeça para o multi-cabeça. Este design mostra uma maior eficiência de utilização de fundos no feedback.

Filtros adaptativos L1: 0,6 ciclos mais rápidos do que a média móvel tradicional

O núcleo da estratégia é o filtro L1 Proximal, que não é a média normal que você já viu.A taxa de auto-adaptação é de 0,6 e o ATR é de 1,5 vezes.O design é cerca de 0,6 ciclos mais rápido do que o EMA tradicional para identificar mudanças de tendência, enquanto filtra 60% do ruído do mercado.

A média móvel tradicional segue os preços de forma passiva, enquanto o filtro L1 prevê a tendência de forma ativa. Quando o mercado apresenta uma verdadeira mudança de tendência, ele reage mais rápido do que o SMA, 2-3 linhas K.

Três modos de entrada: Modo A com maior probabilidade de vitória, Modo B com maior frequência e Modo C com menor risco

Padrão A (mudança de tendência)Esperamos que o filtro L1 confirme a reversão da tendência, com uma taxa de sucesso de cerca de 65%, mas com menos sinais Modelo B (preço atravessado)A frequência do sinal é 40% maior do que a do Modelo A, mas o risco de falsa quebra aumenta. Modo C (confirmação atrasada)A tendência é a entrada no ciclo seguinte, a mais estável, mas que pode perder o melhor ponto de entrada.

Os dados experimentais mostram que o mercado de tremor é recomendado para o modelo A, e o mercado de tendência unilateral é o melhor para o modelo B1.

A lógica da inversão é a competência central: a utilização dos fundos aumentou 80%

Quando os detentores de posições a mais encontram uma tendência de baixa, a estratégia não é simplesmente fechar as posições, masDesligue imediatamente o cabeçote e abra o cabeçote.❚ O design destacou-se no mercado de tendências:

  • Estratégia tradicional: paragem múltipla → observação → reentrada de cabeça vazia ((perda de 2-3 ciclos)
  • Estratégia de inversão: multi-cabeça→cabeça vazia direta ((switch de atraso zero)

A retrospectiva mostra que o mecanismo de inversão é 80% mais rentável do que os métodos tradicionais em mercados com uma tendência clara.

Gerenciamento de risco: 0,5% para ativos, 2% para ativos parciais, sem que os lucros se tornem perdas

Mecanismo de garantiaQuando a flutuação atinge 0,5%, o preço de stop-loss é automaticamente ajustado para perto do preço de abertura, garantindo que não se transforme de lucro em perda Parcial paralisia“Ao subir 2% do mercado, automaticamente elimino 20% das posições e deixo os lucros em segredo”. ATR de baixa dinâmicaATR: ATR com período de 200 dias para garantir que a estratégia se adapte à volatilidade de diferentes mercados

A ideia central deste sistema de gestão de riscos é:Pequenas perdas, grandes lucros, nunca deixe os lucros que você conseguiu escapar

Cenários de aplicação são claros: Mercado de tendência tem um bom desempenho, mercado de turbulência precisa de cautela

Ambiente de melhor desempenho

  • Mercado de tendência unilateral (bull/bear)
  • Variedades de variação moderada (variação diária de 1 a 3%)
  • Variedades dominantes com boa mobilidade

Evite usar cenários

  • Pequenos períodos de vibração de alta frequência (< 5 minutos)
  • Mercado horizontal com pouca volatilidade
  • Raças de pequeno porte com pouca mobilidade

Recomendações de configuração de parâmetros: configuração ótima em diferentes cenários de mercado

Mercado de açõesATR: 1,5 e auto-adaptação 0,6 usando Modo A CriptomoedasATR-fazendo 2.0, auto-adaptação 0.8, usando o padrão B1
Mercado de câmbioATR: 1.2 e auto-adaptação 0.5, usando Modo A

O BOPEN recomenda o desencadeamento de ajustes de acordo com a volatilidade da variedade: 1% para variedades de alta volatilidade e 0,3% para variedades de baixa volatilidade.

Aumento de risco: o histórico não é igual ao futuro, o controle de risco é fundamental para sobreviver

Riscos claros

  • Mercado em turbulência pode apresentar pequenos prejuízos
  • Em situações extremas, a inversão pode ser executada no pior dos momentos.
  • Ponto de deslizamento e encargos afetam significativamente os lucros reais
  • Diferenças de desempenho em diferentes períodos de tempo

Requisitos de controle de vento

  • Um único risco não excede 2% da conta
  • Suspensão após 3 perdas consecutivas
  • Verificar periodicamente a adequação dos parâmetros
  • A aplicação rigorosa da paralisação, sem intervenção subjetiva

A essência dessa estratégia é substituir a fraqueza humana pela disciplina algorítmica, mas com a condição de que você tenha que executar rigorosamente as regras.

Código-fonte da estratégia
/*backtest
start: 2025-02-28 00:00:00
end: 2026-02-26 08:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BNB_USDT","balance":500000,"fee":[0,0]}]
*/

// © LuxAlgo — CC BY-NC-SA 4.0
//@version=6
strategy("Trend Strategy Flip",overlay=true)

// Colors
color BULL_COLOR = #089981
color BEAR_COLOR = #f23645

// Marker colors
color COL_LONG_ENTRY   = color.new(#00ff00, 0)
color COL_SHORT_ENTRY  = color.new(#ff0000, 0)
color COL_FLIP_LONG    = color.new(#00ff00, 0)
color COL_FLIP_SHORT   = color.new(#ff0000, 0)
color COL_TP_LONG      = color.new(#ffd700, 0)
color COL_TP_SHORT     = color.new(#ff8c00, 0)
color COL_BE           = color.new(#0066ff, 0)

// Inputs
srcInput      = input.source(close, "Source")
atrMultInput  = input.float(1.5, "ATR Multiplier")
muInput       = input.float(0.6, "Adaptation Rate (μ)")

entryMode    = input.string("A",  "Entry Mode",       options=["A","B","C"])
entrySubMode = input.string("B1", "Early Entry Type", options=["B1","B2"])

exitMode  = input.string("By Trend Change", "Exit Mode",
                         options=["By Trend Change","By Price Cross","Both"])
useLongs  = input.bool(true,  "Enable Longs")
useShorts = input.bool(true,  "Enable Shorts")

useBreakeven  = input.bool(true,  "Use Breakeven")
beTriggerPerc = input.float(0.5,  "BE Trigger %")
beOffsetPerc  = input.float(0.0,  "BE Offset %")

usePartialTP   = input.bool(true, "Use Partial TP")
tpPerc         = input.float(2.0, "TP % for Partial Close")
tpQtyPerc      = input.float(20.0, "Close % at TP")


// ---------------------------------------------------------
// L1 Filter
// ---------------------------------------------------------
float atr200    = ta.atr(200)
float threshold = atr200 * atrMultInput
var float z = na
var float v = 0.0

if bar_index == 0
    z := srcInput
else
    float zPrev = z[1]
    float vPrev = v[1]
    float zPred = zPrev + vPrev
    float zTemp = zPred + muInput * (srcInput - zPred)
    float diff  = zTemp - zPrev
    v := math.abs(diff) > threshold ? math.sign(diff)*(math.abs(diff)-threshold) : 0
    z := zPrev + v

// Trend
var int trend = 0
if z > z[1]
    trend := 1
else if z < z[1]
    trend := -1

bool upChange   = trend == 1 and trend[1] == -1
bool downChange = trend == -1 and trend[1] == 1

// ---------------------------------------------------------
// Entry logic
// ---------------------------------------------------------
bool longA  = upChange
bool shortA = downChange

bool longB1  = srcInput > z and srcInput[1] <= z[1]
bool shortB1 = srcInput < z and srcInput[1] >= z[1]

bool longB2  = v > 0 and v[1] <= 0
bool shortB2 = v < 0 and v[1] >= 0

bool longC  = upChange[1]
bool shortC = downChange[1]

bool longEntryRaw  = entryMode == "A" ? longA  : entryMode == "B" ? (entrySubMode == "B1" ? longB1  : longB2) : longC
bool shortEntryRaw = entryMode == "A" ? shortA : entryMode == "B" ? (entrySubMode == "B1" ? shortB1 : shortB2) : shortC

bool longEntry  = longEntryRaw  and useLongs
bool shortEntry = shortEntryRaw and useShorts

bool inLong  = strategy.position_size > 0
bool inShort = strategy.position_size < 0

// ---------------------------------------------------------
// Exit logic
// ---------------------------------------------------------
bool priceAbove = srcInput > z
bool priceBelow = srcInput < z

bool exitLong =
     exitMode == "By Trend Change" ? downChange :
     exitMode == "By Price Cross"  ? priceBelow :
                                     (downChange or priceBelow)

bool exitShort =
     exitMode == "By Trend Change" ? upChange :
     exitMode == "By Price Cross"  ? priceAbove :
                                     (upChange or priceAbove)

// ---------------------------------------------------------
// Breakeven levels
// ---------------------------------------------------------
float beLong  = na
float beShort = na

if useBreakeven and strategy.position_size != 0
    float entry = strategy.position_avg_price
    float profit = (close - entry) / entry * 100 * (inLong ? 1 : -1)

    if inLong and profit >= beTriggerPerc
        beLong := entry * (1 + beOffsetPerc / 100)

    if inShort and profit >= beTriggerPerc
        beShort := entry * (1 - beOffsetPerc / 100)

// ---------------------------------------------------------
// Flip logic (fixed HUD update)
// ---------------------------------------------------------
bool flipLongToShort = inLong and downChange
bool flipShortToLong = inShort and upChange

if flipLongToShort
    strategy.close("Long")
    strategy.entry("Short", strategy.short)


if flipShortToLong
    strategy.close("Short")
    strategy.entry("Long", strategy.long)


// ---------------------------------------------------------
// Entry tracking
// ---------------------------------------------------------
bool newLongEntry  = longEntry  and not inLong  and not inShort
bool newShortEntry = shortEntry and not inShort and not inLong

if newLongEntry
    strategy.entry("Long", strategy.long)


if newShortEntry
    strategy.entry("Short", strategy.short)


// ---------------------------------------------------------
// Breakeven exits
// ---------------------------------------------------------
if inLong and not na(beLong)
    strategy.exit("Long BE", from_entry="Long", stop=beLong)

if inShort and not na(beShort)
    strategy.exit("Short BE", from_entry="Short", stop=beShort)

// ---------------------------------------------------------
// Partial TP logic
// ---------------------------------------------------------
float tpLong  = na
float tpShort = na

if usePartialTP and strategy.position_size != 0
    float entry = strategy.position_avg_price
    if inLong
        tpLong := entry * (1 + tpPerc / 100)
    if inShort
        tpShort := entry * (1 - tpPerc / 100)

if usePartialTP
    if inLong and not na(tpLong)
        strategy.exit("Long TP Partial", from_entry="Long", limit=tpLong, qty_percent=tpQtyPerc)
    if inShort and not na(tpShort)
        strategy.exit("Short TP Partial", from_entry="Short", limit=tpShort, qty_percent=tpQtyPerc)

// ---------------------------------------------------------
// Previous position state
// ---------------------------------------------------------
bool wasLong  = strategy.position_size[1] > 0
bool wasShort = strategy.position_size[1] < 0

// ---------------------------------------------------------
// LuxAlgo Trend Visuals
// ---------------------------------------------------------
color zColor = trend == 1 ? BULL_COLOR : BEAR_COLOR

zPlot   = plot(z, "L1 Proximal Filter", color=zColor, linewidth=3)
srcPlot = plot(srcInput, "Source Plot", color=na)

bool showFill = (trend == 1 and srcInput > z) or (trend == -1 and srcInput < z)

color fillTopColor    = showFill ? color.new(zColor, 50)  : na
color fillBottomColor = showFill ? color.new(zColor, 100) : na

fill(srcPlot, zPlot, srcInput, z, fillTopColor, fillBottomColor, "Trend Fill")

float switchVal   = (upChange or downChange) ? z[1] : na
color switchColor = upChange ? BULL_COLOR : BEAR_COLOR

plot(switchVal, "Trend Switch Dot", color=switchColor, style=plot.style_circles, linewidth=4, offset=-1)

// ---------------------------------------------------------
// TP & BE lines (transparent, disappear when inactive)
// ---------------------------------------------------------
float tpLine = inLong ? tpLong : inShort ? tpShort : na
plot(tpLine, "TP Line", color=color.new(color.yellow, 60), style=plot.style_linebr, linewidth=2)

float beLine = inLong ? beLong : inShort ? beShort : na
plot(beLine, "BE Line", color=color.new(COL_BE, 60), style=plot.style_linebr, linewidth=2)

// ---------------------------------------------------------
// BE marker (simple & perfect)
// ---------------------------------------------------------
float beLinePrev = beLine[1]

bool beLongHit  = not na(beLinePrev) and na(beLine) and wasLong
bool beShortHit = not na(beLinePrev) and na(beLine) and wasShort

plotshape(beLongHit,  "Long BE Hit",  shape.square, location.belowbar, COL_BE, size=size.small)
plotshape(beShortHit, "Short BE Hit", shape.square, location.abovebar, COL_BE, size=size.small)

// ---------------------------------------------------------
// TP markers (only real partial exits)
// ---------------------------------------------------------
bool sizeReducedLong  = wasLong  and strategy.position_size < strategy.position_size[1] and strategy.position_size > 0
bool sizeReducedShort = wasShort and strategy.position_size > strategy.position_size[1] and strategy.position_size < 0

bool tpLongHit  = sizeReducedLong  and not na(tpLong)
bool tpShortHit = sizeReducedShort and not na(tpShort)

plotshape(tpLongHit,  "Long TP Partial Hit",  shape.circle, location.abovebar, COL_TP_LONG, size=size.small)
plotshape(tpShortHit, "Short TP Partial Hit", shape.circle, location.belowbar, COL_TP_SHORT, size=size.small)

// ---------------------------------------------------------
// Entry markers
// ---------------------------------------------------------
plotshape(longEntry,  "Long Entry",  shape.triangleup,   location.belowbar, COL_LONG_ENTRY,  size=size.small)
plotshape(shortEntry, "Short Entry", shape.triangledown, location.abovebar, COL_SHORT_ENTRY, size=size.small)

// ---------------------------------------------------------
// Flip markers
// ---------------------------------------------------------
plotshape(flipLongToShort, "Flip L→S", shape.diamond, location.abovebar, COL_FLIP_SHORT, size=size.small)
plotshape(flipShortToLong, "Flip S→L", shape.diamond, location.belowbar, COL_FLIP_LONG, size=size.small)

// ---------------------------------------------------------
// Alerts
// ---------------------------------------------------------
alertcondition(longEntry,        "Long Entry",        "TSF LONG ENTRY")
alertcondition(shortEntry,       "Short Entry",       "TSF SHORT ENTRY")
alertcondition(flipLongToShort,  "Flip Long→Short",   "TSF FLIP SHORT")
alertcondition(flipShortToLong,  "Flip Short→Long",   "TSF FLIP LONG")
alertcondition(tpLongHit,        "Long TP Partial",   "TSF LONG TP PARTIAL")
alertcondition(tpShortHit,       "Short TP Partial",  "TSF SHORT TP PARTIAL")
alertcondition(beLongHit,        "Long BE",           "TSF LONG BE")
alertcondition(beShortHit,       "Short BE",          "TSF SHORT BE")