Estratégia de inversão de tendência baseada no indicador ADX

Autora:ChaoZhang, Data: 2023-09-13 17:02:31
Tags:

Esta estratégia é chamada de Estratégia de Reversão de Tendência Baseada no Indicador ADX. Ele usa o indicador ADX para medir a força da tendência e capturar oportunidades de reversão quando sobrecomprado / sobrevendido.

ADX significa índice direcional médio, refletindo a força de uma tendência.

O DMI inclui as linhas DI+ e DI-. DI+ acima de DI- indica uma tendência de alta, enquanto DI- acima de DI+ indica uma tendência de queda.

A lógica de negociação é:

  1. Quando o ADX está acima de 45, a tendência é considerada muito acentuada.

  2. Se o DI+ estiver abaixo do DI- então, ele sinaliza um estado de sobrevenda e uma oportunidade de reversão da tendência, indo longo.

  3. Por outro lado, se o DI- estiver abaixo do DI+, sugere condições de sobrecompra e uma oportunidade de reversão para um short.

  4. Tirar lucro em tempo hábil após a reversão.

A vantagem é usar o ADX para determinar pontos de reversão de tendência fortes. Valores altos do ADX filtram sinais falsos de mercados variados de forma eficaz. Mas os parâmetros do ADX precisam de otimização e o stop loss também é importante.

Em conclusão, o ADX é hábil em medir o tempo de reversão de tendências fortes.


/*backtest
start: 2023-08-13 00:00:00
end: 2023-09-12 00:00:00
period: 2h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
strategy(shorttitle='DMI swings',title='DMI swings', overlay=true, initial_capital = 100, process_orders_on_close=true, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, commission_type=strategy.commission.percent, commission_value=0.1)

//Backtest dates
fromMonth = input(defval = 1,    title = "From Month",      type = input.integer, minval = 1, maxval = 12)
fromDay   = input(defval = 1,    title = "From Day",        type = input.integer, minval = 1, maxval = 31)
fromYear  = input(defval = 2021, title = "From Year",       type = input.integer, minval = 1970)
thruMonth = input(defval = 1,    title = "Thru Month",      type = input.integer, minval = 1, maxval = 12)
thruDay   = input(defval = 1,    title = "Thru Day",        type = input.integer, minval = 1, maxval = 31)
thruYear  = input(defval = 2112, title = "Thru Year",       type = input.integer, minval = 1970)

showDate  = input(defval = true, title = "Show Date Range", type = input.bool)

start     = timestamp(fromYear, fromMonth, fromDay, 00, 00)        // backtest start window
finish    = timestamp(thruYear, thruMonth, thruDay, 23, 59)        // backtest finish window
window()  => true        // create function "within window of time"

[pos_dm, neg_dm, avg_dm] = dmi(14, 14)

//Entry 
strategy.entry(id="long", long = true, when = avg_dm > 45 and pos_dm < neg_dm and window())

//Exit
strategy.close("long", when = avg_dm > 45 and pos_dm > neg_dm and window())

Mais.