Peek+ Indicator for reversals

Category: Indicators By: Nicolas Created: May 19, 2026, 11:44 AM
May 19, 2026, 11:44 AM
Indicators
0 Comments

The indicator uses HighestBars and LowestBars to locate how many bars ago the highest high or lowest low occurred within a lookback window (bb). From there it builds two streak counters, one for bullish runs and one for bearish runs. When a streak reaches a configurable threshold and a new extreme is set, a histogram bar fires to highlight the event.

There are a few parameters to tune the behavior:

  • bb (default 100): the lookback window in bars for finding highs and lows
  • modeHL (default 1): use High/Low prices (1) or Close prices (0)
  • strictMode (default 1): when active, the opposite side must also be relatively quiet before a signal fires, which filters out noisier setups
  • bbThr (default 0.5): minimum streak length required to trigger, expressed as a ratio of bb
  • bbMin (default 0.1): in strict mode, the opposite streak must be below this ratio of bb

 

If you are familiar with the Aroon indicator, you will notice the underlying mechanics are quite similar. Aroon Up and Aroon Down both measure how many periods have passed since the last highest high or lowest low, normalised over the lookback period, which is exactly what hhOff and llOff do here. The key difference is what each indicator does with that information. Aroon simply scales those distances into a 0-100 oscillator and lets you compare the two lines directly to assess trend direction. Peek+ goes a step further: it accumulates a streak score over time, applies a minimum threshold, and only fires a signal when a new extreme is set after a prolonged run in that direction. The strict mode adds another filter that Aroon does not have, requiring the opposite side to have been quiet. So while both tools share the same root calculation, Peek+ is more selective and event-driven, where Aroon is continuous and comparative.

The indicator returns six series on the sub-chart: the Up streak and Dn streak lines, peek dots (histograms visible only at the exact peak bar), and the signal histograms in green for bullish peeks and orange for bearish ones.

// Peek+ Indicator - ProRealTime conversion
// Original by IonOne (MQL4)
// Detects "peek" moments: bars where a sustained new high/low streak peaks
// after being untouched for a long time (bb bars)
// https://www.prorealcode.com
// Nicolas @ ProRealCode

// Parameters (editable via indicator settings)
bb = 100       // Bars back for highest/lowest lookup
modeHL = 1     // 1 = use High/Low extremes, 0 = use Close
strictMode = 1 // 1 = strict: opposite side must be below bbMin
bbThr = 0.5    // Threshold ratio [0..1]: streak must be >= bb*bbThr to trigger
bbMin = 0.1    // Minima ratio [0..1]: other side must be < bb*bbMin (strict only)

// ---- Find how many bars ago the highest/lowest occurred (within bb bars, starting 1 bar ago) ----
// HighestBars[bb](high[1]) returns offset from bar[1], +1 gives offset from current bar
IF modeHL THEN
   hhOff = HighestBars[bb](high[1]) + 1
   llOff = LowestBars[bb](low[1]) + 1
ELSE
   hhOff = HighestBars[bb](close[1]) + 1
   llOff = LowestBars[bb](close[1]) + 1
ENDIF

// ---- maDn: bearish streak counter (how long since last new high) ----
// Resets and grows when new high was 1 bar ago (hhOff == 1)
// Otherwise counts down from bb based on distance to last high
IF hhOff = 1 THEN
   maDn = maDn[1] + bb / 5
ELSE
   maDn = bb - (hhOff - 1)
ENDIF

// ---- maUp: bullish streak counter (how long since last new low) ----
IF llOff = 1 THEN
   maUp = maUp[1] + bb / 5
ELSE
   maUp = bb - (llOff - 1)
ENDIF

// ---- Bearish peek histogram: fires when new high peaks after long streak ----
IF hhOff = 1 AND maDn >= bb * bbThr THEN
   IF strictMode = 1 AND maUp < bb * bbMin THEN
      maDnHist = maDn
   ELSIF strictMode = 0 THEN
      maDnHist = maDn
   ELSE
      maDnHist = 0
   ENDIF
ELSE
   maDnHist = 0
ENDIF

// ---- Bullish peek histogram: fires when new low peaks after long streak ----
IF llOff = 1 AND maUp >= bb * bbThr THEN
   IF strictMode = 1 AND maDn < bb * bbMin THEN
      maUpHist = maUp
   ELSIF strictMode = 0 THEN
      maUpHist = maUp
   ELSE
      maUpHist = 0
   ENDIF
ELSE
   maUpHist = 0
ENDIF

// ---- Peek dot lines (only visible at the exact peak bar) ----
// Using 0 when not at peak keeps them flat; histogram bars at 0 are invisible
IF hhOff = 1 THEN
   maDnPeek = maDn
ELSE
   maDnPeek = 0
ENDIF

IF llOff = 1 THEN
   maUpPeek = maUp
ELSE
   maUpPeek = 0
ENDIF

RETURN maUp COLOURED(255,255,0) AS "Up streak", maDn COLOURED(255,0,0) AS "Dn streak", maUpPeek COLOURED(255,255,0) STYLE(HISTOGRAM) AS "Up peek", maDnPeek COLOURED(255,0,0) STYLE(HISTOGRAM) AS "Dn peek", maUpHist COLOURED(0,255,0) STYLE(HISTOGRAM) AS "Up signal", maDnHist COLOURED(255,165,0) STYLE(HISTOGRAM) AS "Dn signal"

Download
Filename: PRC_Peek.itf
Downloads: 14
Nicolas Legend
I created ProRealCode because I believe in the power of shared knowledge. I spend my time coding new tools and helping members solve complex problems. If you are stuck on a code or need a fresh perspective on a strategy, I am always willing to help. Welcome to the community!
Author’s Profile

Comments

Logo Logo
Loading...