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 • 17 hours ago #

    Non si carica

  2. yas • 14 hours ago #

    getting showtrend error undefined variable

  3. MaoRai54 • 13 hours ago #

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

  4. Iván • 12 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
Vonasi There are actually two ways to calculate standard deviations and I seem to have used the ver...
segie Can something similar be done with Supertrends?
Vonasi Not sure I fully understand what you are asking for. Are you asking for MTF Supertrend level...
Kris75 very interesting; thanks !
ribes65 Bonjour Nicolas, Merci pour votre travail. Est-il envisageable de créer un screener pour ...
Nicolas Bien sûr, merci de formuler une demande dans le forum des screeners pour prorealtime. En res...
ipbvba Est il possible de le transformer en indicateur (pour ne plus avoir les lignes mais uniqueme...
Rory Dryden Thank you. Experimenting with it now.
Wolf Hi Vonasi. Thank for this indicator. I like this calculate concept. I think that line 16 thi...
Vonasi Well spotted! It is just a safety check to ensure that no value below 1 can be used otherwis...
supertiti Bonjour Nicolas, Je ne comprend pas bien , le trend change de couleur quand les prix sont a...
Nicolas Oui ce serait possible, cependant l'indicateur est bien prévu pour conserver la couleur de l...
supertiti Quand tu pourras si tu peux nous coder la troisième couleur cela améliorerait les trades cou...
Nicolas How to import file page: in the help section of the website explains howto
kenssa import through the indicator page/window in the Proreal time
chicoteca Buenas, no consigo que se me muestre en el chart de DAX. ¿Cómo procedo? Gracias.-
Ciccarelli Franco Per lasciare che la strategia venga eseguita (dopo aver importato il file): Basta eliminare...
JADINVEST Hello Jan, hello everyone, Thanks Jan for this strategy! Since 2020, have any of you found a...
Alessandro Furlani Hi Ian, hope you still use PRT and so you can read this post. I have tested a lot your work ...
Stockastiss Can this code be simply transferred into Backtestingcode so one doesnt need to use call ? (i...
Vonasi Sorry for the late reply. Add the code to your strategy and remove line 5 and line 39. Chang...
viktorthunss Hi! How many averages are there? Can I see the somewhere?
leofi https://www.prorealcode.com/topic/simple-average-with-visual-color/
leofi Go visit www.prorealcode.com/topic/simple-average-with-visual-color/ and watch 2em post
Dritan Hi,I am new on Prorealtime and coding.I downloaded the indi but I have it on a separate wind...
Marie-Eve Vergoz Bonsoir - Voici l'erreur qui est signalée lorsque je souhaite utiliser cet indicateur : il...
Om Hello, thanks for sharing! Getting a message that Variable P is undefined?
matin Intraday Average Volume Indicator Not working, what can i do plz
Nicolas Just add it on the price series.
yomisadiku Hello Nicolas, Can I use high and low price at lines hh=max(hh,close) and ll=min(ll,close) ...
Nicolas Yes you can do that, the impact will be that the trailing stop line will be much close to th...
Byggtrader Hi Nicolas! How do I get the indicator in the price chart? It only stays under i new chart.
Nicolas Just add it on the price chart by using the wrench on the left upper side of the chart (pric...
Dom Hello, hello....je commence le trading et découvre par la même occasion le codage....et ce n...
Nicolas Merci, ça fait plaisir !
Be-n Bonjour tout le monde ! Dans l'indicateur de tendance, j'ai du mal à saisir la nuance entre ...
Vonasi Sure that is possible. I will code it and make a post in the English ProBuilder forum and pu...
Vonasi Vama v2 with Hull moving average included can be found here: https://www.prorealcode.com/top...
JMat45 Thank you, Vonasi.
Globalmarkets79 Thank you Vonasi for the answer. I have an other question. When i tried to run the indicator...
Vonasi Lines is either 0 or 1 to turn on or off the drawing of them. Once again if you download and...
Globalmarkets79 Thank you Vonasi, this indicator is very helpful!!!
Nicolas
6 years ago
Bateson Merci pour la réponse Nicolas. C'est bien ce que j'ai fait mais ça ne fonctionne toujours pa...
Enzo Paliotti Veramente ottimo, era quello che cercavo, si potrebbe modificare inserendo come variazione a...
Nicolas Perché no, chiedetelo con una descrizione dettagliata nel forum degli indicatori, per favore!
jiddan78 how to convert to afl amibroker ?
Nicolas We do not supply free coding assistance for AFL Amibroker on the website. You can ask for pa...
Ngomsi @ Vonasi, how to use timeframe , 13 minutes ,21 minutes, 34 minutes,et 55 minutes with this...
manchokcity can we have it in mql4 platform? or how or which platform do we use it?
camporan I don't use MetaTrader so I won't be able to do the translation myself. Sorry!
Alexander9 This can for amibroker ? . Thanks
riz001 thnk u
geroniman bonjour Nicolas, j ai un indicateur le Tiger . J aiemrai placer des fleches buy et sell dire...
Nicolas Merci de formuler les demandes sur le forum. ça n'est pas le bon endroit et hors sujet ici ! ;)

Top