
A estratégia de negociação de ruptura de tendência de precisão é baseada em indicadores de tendência e em determinadas formas de linha K, para capturar com precisão a tendência de ruptura. A estratégia utiliza a linha média para determinar a direção da tendência, o indicador RSI para determinar a sobrevenda e a sobrevenda, e, em combinação com a forma de linha K avançada, seleciona o ponto de ruptura para determinar com precisão a posição da tendência e, no momento adequado, executa uma ruptura de negociação para obter lucros extras.
Aplicar o 8o EMA e o 80o EMA para determinar a direção da tendência. O 8o EMA é definido como um otimismo acima do 80o EMA e, inversamente, como um pessimismo.
Define uma combinação específica de três linhas K, ou seja, o primeiro ponto baixo da linha K é menor que o segundo e o terceiro ponto baixo da linha K é menor que o segundo. Esta forma aparece como um sinal de compra quando há uma tendência ascendente. Quando há uma tendência descendente, é um sinal de venda.
A terceira linha K é uma linha K interna, ou seja, o preço de fechamento é o melhor ponto de sinal quando o preço está dentro da linha K anterior. Neste momento, a forma 123 pode ser colocada diretamente na ordem de negociação.
O preço de comissão é o terceiro K-line high ((comprar) ou o terceiro K-line low ((vender)). O stop loss é o segundo K-line low ((comprar) ou o segundo K-line high ((vender)). O stop loss é o dobro da diferença de risco.
Quando a tendência, a forma e as condições do indicador são atingidas, coloque uma ordem de ruptura para fazer uma negociação de alta probabilidade. E configure um stop loss para bloquear o lucro e obter uma operação de ruptura estável.
A estratégia tem as seguintes vantagens significativas:
Utilize a EMA dupla para determinar a direção da tendência e evitar negociações adversas.
A seleção de formas K lineares é um passo importante para aumentar a probabilidade de lucro.
A qualidade do sinal é garantida apenas quando os indicadores de tendência, forma e diferença de preço estão de acordo.
A forma de linha K interna aumenta a confiabilidade do sinal, bloqueando ainda mais o tempo de negociação.
O Stop Loss Stop Loss é um ponto de paralisação predefinido para controlar o risco de transações individuais.
Os dados de retrospecção confirmam que a taxa de vitória é superior a 65%, com vantagens estatísticas de longo prazo.
Em suma, a estratégia aproveita o julgamento integral de tendências, formas e indicadores para posicionar com precisão o momento da ruptura, com uma vantagem de risco-receita estável.
Os principais riscos dessa estratégia são:
O erro de julgamento de tendências pode gerar sinais errados em situações de turbulência. Pode-se introduzir mais indicadores de tendências para confirmação multidimensional.
Uma única forma de parar o prejuízo não pode ser perfeitamente adequada a cada situação. Pode-se definir um ponto de parada de prejuízo flutuante.
A identificação de K-linhas depende de configurações de parâmetros e precisa de otimização repetida para encontrar a melhor combinação.
Não é possível prever o impacto de eventos de Black Swan de grande importância sobre a negociação. Recomenda-se o uso de controle de posição e a criação de posições em lotes.
Os dados retrospectivos não podem representar o desempenho real das transações, existindo o risco de sobre-ajuste. A robustez dos parâmetros deve ser rigorosamente verificada.
Os custos de transação têm uma grande influência sobre a estratégia de negociação de alta frequência. Deve-se garantir que a taxa de ganho e perda seja suficiente para suportar os custos.
Em geral, a estratégia pode reduzir o risco e melhorar a estabilidade do desempenho, por meio da otimização da configuração de parâmetros, da introdução de mais dimensões de julgamento e do controle do tamanho da posição.
A estratégia ainda possui as seguintes dimensões de otimização:
Testar mais parâmetros de K-linearidade para determinar uma combinação de parâmetros mais estável.
Aumentar o volume de transações para a confirmação multidimensional, evitando falsas brechas.
Aumentar a robustez dos parâmetros de avaliação de indicadores como a taxa de Sharpe, a taxa de ganho e perda.
Introdução de mecanismos de rastreamento de paralisação para gerenciamento dinâmico de lucros.
Combinado com o índice de pânico VIX, evita períodos de incerteza no mercado.
Testar diferentes parâmetros de ciclo de detenção para determinar a melhor eficácia de uma posição.
Otimizar o mecanismo de parada de perdas para evitar que a parada estática predefinida seja muito rígida.
Através destes meios, a estabilidade, a flexibilidade e a rentabilidade da estratégia podem ser ainda mais reforçadas.
A estratégia de negociação de ruptura de tendência de precisão usa com sucesso a combinação orgânica de tendências, formas e paradas de perda para capturar uma alta probabilidade de ruptura de tendência. Com características de claridade de sinais de negociação, reconhecimento de múltiplos indicadores e controle de risco, é uma estratégia eficiente para situações de tendência. Com otimização e aperfeiçoamento contínuos, a estratégia promete ser uma ferramenta poderosa para monitorar a tendência e gerenciar a posição de ruptura.
/*backtest
start: 2022-11-01 00:00:00
end: 2023-10-14 05:20:00
period: 1d
basePeriod: 1h
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/
// © julianossilva
//@version=5
strategy(title="J2S Backtest: 123-Stormer Strategy",
shorttitle="J2S Backtest: 123-Stormer Strategy",
overlay=true, initial_capital=1000, default_qty_value=10,
default_qty_type = strategy.percent_of_equity, pyramiding=0)
// Initial Backtest Date Range
useStartDate = timestamp("01 Jan 2020 21:00:00")
useEndDate = timestamp("01 Jan 2023 21:00:00")
// User Inputs
SIGNAL_CONFIG = "BACKTEST: STORMER STRATEGY (123)"
longEntryInput = input.bool(defval=true, title="Long Entry", group=SIGNAL_CONFIG)
shortEntryInput = input.bool(defval=true, title="Short entry", group=SIGNAL_CONFIG)
thresholdForEntryInput = input.int(defval=3, title="Threshold on clandes for entry", group=SIGNAL_CONFIG)
insideBarStrategyTitle = "Only third candle inside bar is valid"
insideBarStrategyTip = "According to Stomer, it would be the best signal for the strategy"
insideBarStrategyInput = input.bool(defval=true, title=insideBarStrategyTitle, group=SIGNAL_CONFIG, tooltip=insideBarStrategyTip)
EMA_CONFIG = "BACKTEST: EXPONENTIAL MOVING AVERAGES"
sourceInput = input.source(defval=close, title="Source", inline="01", group=EMA_CONFIG)
emaTimeframeInput = input.timeframe("1W", title="Timeframe", inline="01", group=EMA_CONFIG)
emaOffsetInput = input.int(defval=8, title="Offset", inline="01", group=EMA_CONFIG)
fastEMALengthInput = input.int(defval=8, title="Fast EMA Length", inline="02", group=EMA_CONFIG)
useFastEMAInput = input.bool(defval=true, title="Use Fast EMA", inline="02", group=EMA_CONFIG)
slowEMALengthInput = input.int(defval=80, title="Slow EMA Length", inline="03", group=EMA_CONFIG)
useSlowEMAInput = input.bool(defval=true, title="Use Slow EMA", inline="03", group=EMA_CONFIG)
PERIOD_CONFIG = "BACKTEST: TIME PERIOD"
useDateFilterInput = input.bool(defval=true, title="Filter Date Range of Backtest", group=PERIOD_CONFIG)
backtestStartDateInput = input(defval=useStartDate, title="Start Date", group=PERIOD_CONFIG)
backtestEndDateInput = input(defval=useEndDate, title="End Date", group=PERIOD_CONFIG)
// Colors
bbBackgroundColor = color.rgb(33, 150, 243, 90)
candleColorDown = color.rgb(239, 83, 80, 80)
candleColorUp = color.rgb(38, 166, 154, 70)
insideBarColorDown = color.rgb(239, 83, 80, 40)
insideBarColorUp = color.rgb(38, 166, 154, 20)
downTrendColor = color.rgb(239, 83, 80, 80)
sidewaysTrendColor = color.rgb(252, 232, 131, 80)
upTrendColor = color.rgb(38, 166, 154, 80)
buySignalColor = color.lime
sellSignalColor = color.orange
// Candles
isCandleUp() => close > open
isCandleDown() => close <= open
barcolor(isCandleUp() ? candleColorUp : isCandleDown() ? candleColorDown : na)
// Exponential Moving Averages
fastEMA = request.security(syminfo.tickerid, emaTimeframeInput, ta.ema(sourceInput, fastEMALengthInput), barmerge.gaps_on, barmerge.lookahead_on)
currentFastEMA = request.security(syminfo.tickerid, emaTimeframeInput, ta.ema(sourceInput, fastEMALengthInput), barmerge.gaps_off, barmerge.lookahead_on)
previousFastEMA = request.security(syminfo.tickerid, emaTimeframeInput, ta.ema(sourceInput[1], fastEMALengthInput), barmerge.gaps_off, barmerge.lookahead_on)
slowEMA = request.security(syminfo.tickerid, emaTimeframeInput, ta.ema(sourceInput, slowEMALengthInput), barmerge.gaps_on, barmerge.lookahead_on)
currentSlowEMA = request.security(syminfo.tickerid, emaTimeframeInput, ta.ema(sourceInput, slowEMALengthInput), barmerge.gaps_off, barmerge.lookahead_on)
previousSlowEMA = request.security(syminfo.tickerid, emaTimeframeInput, ta.ema(sourceInput[1], slowEMALengthInput), barmerge.gaps_off, barmerge.lookahead_on)
// Trend Rules for Exponential Moving Averages
isSlowEMAUp() => currentSlowEMA > previousSlowEMA
isSlowEMADown() => currentSlowEMA < previousSlowEMA
isFastEMAUp() => currentFastEMA > previousFastEMA
isFastEMADown() => currentFastEMA < previousFastEMA
// Exponential Moving Average Colors
fastEMAColor = isFastEMAUp() ? upTrendColor : isFastEMADown() ? downTrendColor : sidewaysTrendColor
slowEMAColor = isSlowEMAUp() ? upTrendColor : isSlowEMADown() ? downTrendColor : sidewaysTrendColor
// Display Exponential Moving Averages
plot(useFastEMAInput ? fastEMA : na, offset=emaOffsetInput, color=fastEMAColor, title="Fast EMA", style=plot.style_line, linewidth=4)
plot(useSlowEMAInput ? slowEMA : na, offset=emaOffsetInput, color=slowEMAColor, title="Slow EMA", style=plot.style_line, linewidth=7)
// Price Trend
pricesAboveFastEMA() => low[2] > currentFastEMA and low[1] > currentFastEMA and low > currentFastEMA
pricesAboveSlowEMA() => low[2] > currentSlowEMA and low[1] > currentSlowEMA and low > currentSlowEMA
pricesBelowFastEMA() => high[2] < currentFastEMA and high[1] < currentFastEMA and high < currentFastEMA
pricesBelowSlowEMA() => high[2] < currentSlowEMA and high[1] < currentSlowEMA and high < currentSlowEMA
// Market in Bullish Trend
isBullishTrend() =>
if useFastEMAInput and useSlowEMAInput
pricesAboveFastEMA() and pricesAboveSlowEMA()
else if useFastEMAInput
pricesAboveFastEMA()
else if useSlowEMAInput
pricesAboveSlowEMA()
else
na
// Market in Bearish Trend
isBearishTrend() =>
if useFastEMAInput and useSlowEMAInput
pricesBelowFastEMA() and pricesBelowSlowEMA()
else if useFastEMAInput
pricesBelowFastEMA()
else if useSlowEMAInput
pricesBelowSlowEMA()
else
na
// Stormer Strategy (123)
isFirstCandleUp() => high[2] > high[1] and low[2] > low[1]
isFirstCandleDown() => high[2] < high[1] and low[2] < low[1]
isThirdCandleUp() => low > low[1]
isThirdCandleDown() => high < high[1]
isThirdCandleInsideBar() => high < high[1] and low > low[1]
// Buy Signal
isStormer123Buy() =>
if insideBarStrategyInput
longEntryInput and isFirstCandleUp() and isThirdCandleInsideBar() and isBullishTrend()
else
longEntryInput and isFirstCandleUp() and isThirdCandleUp() and isBullishTrend()
// Sell Signal
isStormer123Sell() =>
if insideBarStrategyInput
shortEntryInput and isFirstCandleDown() and isThirdCandleInsideBar() and isBearishTrend()
else
shortEntryInput and isFirstCandleDown() and isThirdCandleDown() and isBearishTrend()
// Backtest Time Period
inTradeWindow = true
isInTradeWindow() => inTradeWindow
isBacktestDateRangeOver() => not inTradeWindow and inTradeWindow[1]
// Backtest Price Parameters
highestPrice = ta.highest(high, 3)
lowestPrice = ta.lowest(low,3)
priceRange = highestPrice - lowestPrice
// Stormer Strategy (123): LONG
var myLongOrders = array.new_int(0)
longtEntryID = "Long Entry:\n" + str.tostring(bar_index)
longExitID = "Long Exit:\n" + str.tostring(bar_index)
stopLossInLong = lowestPrice + 0.01
takeProfitInLong = priceRange + high
longEntryHasBeenMet = isInTradeWindow() and isBullishTrend() and isStormer123Buy()
// Scheduling LONG entry
if longEntryHasBeenMet
array.push(myLongOrders, bar_index)
strategy.order(longtEntryID, strategy.long, stop=high)
strategy.exit(longExitID, longtEntryID, stop=stopLossInLong, limit=takeProfitInLong)
// In pine script, any order scheduled but not yet filled can be canceled.
// Once a order is filled, the trade is only finished with use of close or exit functions.
// As scheduled orders are not stored in the strategy.opentrades array, manual control is required.
for myOrderIndex = 0 to (array.size(myLongOrders) == 0 ? na : array.size(myLongOrders) - 1)
myLongOrder = array.get(myLongOrders, myOrderIndex)
if bar_index - myLongOrder == thresholdForEntryInput
longEntryID = "Long Entry:\n" + str.tostring(myLongOrder)
strategy.cancel(longEntryID)
// Stormer Strategy (123): SHORT
var myShortOrders = array.new_int(0)
shortEntryID = "Short Entry:\n" + str.tostring(bar_index)
shortExitID = "Short Exit:\n" + str.tostring(bar_index)
stopLossInShort = highestPrice + 0.01
takeProfitInShort = low - priceRange
shortEntryHasBeenMet = isInTradeWindow() and isBearishTrend() and isStormer123Sell()
// Scheduling SHORT entry
if shortEntryHasBeenMet
array.push(myShortOrders, bar_index)
strategy.order(shortEntryID, strategy.short, stop=low)
strategy.exit(shortExitID, shortEntryID, stop=stopLossInShort, limit=takeProfitInShort)
// In pine script, any order scheduled but not yet filled can be canceled.
// Once a order is filled, the trade is only finished with use of close or exit functions.
// As scheduled orders are not stored in the strategy.opentrades array, manual control is required.
for myOrderIndex = 0 to (array.size(myShortOrders) == 0 ? na : array.size(myShortOrders) - 1)
myShortOrder = array.get(myShortOrders, myOrderIndex)
if bar_index - myShortOrder == thresholdForEntryInput
shortEntryID := "Short Entry:\n" + str.tostring(myShortOrder)
strategy.cancel(shortEntryID)
// Close all positions at the end of the backtest period
if isBacktestDateRangeOver()
strategy.cancel_all()
strategy.close_all(comment="Date Range Exit")
// Display Signals
plotshape(series=longEntryHasBeenMet, title="123 Buy", style=shape.triangleup, location=location.belowbar, color=buySignalColor, text="123", textcolor=buySignalColor)
plotshape(series=shortEntryHasBeenMet, title="123 Sell", style=shape.triangledown, location=location.abovebar, color=sellSignalColor, text="123", textcolor=sellSignalColor)