Iván González

Institutional Swing Setup Score

Category: Indicators By: Iván González Created: November 30, 2026, 11:35 AM
November 30, 2026, 11:35 AM
Indicators
0 Comments
Institutional Swing Setup Score

Introduction

 

Before buying a stock for a swing trade, an experienced trader checks the same handful of things: is the trend healthy, is the stock building a tight base near its highs, has volatility dried up, is volume showing accumulation, is it close to breaking out. The Institutional Swing Setup Score turns that checklist into one number from 0 to 100, plotted in its own panel, with the detail of every part in a small dashboard.

It is a reading of the chart, not a trading system: it does not give entries, stops or targets. It tells you which charts deserve a closer look and when a setup is improving or falling apart.

Theory Behind the Indicator

 

The score is a weighted average of five engines, each scored from 0 to 100.

Trend (weight 15). The trend-template check: close above the 50, 150 and 200 moving averages in that order (30 points), the 200 rising over the last 20 bars (25), close above the 200 (15), close at least 30% above the 52-week low (15) and within 25% of the 52-week high (15).

Price structure (weight 10). How tight the base of the last 50 bars is (range as a percentage of its high), how close the close is to the top of the base, and how many higher swing lows in a row the stock has made (counted up to 3).

Volatility contraction (weight 10). ATR as a percentage of price below its own average, Bollinger Band width below its average, and the percent rank of ATR% over the last 126 bars: the lower the rank, the more contracted volatility is compared with its own history.

Volume and accumulation (weight 30, the highest by design). Five checks worth 20 points each: volume drying up (short volume average below 75% of the long one), more volume on up days than on down days over 20 bars (ratio above 1.3), the accumulation/distribution line above its 21-bar average, light volume on down days, and a recent up day with at least 1.5 times the average volume.

Breakout readiness (weight 20). A blend of the other engines, plus points for being near the top of the base and for a tight base whose resistance has been tested at least twice. A confirmed breakout adds a 20-point bonus: a new high of the base made with volume participation and the moving averages aligned. Without that bonus, the volatility and range expansion that comes with every breakout would pull the score down exactly when the setup triggers.

Key Features at a Glance

 

  • One composite score from 0 to 100 with bands at 80 (exceptional), 60 (good), 40 (average) and 20 (weak).
  • The line takes the colour of its band, and the background turns green above 80.
  • A dashboard with every engine, the accumulation state, the higher-low count and whether a breakout is confirmed.
  • Calibration markers: a green triangle when the score crosses above 60, a red one when it crosses below 40, and a “B” on a confirmed breakout.
  • Every weight and threshold can be changed.
  • Alert series for a significant improvement, a new accumulation phase and a confirmed breakout.

How to Read the Indicator

 

  • 80 and above: everything lines up. Trend, a tight base and accumulation. These are the charts to study first.
  • 60 to 80: a good setup with one or two weak points; the dashboard shows which.
  • Below 40: the stock is not set up for a long swing trade right now.
  • “B” marker: a fresh high of the base with real volume and an aligned trend. The breakout the base was building towards.
  • A score rising fast: the setup is improving; the “Significant Improvement” series flags a rise of more than 15 points in 5 bars.

Practical Applications

 

  • Watchlist triage: run it on a list of growth stocks and keep only those above 60 or 80.
  • Timing within a base: the score usually climbs while the base tightens and volume dries up, before the breakout itself.
  • Checking your own read: the dashboard shows which part of the setup is missing, for example a perfect trend with no accumulation.
  • Calibration: the markers show where the score crossed 60 and 40 in the past, to compare with what price did next.

Indicator Configuration

 

  • tightnessRef (default 1.0): global tightness sensitivity; higher values make the base and compression scoring stricter.
  • smaFastLen, smaMidLen, smaSlowLen (default 50, 150, 200): trend moving averages.
  • slopeLookback (default 20): bars used to tell whether the long average is rising.
  • yearLookback (default 252): 52-week high and low.
  • structLookback (default 50): base length in bars.
  • structPivotBars (default 5): bars on each side of a swing low for the higher-low count.
  • tightRangeRefPct (default 25): base width in % considered tight.
  • atrLen (default 14), volContractLookback (default 20), volPercentileLookback (default 126): volatility engine.
  • bbLen (default 20) and bbMult (default 2.0): Bollinger Bands.
  • volShortLen (default 10) and volLongLen (default 50): volume averages.
  • volDryUpFactor (default 0.75): dry-up threshold, short volume average over long.
  • volRatioLookback (default 20) and volUDThreshold (default 1.3): up/down volume ratio.
  • adlSmoothLen (default 21): accumulation/distribution line smoothing.
  • volExpansionMult (default 1.5) and participationLookback (default 5): breakout volume participation.
  • breakoutLookback (default 50), breakoutProximityPct (default 8), breakoutMinTests (default 2), breakoutConfirmBonus (default 20): breakout readiness engine.
  • wTrend, wStruct, wVolat, wVolume, wBreakout (default 15, 10, 10, 30, 20): composite weights.
  • showDashboard (default 1), dashX / dashY / dashCol: dashboard on/off and position in pixels from the top right corner of the panel.
  • alertScoreThreshold (default 80): green background from this score.
  • alertImprovementPts (default 15): points in 5 bars for the improvement series.
  • testMarkersOn (default 1), testEntryScore (default 60), testExitScore (default 40): calibration markers.

