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

    Non si carica

  2. yas • 15 hours ago #

    getting showtrend error undefined variable

  3. MaoRai54 • 14 hours ago #

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

  4. Iván • 14 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
avatar
Anonymous Hi robertogozzi - thank you very much for sharing this strategy. I have performed various ...
robertogozzi Thank you samsampop.
Dotan Hello guys I really appreciate this coding effort but can I use this code for Mt5 Forex Trad...
LucioleLucide Clean view, thanks for sharing
dertopen hi where i can found the window for candle configuration?
paolosab69 Ciao! . I have seen the pictures that explain this metod but i don't understand when is mome...
coscar Ottimo lavoro. come sempre!
luxrun Nello studio di Sepiashvili viene descritto anche un altro indicatore, il Q-indicator, che è...
Maik2404 wie kann ich den Code bekommen Paul?
jens_kittner Works with US Crude at 1h as well!
Jean-Claude REGIS Je préconise de regarder les graphiques H1 et M15 pour visualiser la tendance de fond et d'...
capgros Bonjour @Nicolas, Thanks a lot for this tool, it is very useful for me. I would like to s...
Hans63 Would you add the possibility to color also the Heikin Ashi and bar chart?
Nicolas That's possible, please open a new topic in the indicator forum explaining what you need exa...
Nicolas
7 years ago
BSTrend
v10.3
BSTrend
10
Indicators
Florian Legeard C’est à dire sur le prix et non sur le temps ? Merci
Rohit82189 bstrend repaints
Nicolas No, it doesn't repaint.
XXXXVII Excellent indicateur ! Déterminer une tendance est devenu un jeu d'enfants ! Félicitation......
gregoire bonjour nicolas j ai cherché partout sur le net et impossible de trouvé ce que je recherch...
Nicolas Merci de poster une demande dans le forum des indicateurs, ainsi on pourra le coder dans ce ...
cfta Hi Fulvio, many thanks for sharing this clever indicator, much appreciated. As Pepsmile ment...
cfta Sorry adding the PRT to code didn't work in the above comment so I guess we will have to set...
juanj Something appears to be wrong with this formula as graphing t shows t to almost never be wit...
Nicolas
7 years ago
Maxime Baudin Interesting, Thank you! :)
franck-david Bonjour Nicolas , actuellement je me forme grace a vos videos tres tres bien expliques mer...
Nicolas Merci. ça n'est pas le lieu pour poser ce genre de question :) Merci d'utiliser le forum Pro...
Vonasi Discussion on this indicator/filter can be found here: https://www.prorealcode.com/topic/121...
Vonasi Forum discussion on these indicators can be found here: https://www.prorealcode.com/topic/av...
jennr29 Hi. Is it possible to convert this code to an mq4 file?
Nicolas Sorry but our website is dedicated to prorealtime programming. However, you can ask for priv...
Domenec Claro Juanjo de todas maneras en deinversoratrader.com tienes estsos osciladores evolucionad...
Dron Hola Domenec, en la descripción hablas del indicador velas de colores, no lo encuentro en la...
Domenec Hola Dron mira en el blog deinversoratrader.com en formacion indicadores ahi hay varios grat...
Geronima Ortiz I watched the video three times, but I can not put the npips parameter as a variable. I do...
Geronima Ortiz I think the video is for an old version of prorealtime, the images do not correspond at all ...
Nicolas indicator1 = CALL “PRC_StopReversal”[npips, 1] and define npips in the optimization window ...
Caribeengeek Bonjour j’avais vu que vous proposiez d’écrire des codes pour ceux qui s’y connaisse pas Mai...
Caribeengeek Les devises unité
Nicolas Merci d'utiliser le forum pour les demandes de programmation personnalisée
ullle73 nicolas, can you somehome make this to be in the background of the price chart?
jonpt88 none did that yet right?
Nicolas You can ask for a code modification on forums, please open a new topic with your request.
Toto le Heros Thanks Nicolas. I read somewhere that in the calculation, we should round the value of the A...
Nicolas aADX = round(adx[10])
bolsatrilera
8 years ago
Rainbow Oscillator
Rainbow Oscillator
1
Indicators
Maxime Baudin Interesting, thanks! Combine this indicator with the bollinger bands there is enough to make...

Top