Estratégia de ruptura da volatilidade

Autora:ChaoZhang, Data: 2023-12-13 14:36:04
Tags:

img

Resumo

A estratégia de ruptura de volatilidade é uma estratégia que faz operações de compra e venda quando os preços atravessam os principais níveis de suporte ou resistência em padrões de volatilidade.

Princípio da estratégia

Esta estratégia baseia-se principalmente nos quatro indicadores técnicos Bollinger Middle Band, 48-day Simple Moving Average (SMA), MACD e ADX.

  1. Considerar oportunidades de negociação quando o preço de fechamento cruzar acima ou abaixo da SMA de 48 dias;

  2. Quando o preço de fechamento atravessa a faixa média de Bollinger, serve como sinal de entrada;

  3. O MACD superior ou inferior a 0 serve como indicador auxiliar para determinar a direção da tendência;

  4. ADX superior a 25 para filtrar mercados não em tendência.

Quando as quatro condições acima estiverem preenchidas, vá para longo ou curto.

Vantagens da estratégia

Trata-se de uma estratégia que combina indicadores de tendência e volatilidade.

  1. A SMA de 48 dias filtra a troca excessivamente frequente e bloqueia as tendências de médio e longo prazo;

  2. A ruptura da faixa média de Bollinger compreende os principais pontos de ruptura de suporte/resistência com forte função de stop loss;

  3. O MACD avalia a direcção das principais tendências, evitando a negociação contra a tendência;

  4. O ADX filtra os mercados que não estão em tendência e melhora a taxa de ganho da estratégia.

Em resumo, esta estratégia fez otimizações no controle da frequência de negociação, captura de pontos-chave, determinação da direção da tendência e filtragem de movimentos inválidos, tendo assim uma taxa de vitória relativamente alta.

Riscos da Estratégia

Os principais riscos desta estratégia são:

  1. Em mercados voláteis, a faixa média de Bollinger pode desencadear demasiadas oportunidades de negociação, levando a um excesso de negociação;

  2. O indicador ADX também apresenta alguns erros na determinação de tendências e movimentos inválidos;

  3. Risco de utilização relativamente elevado, adequado para investidores que possam suportar um certo nível de risco.

Orientações de otimização

Esta estratégia pode ser melhorada nos seguintes aspectos:

  1. Adicionar o indicador ATR para definir pontos de perda de parada e reduzir por perda de parada;

  2. Otimizar os parâmetros de Bollinger para reduzir a frequência de desencadeamento da linha média;

  3. Adicionar indicadores de volume de negociação ou de força da tendência para determinar a força das tendências, evitando operações de reversão fracas.

Resumo

Em resumo, esta estratégia de ruptura de volatilidade é relativamente madura como um todo, capturando efetivamente pontos de negociação chave em mercados voláteis.