The Code

 

//---------------------------------------------------------------
// PRC_Swing Setup Score
// version = 0
// 30.11.2026
// Iván González @ www.prorealcode.com
// Author: AzeezF
// Sharing ProRealTime knowledge
//--------------------------------------------------------------------//
defparam drawonlastbaronly = true
//--------------------------------------------------------------------//
// Inputs
//--------------------------------------------------------------------//
tightnessRef = 1.0          // global tightness sensitivity (higher = stricter)
// Trend engine
smaFastLen = 50
smaMidLen = 150
smaSlowLen = 200
slopeLookback = 20          // long-term MA slope lookback (bars)
yearLookback = 252          // 52-week lookback (bars)
// Price structure engine
structLookback = 50         // base / consolidation lookback (bars)
structPivotBars = 5         // pivot low left/right bars (higher-low detection)
tightRangeRefPct = 25.0     // reference base width in % (at or below = tight)
// Volatility contraction engine
atrLen = 14
volContractLookback = 20
volPercentileLookback = 126
bbLen = 20
bbMult = 2.0
// Volume / accumulation engine
volShortLen = 10
volLongLen = 50
volDryUpFactor = 0.75       // dry-up: short volume MA below this x long volume MA
volRatioLookback = 20       // up/down volume ratio lookback (bars)
volUDThreshold = 1.3        // strong demand up/down volume ratio
adlSmoothLen = 21           // accumulation/distribution line smoothing
volExpansionMult = 1.5      // breakout participation: volume >= this x long average
participationLookback = 5   // bars a volume-thrust day stays active
// Breakout readiness engine
breakoutLookback = 50
breakoutProximityPct = 8.0
breakoutMinTests = 2
breakoutConfirmBonus = 20
// Composite weights
wTrend = 15
wStruct = 10
wVolat = 10
wVolume = 30
wBreakout = 20
// Dashboard, background and markers
showDashboard = 1
alertScoreThreshold = 80    // background highlight from this score
alertImprovementPts = 15    // "significant improvement" over 5 bars
testMarkersOn = 1           // calibration markers (not trade signals)
testEntryScore = 60
testExitScore = 40
dashX = 0 - 250             // dashboard: pixels from the right edge of the panel
dashY = 0 - 16              // dashboard: pixels from the top edge of the panel
dashCol = 120               // dashboard: distance between label and value columns
//--------------------------------------------------------------------//
// Engine 1: trend (MA alignment, long MA slope, 52-week range)
//--------------------------------------------------------------------//
smaFast = average[smaFastLen](close)
smaMid = average[smaMidLen](close)
smaSlow = average[smaSlowLen](close)
aligned = close > smaFast AND smaFast > smaMid AND smaMid > smaSlow
slowRising = smaSlow > smaSlow[slopeLookback]
hi52 = highest[yearLookback](high)
lo52 = lowest[yearLookback](low)
trendScore = 30 * aligned + 25 * slowRising + 15 * (close > smaSlow) + 15 * (close > lo52 * 1.30) + 15 * (close > hi52 * 0.75)
trendScore = max(0, min(100, trendScore))
//--------------------------------------------------------------------//
// Engine 3: price structure (base tightness, distance to the base high,
// consecutive higher pivot lows)
//--------------------------------------------------------------------//
ONCE higherLowCount = 0
ONCE nPivL = 0
llP = lowest[structPivotBars](low)
IF barindex >= 2 * structPivotBars THEN
   IF low[structPivotBars] < llP AND low[structPivotBars] <= llP[structPivotBars + 1] THEN
      prevPivotLow = lastPivotLow
      lastPivotLow = low[structPivotBars]
      nPivL = nPivL + 1
      IF nPivL > 1 THEN
         IF lastPivotLow > prevPivotLow THEN
            higherLowCount = higherLowCount + 1
         ELSE
            higherLowCount = 0
         ENDIF
      ENDIF
   ENDIF
