Zone Shift — Trend Zones and Retests

Zone Shift — Trend Zones and Retests

What is Zone Shift?

Zone Shift is a trend-and-channel indicator designed for clear, actionable context. It highlights when price escapes a dynamic envelope and then retests the breakout level. The tool works across timeframes:

  • Swing & positional: clean visual structure and reliable “zone memory.”

  • Intraday: responsive enough for trend days; still mindful of retests.

Use it to:

  • Confirm trend bias (green/red candles).

  • Track dynamic zones (top/bottom bands).

  • Spot retests of the trend-start level (diamond signals) that often precede continuation.

How it works

  1. Core averages

    • ema: an exponential-style average of close using length (user-driven).

    • hma: a faster, HMA-like average using max(20, length − 40) for the period.

    • Middle line (mid) = average of ema and hma.

  2. Dynamic distance

    • dist = simple average of the true bar range (high − low) over 200 bars.

    • Top (itop) = mid + dist; Bottom (ibot) = mid − dist.

  3. Trend flip logic

    • Bull flip: when the low closes above itop while the prior bar’s low was below the prior itop.
      trend = 1, trendStart = low, candles turn green.

    • Bear flip: when the high falls below ibot while the prior bar’s high was above the prior ibot.
      trend = 0, trendStart = high, candles turn red.

  4. Retest logic (⯁)

    • After a flip, the indicator tracks the trend-start level (trendStart).

    • Bull trend: prints a green ⯁ when price crosses back above trendStart.

    • Bear trend: prints a red ⯁ when price crosses back below trendStart.

    • Markers are spaced by ≥ 5 bars to avoid clutter, and positioned using ATR(14) x 0.2 for visibility.

Visual elements & interpretation

  • Three lines

    • Top (blue): upper zone boundary.

    • Middle (dotted): blended trend mean (EMA/HMA-style).

    • Bottom (blue): lower zone boundary.

  • Candle coloring

    • Green candles = active bull regime after a confirmed upside escape.

    • Red candles = active bear regime after a confirmed downside escape.

  • Retest diamonds (⯁)

    • Plot a green ⯁ below price in bull regimes (reclaiming trend-start).

    • Plot a red ⯁ above price in bear regimes (rejecting trend-start).

Inputs & settings

  • Length (per)

    • Default: 100

    • Range enforced: 60–200 (automatically clamped).

    • Effect: Governs the smoothness of the core averages. Larger = smoother bands; smaller = more responsive.

  • Candle coloring (colorCandles)

    • 1 = on (default), 0 = off. When on, the indicator draws candles with regime colors.

  • ATR(14) for marker offset

    • Used only to place ⯁ slightly away from bars (±0.2 × ATR) for readability.

Note: Internally, length feeds both the EMA-like and HMA-style calculations, with the HMA-style period set to max(20, length − 40) to maintain responsiveness.

Signals & trade ideas (not financial advice)

  • Breakout → Trend initiation
    When price escapes the Top/Bottom and candles flip color, consider the new regime as in force.

  • Retest continuation (⯁)
    The diamond marks when price re-tests the trend-start level and reaffirms the regime. Many traders look for follow-through candles after the ⯁.

  • Middle-line pullbacks
    In an established trend, pullbacks toward the Middle can act as dynamic mean reversion spots for continuation, especially when the regime color remains intact.

ProBuilder code

Share this

Risk disclosure:

No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.

ProRealTime ITF files and other attachments : How to import ITF files into ProRealTime platform?

PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials

  1. Ciccarelli Franco • 12 hours ago #

    Non si carica

  2. yas • 9 hours ago #

    getting showtrend error undefined variable

  3. MaoRai54 • 7 hours ago #

    Anche a me non si carica e poi manca definizione di variabile SHOWTREND

  4. Iván • 7 hours ago #

    Sorry.
    You should add new line after line 21.

    showtrend=1

    // ——————————————————
    //PRC_Zone Shift [ChartPrime]
    //version = 1
    //06.11.2025
    //Iván González @ http://www.prorealcode.com
    //Sharing ProRealTime knowledge
    // ——————————————————
    // inputs
    // ——————————————————
    per = 100 // Length 60-200 / minval = 60, maxval = 200
    if per >200 then
    length=200
    elsif per <60 then
    length=60
    else
    length=per
    endif
    colorCandles=1
    showsignals=1
    showcloud=1
    showlevel=1
    showtrend=1
    UPcolorR=100
    UPcolorG=200
    UPcolorB=200
    DNcolorR=200
    DNcolorG=200
    DNcolorB=100
    atr=averagetruerange[14](close)
    // ——————————————————
    // Indicator calculations
    // ——————————————————
    once trend = 0
    once trendStart = 0
    once lastRetest = 0

    ema= average[length,1](close)
    hma= average[max(20,length-40),8](close)
    dist=average[200](high-low)
    mid = (ema+hma)/2
    itop = mid+dist
    ibot = mid-dist

    if low > itop and low[1] < itop[1] and not trend then
    drawsegment(trendStartidx,trendStart,barindex,trendStart)style(dottedline)coloured(“grey”,255*showlevel)
    trend=1
    trendStart=low
    trendStartidx=barindex
    r=UPcolorR
    g=UPcolorG
    b=UPcolorB
    endif

    if high < ibot and high[1] > ibot[1] and trend then
    drawsegment(trendStartidx,trendStart,barindex,trendStart)style(dottedline)coloured(“grey”,255*showlevel)
    trend=0
    trendStart=high
    trendStartidx=barindex
    r=DNcolorR
    g=DNcolorG
    b=DNcolorB
    endif

    // Retest TrendStart Level

    if (close > trendStart and close[1] < trendStart or low > trendStart and low[1] <trendStart) and trend and barindex-lastRetest>5 then
    lastRetest=barindex
    drawtext(“⯁”,barindex,low-0.2*atr)coloured(r,g,b,255*showsignals)
    endif

    if (close[1]>trendStart and close<trendStart or high[1]>trendStart and high<trendStart) and not trend and barindex-lastRetest>5 then

    lastRetest=barindex
    drawtext(“⯁”,barindex,high+0.2*atr)coloured(r,g,b,255*showsignals)
    endif

    if islastbarupdate then
    drawsegment(trendStartidx,trendStart,barindex,trendStart)style(dottedline)coloured(“grey”,255*showlevel)
    endif
    // ——————————————————
    // PLOT
    // ——————————————————
    if showtrend then
    drawrectangle(barindex,5,barindex+1,15)anchor(bottom,index,yshift)coloured(r,g,b,0)fillcolor(r,g,b)
    endif
    colorbetween(itop,ibot,r,g,b,95*showcloud)
    // ——————————————————
    return mid as “Middle”style(dottedline), itop as “Top”, ibot as “Bottom”

