
Esta estratégia é diferente. Quando o ponto de parada é múltiplo, o sistema fica imediatamente vazio; quando o ponto de parada é vazio, o sistema é imediatamente mais. Este design de “virar a cara mais rápido do que o livro” permite que a estratégia continue a capturar lucros em situações de turbulência.
Não se preocupe com números pequenos, o design percentual baseado na média de 30 períodos é mais científico do que o número de pontos fixos. Um stop loss de 0,45% corresponde a uma flutuação de cerca de US \( 8-10 em ouro, um stop loss de 0,60% corresponde a cerca de US \) 12-15. O mecanismo de reentrada é mais inteligente: se você optar por reentrada após a primeira parada, o objetivo de parada é reduzido para 0,30 e o stop loss se aproxima de 0,20%.
Quando o ATR é inferior a 0,2 barreira, a estratégia entra em um período de resfriamento de 10 minutos, rejeitando todos os novos sinais. Este design é muito importante. Forçar a transação em um ambiente de baixa volatilidade é enviar dinheiro, melhor esperar.
A configuração do eixo central de 4 linhas K à esquerda e 2 linhas K à direita é mais radical do que o clássico parâmetro de 5 a 5. Isso significa que a estratégia identifica os pontos de inflexão mais cedo, mas também assume mais risco de falsas rupturas. Compatível com o filtro de tendência de linha média de 50 períodos, faça o mínimo do eixo central múltiplo apenas quando o preço estiver acima da linha média e faça o máximo do eixo central vazio quando estiver abaixo da linha média.
A probabilidade de 50% de reversão de posição após a parada e 50% de reentrada. Este projeto é interessante, mas também é perigoso. O bom é ser capaz de ajustar rapidamente no início da reversão de tendência, o mau é que é possível voltar em uma falsa ruptura.
Duas situações são as mais temidas pela estratégia: um horizonte ultra-baixo e um cenário unilateral ultra-alto. O primeiro desencadeia uma parada frequente do mecanismo de resfriamento, e o segundo é facilmente interceptado por filtros de linha K. O melhor cenário para a estratégia é o cenário de negociação normal de US \( 15 a US \) 30 por dia.
Apesar de haver um mecanismo de reversão, a estratégia ainda pode enfrentar perdas contínuas em caso de persistentes falsos sinais de ruptura. Especialmente antes e depois da divulgação de dados econômicos importantes, oscilações de sentimento no mercado podem causar a falha do sinal do eixo. É recomendado controlar rigorosamente as posições individuais e suspender manualmente a estratégia antes de eventos importantes.
/*backtest
start: 2024-09-24 00:00:00
end: 2025-09-22 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"ETH_USDT","balance":500000}]
*/
//@version=6
strategy("Gold By Ann v.2", overlay=true)
// --- Inputs ---
leftBars = input.int(4, "Pivot Lookback Left")
rightBars = input.int(2, "Pivot Lookback Right")
atrLength = input.int(14, "ATR Length")
atrMult = input.float(2.0, "ATR Multiplier")
atrThreshold = input.float(0.2, "ATR Threshold")
cooldownMinutes = input.int(10, "Cooldown Minutes")
// --- Pivot Calculation ---
ph = ta.pivothigh(leftBars, rightBars)
pl = ta.pivotlow(leftBars, rightBars)
ma = ta.sma(close, 50)
bullishTrend = close > ma
bearishTrend = close < ma
// --- Volatility (ATR) and Cooldown ---
atrValue = ta.atr(atrLength)
var float cooldownEnd = na
if atrValue < atrThreshold and na(cooldownEnd)
cooldownEnd := timenow + cooldownMinutes * 60 * 1000 // ms
if not na(cooldownEnd) and timenow > cooldownEnd
cooldownEnd := na
inCooldown = not na(cooldownEnd)
// --- Tall candle filter ---
rangeBar = high - low
isTall = rangeBar > ta.atr(5) * atrMult
// --- SL & TP based on % of 30-bar close ---
baseClose = ta.sma(close, 30) // 30-bar average close
slPercent = 0.0045 // 0.45%
tpPercent = 0.0060 // 0.60%
tpReEntryPercent = 0.006 // 0.30% (smaller TP after re-entry)
stopReEntryPercent = 0.005 // -0.20%
stopReEntryValue = baseClose * stopReEntryPercent
slValue = baseClose * slPercent
tpValue = baseClose * tpPercent
tpReValue = baseClose * tpReEntryPercent
// --- Re-entry state flag ---
var bool isReEntry = false
// --- Trade Logic (Only if NOT in cooldown) ---
if not inCooldown and not isTall
if strategy.position_size == 0
if not na(pl)
strategy.entry("PivExtLE", strategy.long, comment="Long")
isReEntry := false
if not na(ph)
strategy.entry("PivExtSE", strategy.short, comment="Short")
isReEntry := false
// =====================================================
// --- Take Profit / Stop Loss with auto-flip ---
// =====================================================
// LONG
if strategy.position_size > 0 and not isTall
entryPrice = strategy.position_avg_price
tpLevel = entryPrice + (isReEntry ? tpReValue : tpValue)
// Re-entry extra stop condition
if isReEntry and close <= entryPrice - stopReEntryValue
strategy.close("PivExtLE", comment="Stop Re-Entry Long (-0.20%)")
isReEntry := false
else if close >= tpLevel
strategy.close("PivExtLE", comment=isReEntry ? "TP Long (Re-Entry)" : "TP Long")
randChoice = (bar_index * 9301 + 49297) % 2
if randChoice == 0
strategy.entry("PivExtSE", strategy.short, comment="Flip to Short (TP)")
isReEntry := false
else
strategy.entry("PivExtLE", strategy.long, comment="Re-Enter Long (TP)")
isReEntry := true
else if close <= entryPrice - slValue
strategy.close("PivExtLE", comment="SL Long")
strategy.entry("PivExtSE", strategy.short, comment="Flip to Short (SL)")
isReEntry := false
// SHORT
if strategy.position_size < 0 and not isTall
entryPrice = strategy.position_avg_price
tpLevel = entryPrice - (isReEntry ? tpReValue : tpValue)
// Re-entry extra stop condition
if isReEntry and close >= entryPrice + stopReEntryValue
strategy.close("PivExtSE", comment="Stop Re-Entry Short (-0.20%)")
isReEntry := false
else if close <= tpLevel
strategy.close("PivExtSE", comment=isReEntry ? "TP Short (Re-Entry)" : "TP Short")
strategy.entry("PivExtLE", strategy.long, comment="Flip to Long (TP)")
isReEntry := true
else if close >= entryPrice + slValue
strategy.close("PivExtSE", comment="SL Short")
strategy.entry("PivExtLE", strategy.long, comment="Flip to Long (SL)")
isReEntry := false
// --- Plot reference ---
plot(slValue, title="SL Value (0.45% of 30-bar Close)", color=color.red)
plot(tpValue, title="TP Value (0.60% of 30-bar Close)", color=color.green)
plot(tpReValue, title="TP Value (Re-Entry 0.30%)", color=color.orange)