ENDIF
baseHigh = highest[structLookback](high)
baseLow = lowest[structLookback](low)
rangePct = 0
distFromHighPct = 0
IF baseHigh <> 0 THEN
   rangePct = (baseHigh - baseLow) / baseHigh * 100
   distFromHighPct = (baseHigh - close) / baseHigh * 100
ENDIF
effTightRef = tightRangeRefPct / tightnessRef
tightnessScore = max(0, min(100, 100 - (rangePct / effTightRef) * 100))
compressionScore = max(0, min(100, 100 - (distFromHighPct / (effTightRef * 0.6)) * 100))
higherLowScore = min(higherLowCount, 3) / 3 * 100
structScore = max(0, min(100, tightnessScore * 0.40 + compressionScore * 0.30 + higherLowScore * 0.30))
//--------------------------------------------------------------------//
// Engine 4: volatility contraction (ATR% vs its average and its percent
// rank, Bollinger width vs its average)
//--------------------------------------------------------------------//
atrVal = averagetruerange[atrLen](close)
atrPct = 0
IF close <> 0 THEN
   atrPct = atrVal / close * 100
ENDIF
$atrP[barindex] = atrPct
atrContracting = atrPct < average[volContractLookback](atrPct)
// percent rank: share of the previous N values that are <= the current one
rankCnt = 0
IF barindex >= volPercentileLookback THEN
   FOR k = 1 TO volPercentileLookback DO
      IF $atrP[barindex - k] <= atrPct THEN
         rankCnt = rankCnt + 1
      ENDIF
   NEXT
ENDIF
atrPercentRank = rankCnt * 100 / volPercentileLookback
bbBasis = average[bbLen](close)
bbDev = std[bbLen](close) * bbMult
bbWidthPct = 0
IF bbBasis <> 0 THEN
   bbWidthPct = (2 * bbDev) / bbBasis * 100
ENDIF
bbContracting = bbWidthPct < average[volContractLookback](bbWidthPct)
volatScore = max(0, min(100, 30 * atrContracting + 30 * bbContracting + (100 - atrPercentRank) * 0.40))
//--------------------------------------------------------------------//
// Engine 5: volume / accumulation (dry-up, up/down volume, A/D line,
// light pullbacks, breakout participation)
//--------------------------------------------------------------------//
volSmaShort = average[volShortLen](volume)
volSmaLong = average[volLongLen](volume)
dryUp = volSmaShort < volSmaLong * volDryUpFactor
upVolSum = summation[volRatioLookback]((close > close[1]) * volume)
downVolSum = summation[volRatioLookback]((close < close[1]) * volume)
IF downVolSum > 0 THEN
   udRatio = upVolSum / downVolSum
ELSIF upVolSum > 0 THEN
   udRatio = volUDThreshold * 2
ELSE
   udRatio = 1
ENDIF
strongDemand = udRatio > volUDThreshold
hlRange = high - low
mfm = 0
IF hlRange <> 0 THEN
   mfm = ((close - low) - (high - close)) / hlRange
ENDIF
ONCE adl = 0
adl = adl + mfm * volume
adlRising = adl > average[adlSmoothLen](adl)
pullbackLight = close < close[1] AND volume < volSmaLong
relVol = 1
IF volSmaLong > 0 THEN
   relVol = volume / volSmaLong
ENDIF
bpToday = close > close[1] AND relVol >= volExpansionMult
breakoutParticipation = highest[participationLookback](bpToday) >= 1
volumeScore = 20 * dryUp + 20 * strongDemand + 20 * adlRising + 20 * pullbackLight + 20 * breakoutParticipation
//--------------------------------------------------------------------//
// Engine 6: breakout readiness (blend of the other engines, proximity to
// the base high, tests of resistance, confirmed breakout bonus)
//--------------------------------------------------------------------//
$hA[barindex] = high
nearHigh = distFromHighPct < breakoutProximityPct
tight = rangePct < tightRangeRefPct
newBaseHigh = high >= baseHigh * 0.999
testCount = 0
testFloor = baseHigh * (1 - breakoutProximityPct / 100)
FOR i = 0 TO min(breakoutLookback - 1, barindex) DO
   hi = $hA[barindex - i]
   IF hi >= testFloor AND hi < baseHigh THEN
      testCount = testCount + 1
   ENDIF