avatar
Register or

Likes

avatar
Related users ' posts
MaoRai54 dear Ivan, it seems to be very interesting but please clarify what are all the lines I see i...
Iván Hi! you have the answer in the last line of code... MacdMiddle as "histo" style(histogra...
kats Le Top , a utiliser avec le nuage violet et alerte TN pour plus de précision.
Iván Hi! yes. You can ask for it here: https://www.prorealcode.com/free-code-conversion/
roccafragius Thank you so much Ivan! I created this request in english Translate from TradingView Indicat...
ipbvba Hello, Is it possible to have a screener for the various buy and sell signals?
Regisnew très bel indicateur merci
Jean2139 Bonjour Yvan, Merci pour ton indicateur que je trouve très intéressant. Je suppose que tu ...
Suffi Hier eine kleine Korrektur: //-----Inputs-----------------------------------------// MALengt...
kats Bonjour, J'ai une question etes vous trader? Je m'explique , j'ai téléchargé tous les indi...
Faisalx Hola Ivan. Thanks for your great job. I would appreciate if you have look at my request http...
roccafragius Thank you for all these useful information!! Very great job Ivan! THank you so much
geroniman Merci Ivan, super travail. On peut toujours compter sur toi pour apporter des innovations su...
Stenozar Ciao IVAN , mi da errore per la riga 49 "print tema low"; puoi suggerirmi la modifica da met...
Iván Avete provato a scaricare il file .itf?
AndyB72 Caricato ora sulla V12, nessun errore.
Iván Allora crei un nuovo post. Lo aspetterò.
Stenozar Ciao Ivan, ho inserito il post con la richiesta di traduzione. Se puoi vedere, grazie!
Iván perfect!
kats BONSOIR c bon merci j ai trouve ce weekend merci de votre reponse cdlt
the_giorgio Hi, nice work I would like to understand something about prorealtime code. With your ...
Iván Hello. When you use the drawcandle() instruction then in the configuration window you add ...
Gaspare Ciao Ivan si puo' inserire una strategia su questo indicatore per ottimizzare le variabil...
Iván
2 years ago
Iván Si lo descargas e importas en tu PRT verás que se han creado las variables para luego config...
WhyAskOZ Hi, Ivan As always you are doing great coding. The code works on my PRT, however the issu...
Iván You can delete in the last line (return) the configuration for color. Delete coloured(xx,xx,...
Bernard13 (Je réécris mon commentaire -français- en français car certains mots ne correspondaient pas ...
Iván 1000 indicateurs !!! brutaux
Iván Gracias! Para el screener sólo tienes que copiar el indicador y poner como condición de búsq...
Lean Muchas gracias Iván, ya lo he podido crear.
bertoluce Hello Ivan, thank you very much for the indicator. An observation: would it be possible (and...
Doddge Hola Iván, ¿sería posible crear un screener que indique cuándo las velas coloreadas del indi...
RTR Ivan thank you for the pro-screener. I a trying to understand how to write the signals from ...
Iván Hi, Lines 62 and 63. These lines define buy and sell conditions.
Iván Hi You should delete from the indicator code all drawing functions and all variables not us...
Iván I've created a screener to show [longcondition or shortcondition]
Chrisinobi Hallo Ivan, Danke das ist Perfekt !! Kannst du bitte in der Screener-Bibliothek die itf. hoc...
MaoRai54 Thanks, now it's OK. in your first code at line 15-16 it's missing.
Madrosat Hello Ivan Did you try a strategy with this indicator
Iván Hi. No I didn't. This is a code translation requested by an user a few days ago.
Iván
2 years ago
cjr30 Simplemente modifica las lineas 19 y 21 por las siguientes: drawtext("▲",barindex,low-0.1*a...
groelandes Gracias!!
WhyAskOZ i copied the code into strategy and it gives error on line 21 and 23. it says " Line 1: ...
Iván
2 years ago
Madrosat Hello Ivan You have interesting topics on indicators , smart supertrend, optimised trend t...
Iván Hi! thanks. All of these codes are translations requested in the forum. I've on mind to back...
Raspete01 Buenos días Iván, estoy intentando llevar el código eliminando los colores y pasando un Back...
Iván
2 years ago
winnie37 Hi Ivan, if i want to use it, and call the oscillator value (in grey, green or red), how to...
Iván The oscillator is smoothtype. In inputs there is de lag to configure the output
ARLEQUIN49 Hello Ivan, Would it be possible to convert the code of this QQE MOD indicator which accomp...
ARLEQUIN49 here is the code: //@version=4 //By Glaz, Modified // study("QQE MOD") RSI_Period = i...
Iván Hi, Yes I can translate it but please, create a new topic for it.

Top