/*backtest
start: 2023-12-11 00:00:00
end: 2023-12-12 00:00:00
period: 10m
basePeriod: 1m
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/
// © 03.freeman
//Volatility Traders Minds Strategy (VTM Strategy)
//I found this startegy on internet, with a video explaingin how it works.
//Conditions for entry:
//1 - Candles must to be above or bellow the 48 MA (Yellow line)
//2 - Candles must to break the middle of bollinger bands
//3 - Macd must to be above or bellow zero level;
//4 - ADX must to be above 25 level
//@version=4
strategy("Volatility Traders Minds Strategy (VTM Strategy)", shorttitle="VTM",overlay=true)
source = input(close)
//MA
ma48 = sma(source,48)
//MACD
fastLength = input(12)
slowlength = input(26)
MACDLength = input(9)

MACD = ema(source, fastLength) - ema(source, slowlength)
aMACD = ema(MACD, MACDLength)
delta = MACD - aMACD

//BB

length = input(20, minval=1)
mult = input(2.0, minval=0.001, maxval=50)

basis = sma(source, length)
dev = mult * stdev(source, length)

upper = basis + dev
lower = basis - dev

//ADX
adxThreshold = input(title="ADX Threshold", type=input.integer, defval=25, minval=1)
adxlen = input(14, title="ADX Smoothing")
dilen = input(14, title="DI Length")
dirmov(len) =>
	up = change(high)
	down = -change(low)
	plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
    minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
	truerange = rma(tr, len)
	plus = fixnan(100 * rma(plusDM, len) / truerange)
	minus = fixnan(100 * rma(minusDM, len) / truerange)
	[plus, minus]

adx(dilen, adxlen) =>
	[plus, minus] = dirmov(dilen)
	sum = plus + minus
	adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)

sig = adx(dilen, adxlen)

//  Strategy: (Thanks to JayRogers)
// === STRATEGY RELATED INPUTS ===
//tradeInvert     = input(defval = false, title = "Invert Trade Direction?")
// the risk management inputs
inpTakeProfit   = input(defval = 0, title = "Take Profit Points", minval = 0)
inpStopLoss     = input(defval = 0, title = "Stop Loss Points", minval = 0)
inpTrailStop    = input(defval = 0, title = "Trailing Stop Loss Points", minval = 0)
inpTrailOffset  = input(defval = 0, title = "Trailing Stop Loss Offset Points", minval = 0)

// === RISK MANAGEMENT VALUE PREP ===
// if an input is less than 1, assuming not wanted so we assign 'na' value to disable it.
useTakeProfit   = inpTakeProfit  >= 1 ? inpTakeProfit  : na
useStopLoss     = inpStopLoss    >= 1 ? inpStopLoss    : na
useTrailStop    = inpTrailStop   >= 1 ? inpTrailStop   : na
useTrailOffset  = inpTrailOffset >= 1 ? inpTrailOffset : na

// === STRATEGY - LONG POSITION EXECUTION ===
enterLong() => close>ma48 and close>basis and delta>0 and sig>adxThreshold  // functions can be used to wrap up and work out complex conditions
//exitLong() => jaw>teeth or jaw>lips or teeth>lips
strategy.entry(id = "Buy", long = true, when = enterLong() )    // use function or simple condition to decide when to get in
//strategy.close(id = "Buy", when = exitLong() )                  // ...and when to get out

// === STRATEGY - SHORT POSITION EXECUTION ===
enterShort() => close<ma48 and close<basis and delta<0 and sig>adxThreshold
//exitShort() => jaw<teeth or jaw<lips or teeth<lips
strategy.entry(id = "Sell", long = false, when = enterShort())
//strategy.close(id = "Sell", when = exitShort() )

// === STRATEGY RISK MANAGEMENT EXECUTION ===
// finally, make use of all the earlier values we got prepped
strategy.exit("Exit Buy", from_entry = "Buy", profit = useTakeProfit, loss = useStopLoss, trail_points = useTrailStop, trail_offset = useTrailOffset)
strategy.exit("Exit Sell", from_entry = "Sell", profit = useTakeProfit, loss = useStopLoss, trail_points = useTrailStop, trail_offset = useTrailOffset)

// === Backtesting Dates === thanks to Trost

testPeriodSwitch = input(false, "Custom Backtesting Dates")
testStartYear = input(2020, "Backtest Start Year")
testStartMonth = input(1, "Backtest Start Month")
testStartDay = input(1, "Backtest Start Day")
testStartHour = input(0, "Backtest Start Hour")
testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,testStartHour,0)
testStopYear = input(2020, "Backtest Stop Year")
testStopMonth = input(12, "Backtest Stop Month")
testStopDay = input(31, "Backtest Stop Day")
testStopHour = input(23, "Backtest Stop Hour")
testPeriodStop = timestamp(testStopYear,testStopMonth,testStopDay,testStopHour,0)
testPeriod() =>
    time >= testPeriodStart and time <= testPeriodStop ? true : false
isPeriod = testPeriodSwitch == true ? testPeriod() : true
// === /END

if not isPeriod
    strategy.cancel_all()
    strategy.close_all()

Mais.