NEXT
testedResistance = testCount >= breakoutMinTests
// the four engine weights (0.20 / 0.25 / 0.15 / 0.10) are rescaled to add up to 0.90
brkScore = (trendScore * 0.20 + volumeScore * 0.25 + structScore * 0.15 + volatScore * 0.10) * 0.90 / 0.70
brkScore = brkScore + 5 * nearHigh + 5 * (tight AND testedResistance)
brkConfirmed = newBaseHigh AND breakoutParticipation AND aligned
brkScore = brkScore + breakoutConfirmBonus * brkConfirmed
breakoutScore = max(0, min(100, brkScore))
//--------------------------------------------------------------------//
// Composite setup score
//--------------------------------------------------------------------//
weightSum = wTrend + wStruct + wVolat + wVolume + wBreakout
IF weightSum = 0 THEN
   weightSum = 1
ENDIF
composite = (trendScore * wTrend + structScore * wStruct + volatScore * wVolat + volumeScore * wVolume + breakoutScore * wBreakout) / weightSum
composite = max(0, min(100, composite))
//--------------------------------------------------------------------//
// Colours by quality band
//--------------------------------------------------------------------//
ONCE warm = max(max(smaSlowLen + slopeLookback, yearLookback), max(volPercentileLookback + atrLen, max(structLookback, breakoutLookback)))
IF composite >= 80 THEN
   cR = 76
   cG = 175
   cB = 80
ELSIF composite >= 60 THEN
   cR = 0
   cG = 230
   cB = 118
ELSIF composite >= 40 THEN
   cR = 253
   cG = 216
   cB = 53
ELSIF composite >= 20 THEN
   cR = 255
   cG = 152
   cB = 0
ELSE
   cR = 242
   cG = 54
   cB = 69
ENDIF
IF barindex >= warm THEN
   lineA = 255
   IF composite >= alertScoreThreshold THEN
      BACKGROUNDCOLOR(76, 175, 80, 25)
   ENDIF
ELSE
   lineA = 0
ENDIF
//--------------------------------------------------------------------//
// Calibration markers (score crossings and confirmed breakouts), kept
// in a list and redrawn on the last bar
//--------------------------------------------------------------------//
ONCE nMk = 0
IF barindex > warm AND testMarkersOn THEN
   IF composite crosses over testEntryScore THEN
      $mkB[nMk] = barindex
      $mkT[nMk] = 1
      $mkY[nMk] = composite - 6
      nMk = nMk + 1
   ENDIF
   IF composite crosses under testExitScore THEN
      $mkB[nMk] = barindex
      $mkT[nMk] = 2
      $mkY[nMk] = composite + 6
      nMk = nMk + 1
   ENDIF
   IF brkConfirmed AND NOT brkConfirmed[1] THEN
      $mkB[nMk] = barindex
      $mkT[nMk] = 3
      $mkY[nMk] = composite - 12
      nMk = nMk + 1
   ENDIF
