
A estratégia de intervalo de transição é uma estratégia de negociação de curta linha baseada em intervalos de flutuação de preços. Ela usa intervalos de flutuação que os preços formam em um determinado intervalo de tempo para julgar a tendência do mercado, fazendo uma entrada de mais/menos quando o intervalo é quebrado.
A estratégia constrói um intervalo de flutuação do preço, calculado a partir dos preços mais altos e mais baixos das linhas K anteriores. Quando a linha K mais recente penetra esse intervalo, a tendência é reversível, gerando um sinal de negociação.
Concretamente, a estratégia segue continuamente os preços máximos e mínimos da última N-raiz K-linha ((N-parâmetro ajustável), onde:
O que é o que está acontecendo com o mercado de ações?
Quando o preço de fechamento da linha K mais recente é superior ao preço máximo do intervalo, indica uma quebra no intervalo, gerando um sinal de fazer mais; quando o preço de fechamento da linha K mais recente é inferior ao preço mínimo do intervalo, indica uma quebra no intervalo, gerando um sinal de fazer menos.
Além disso, a estratégia adicionou filtros de cor e de entidades. O filtro de cor filtra os sinais de acordo com a cor da linha K; o filtro de entidades filtra os sinais de acordo com o tamanho da linha K. Isso pode filtrar alguns falsos sinais.
A estratégia tem as seguintes vantagens:
A estratégia também apresenta alguns riscos:
Estes riscos podem ser reduzidos por meio de ajustes nos parâmetros de intervalos, otimização das condições de filtragem do sinal e outros métodos.
A estratégia pode ser otimizada em várias direções:
A estratégia de intervalo de transição é, em geral, uma estratégia de negociação de linha curta mais simples e prática. Ela determina pontos de mudança de tendência através de intervalos de preços, para que você possa aproveitar rapidamente as oportunidades do mercado.
/*backtest
start: 2023-11-28 00:00:00
end: 2023-12-28 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//Noro
//2018
//@version=2
strategy("Noro's Transient Zones Strategy v1.0", shorttitle = "TZ str 1.0", overlay=true, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, pyramiding = 0)
//Settings
needlong = input(true, defval = true, title = "Long")
needshort = input(true, defval = true, title = "Short")
capital = input(100, defval = 100, minval = 1, maxval = 10000, title = "Capital, %")
usecol = input(true, defval = true, title = "Use Color-Filter")
usebod = input(true, defval = true, title = "Use Body-Filter")
h_left = input(title = "H left", defval = 10)
h_right = -1
sample_period = input(title = "Sample bars for % TZ", defval = 5000)
show_ptz = input(title = "Show PTZ", type = bool, defval = true)
show_channel = input(title = "Show channel", type = bool, defval = true)
fromyear = input(2018, defval = 2018, minval = 1900, maxval = 2100, title = "From Year")
toyear = input(2100, defval = 2100, minval = 1900, maxval = 2100, title = "To Year")
frommonth = input(01, defval = 01, minval = 01, maxval = 12, title = "From Month")
tomonth = input(12, defval = 12, minval = 01, maxval = 12, title = "To Month")
fromday = input(01, defval = 01, minval = 01, maxval = 31, title = "From day")
today = input(31, defval = 31, minval = 01, maxval = 31, title = "To day")
//By Jurij w/ TZ percent occurrence by SPYderCrusher
//barCount = nz(barCount[1]) + 1
//check history and realtime PTZ
h_left_low = lowest(h_left)
h_left_high = highest(h_left)
newlow = low <= h_left_low
newhigh = high >= h_left_high
plotshape(newlow and show_ptz, style=shape.triangledown, location=location.belowbar, color=red)
plotshape(newhigh and show_ptz, style=shape.triangleup, location=location.abovebar, color=green)
channel_high = plot(show_channel ? h_left_low : 0, color=silver)
channel_low = plot (show_channel ? h_left_high : 0, color=silver)
//check true TZ back in history
central_bar_low = low[h_right + 1]
central_bar_high = high[h_right + 1]
full_zone_low = lowest(h_left + h_right + 1)
full_zone_high = highest(h_left + h_right + 1)
central_bar_is_highest = central_bar_high >= full_zone_high
central_bar_is_lowest = central_bar_low <= full_zone_low
plotarrow(central_bar_is_highest ? -1 : 0, offset=-h_right-1)
plotarrow(central_bar_is_lowest ? 1 : 0, offset=-h_right-1)
//Color Filter
bar = close > open ? 1 : close < open ? -1 : 0
//Body Filter
nbody = abs(close - open)
abody = sma(nbody, 10)
body = nbody > abody / 3 or usebod == false
//Signals
up1 = central_bar_is_lowest and body and (bar == -1 or usecol == false)
dn1 = central_bar_is_highest and body and (bar == 1 or usecol == false)
exit = ((strategy.position_size > 0 and close > open) or (strategy.position_size < 0 and close < open)) and body
//Trading
lot = strategy.position_size == 0 ? strategy.equity / close * capital / 100 : lot[1]
if up1
if strategy.position_size < 0
strategy.close_all()
strategy.entry("long", strategy.long, needlong == false ? 0 : lot, when=(time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59)))
if dn1
if strategy.position_size > 0
strategy.close_all()
strategy.entry("Short", strategy.short, needshort == false ? 0 : lot, when=(time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59)))
if time > timestamp(toyear, tomonth, today, 23, 59) or exit
strategy.close_all()