ENDIF
//--------------------------------------------------------------------//
// Alert series (invisible): set alerts on them in the indicator window
//--------------------------------------------------------------------//
improvement = composite - composite[5] > alertImprovementPts
accumulation = adlRising AND NOT adlRising[1]
newConfirmed = brkConfirmed AND NOT brkConfirmed[1]
//--------------------------------------------------------------------//
// Drawing on the last bar: markers and dashboard
//--------------------------------------------------------------------//
IF islastbarupdate THEN
   IF nMk > 0 THEN
      FOR m = 0 TO nMk - 1 DO
         mx = $mkB[m]
         my = $mkY[m]
         IF $mkT[m] = 1 THEN
            DRAWTEXT("▲", mx, my) COLOURED(0, 230, 118)
         ELSIF $mkT[m] = 2 THEN
            DRAWTEXT("▼", mx, my) COLOURED(242, 54, 69)
         ELSE
            DRAWTEXT("B", mx, my, sansserif, bold, 11) COLOURED(255, 152, 0)
         ENDIF
      NEXT
   ENDIF
   IF showDashboard THEN
      vComp = round(composite)
      vTrend = round(trendScore)
      vStruct = round(structScore)
      vVolat = round(volatScore)
      vVol = round(volumeScore)
      vBrk = round(breakoutScore)
      DRAWTEXT("Institutional Setup Score", dashX, dashY, sansserif, bold, 11) COLOURED(40, 40, 40) ANCHOR(topright, xshift, yshift)
      DRAWTEXT("#vComp#", dashX + dashCol, dashY, sansserif, bold, 11) COLOURED(cR, cG, cB) ANCHOR(topright, xshift, yshift)
      DRAWTEXT("Trend Quality", dashX, dashY - 18, sansserif, standard, 10) COLOURED(90, 90, 90) ANCHOR(topright, xshift, yshift)
      DRAWTEXT("#vTrend#", dashX + dashCol, dashY - 18, sansserif, bold, 10) COLOURED(60, 60, 60) ANCHOR(topright, xshift, yshift)
      DRAWTEXT("Price Structure", dashX, dashY - 36, sansserif, standard, 10) COLOURED(90, 90, 90) ANCHOR(topright, xshift, yshift)
      DRAWTEXT("#vStruct#", dashX + dashCol, dashY - 36, sansserif, bold, 10) COLOURED(60, 60, 60) ANCHOR(topright, xshift, yshift)
      DRAWTEXT("Volatility Contraction", dashX, dashY - 54, sansserif, standard, 10) COLOURED(90, 90, 90) ANCHOR(topright, xshift, yshift)
      DRAWTEXT("#vVolat#", dashX + dashCol, dashY - 54, sansserif, bold, 10) COLOURED(60, 60, 60) ANCHOR(topright, xshift, yshift)
      DRAWTEXT("Volume Quality", dashX, dashY - 72, sansserif, standard, 10) COLOURED(90, 90, 90) ANCHOR(topright, xshift, yshift)
      DRAWTEXT("#vVol#", dashX + dashCol, dashY - 72, sansserif, bold, 10) COLOURED(60, 60, 60) ANCHOR(topright, xshift, yshift)
      DRAWTEXT("Institutional Accumulation", dashX, dashY - 90, sansserif, standard, 10) COLOURED(90, 90, 90) ANCHOR(topright, xshift, yshift)
      IF adlRising THEN
         DRAWTEXT("Yes", dashX + dashCol, dashY - 90, sansserif, bold, 10) COLOURED(76, 175, 80) ANCHOR(topright, xshift, yshift)
      ELSE
         DRAWTEXT("No", dashX + dashCol, dashY - 90, sansserif, bold, 10) COLOURED(242, 54, 69) ANCHOR(topright, xshift, yshift)
      ENDIF
      DRAWTEXT("Breakout Readiness", dashX, dashY - 108, sansserif, standard, 10) COLOURED(90, 90, 90) ANCHOR(topright, xshift, yshift)
      DRAWTEXT("#vBrk#", dashX + dashCol, dashY - 108, sansserif, bold, 10) COLOURED(60, 60, 60) ANCHOR(topright, xshift, yshift)
      DRAWTEXT("Higher-Low Count", dashX, dashY - 126, sansserif, standard, 10) COLOURED(90, 90, 90) ANCHOR(topright, xshift, yshift)
      DRAWTEXT("#higherLowCount#", dashX + dashCol, dashY - 126, sansserif, bold, 10) COLOURED(60, 60, 60) ANCHOR(topright, xshift, yshift)
      DRAWTEXT("Breakout Confirmed", dashX, dashY - 144, sansserif, standard, 10) COLOURED(90, 90, 90) ANCHOR(topright, xshift, yshift)
      IF brkConfirmed THEN
         DRAWTEXT("Yes", dashX + dashCol, dashY - 144, sansserif, bold, 10) COLOURED(76, 175, 80) ANCHOR(topright, xshift, yshift)
      ELSE
         DRAWTEXT("No", dashX + dashCol, dashY - 144, sansserif, bold, 10) COLOURED(242, 54, 69) ANCHOR(topright, xshift, yshift)
      ENDIF
   ENDIF
ENDIF
RETURN composite COLOURED(cR, cG, cB, lineA) STYLE(line, 2) AS "Composite Setup Score", 80 COLOURED(76, 175, 80, 100) STYLE(dottedline, 1) AS "Exceptional (80)", 60 COLOURED(0, 230, 118, 100) STYLE(dottedline, 1) AS "Good (60)", 40 COLOURED(253, 216, 53, 100) STYLE(dottedline, 1) AS "Average (40)", 20 COLOURED(242, 54, 69, 100) STYLE(dottedline, 1) AS "Weak (20)", volumeScore COLOURED(0, 0, 0, 0) AS "Volume Score", breakoutScore COLOURED(0, 0, 0, 0) AS "Breakout Readiness", improvement COLOURED(0, 0, 0, 0) AS "Significant Improvement", accumulation COLOURED(0, 0, 0, 0) AS "New Accumulation Phase", newConfirmed COLOURED(0, 0, 0, 0) AS "Breakout Confirmed"

Original author: AzeezF, published open source.

Download
Filename: PRC_Swing-Setup-Score.itf
Downloads: 13
Iván González
Iván González Legend
Developer by day, aspiring writer by night. Still compiling my bio... Error 404: presentation not found.
Author’s Profile

Comments

ProRealCode ProRealCode
Loading...