Support and Resistance -- Touch Strength Score For ThinkOrSwim

Clark2001

New member
Screenshot 2025-10-12 225044.png


Hello everyone, I was working on another project with support and resistance so I thought I share it. Again my knowledge in thinkscript isn't extensive by any means but I do have enough understanding to piece the logic together For this used I used ChatGBT to aid me in process and I was honestly surprised by how much it could do. Of course I had to tweak a bit of the logic here and there cause ChatGBT wasn't entirely understanding my process at first...but it worked out well and I had fun doing it. Please feel free to provide any feedback or adjustments!

Code:
# ============================================================
# Supp_Resis_Strength_By_Touch_Count
# Clark2001
# Script logic and optimization aided by ChatGPT (OpenAI)
# ============================================================

declare upper;

input n = 18;  # Pivot Width —
               # how many candles are checked on each side to confirm a pivot high/low.
               # Smaller = more lines (sensitive), larger = fewer but stronger levels.

input maxLevelsEach = 8;  # Maximum Levels per Side — how many recent support and resistance levels
                          # to keep visible on the chart (1–10 recommended).

# ------------------------
# Strength Calculation
# ------------------------
input useWholeChartForStrength = yes;  # Touch Count Method — if "yes", counts all touches across the entire chart.
                                       # If "no", uses only the number of bars defined below (lookback window).

input touchLookbackBars = 120;  # Touch Lookback — how many bars (candles) to check for touches
                                # when not using the full chart. For 1-minute charts:
                                # 60 = ~1 hour, 390 = ~1 trading day.

input touchTicks = 2;  # Touch Tolerance — how close price must come
                         #(in ticks) to count as a "touch".
                       # Increase if lines feel too strict; lower for tighter accuracy.

input minScoreToShow = 1.0;  # Minimum Touches to Display — hides levels touched fewer times than this threshold.
                             # For example: 1.0 = show all; 2.0 = only show levels hit at least twice.

# ------------------------
# Zone Display
# ------------------------
input showZones = yes;  # Show/Hide Zones — toggle visibility of the shaded support/resistance areas (clouds).

input zoneTicks = 2;  # Zone Thickness — half the width of each zone in ticks (2 = +/- 2 ticks from line).

input showBaseLines = yes;  # Show/Hide Lines — toggles visibility of the main S/R lines.

# Visuals (use GlobalColor for TOS compatibility)
DefineGlobalColor("BaseLine",      Color.GRAY);     # normal lines
DefineGlobalColor("StrongLine",    Color.YELLOW);   # strongest lines
DefineGlobalColor("BaseResZone",   Color.GRAY);     # resistance zones (base)
DefineGlobalColor("BaseSupZone",   Color.GRAY);     # support zones (base)
DefineGlobalColor("StrongResZone", Color.YELLOW);   # strongest zone (R)
DefineGlobalColor("StrongSupZone", Color.YELLOW);   # strongest zone (S)

input baseLineWeight             = 2;
input strongestLineWeight        = 5;

# Optional debug
input showTouchBubbles           = no;     # show bubbles where touches were counted
input showScoreLabels            = no;     # show strongest scores label

#---------------------
# Helpers
#---------------------
def x       = BarNumber();
def lastBar = x == HighestAll(x);
def tol     = touchTicks * TickSize();
def z       = zoneTicks  * TickSize();

#---------------------
# Pivots (classic)
#---------------------
def hh = fold i = 1 to n + 1 with p = 1 while p do high > GetValue(high, -i);
def ll = fold j = 1 to n + 1 with q = 1 while q do low  < GetValue(low,  -j);

def PivotH = if x > n and high == Highest(high, n) and hh then high else Double.NaN;
def PivotL = if x > n and low  == Lowest(low,  n) and ll then low  else Double.NaN;

def PHBar  = if !IsNaN(PivotH) then x else PHBar[1];
def PLBar  = if !IsNaN(PivotL) then x else PLBar[1];

def newPH  = !IsNaN(PivotH);
def newPL  = !IsNaN(PivotL);

#---------------------
# Keep last 10 levels per side (shift registers)
#---------------------
def R1V  = CompoundValue(1, if newPH then PivotH else R1V[1],  Double.NaN);
def R1B  = CompoundValue(1, if newPH then PHBar  else R1B[1],  Double.NaN);
def R2V  = CompoundValue(1, if newPH then R1V[1] else R2V[1],  Double.NaN);
def R2B  = CompoundValue(1, if newPH then R1B[1] else R2B[1],  Double.NaN);
def R3V  = CompoundValue(1, if newPH then R2V[1] else R3V[1],  Double.NaN);
def R3B  = CompoundValue(1, if newPH then R2B[1] else R3B[1],  Double.NaN);
def R4V  = CompoundValue(1, if newPH then R3V[1] else R4V[1],  Double.NaN);
def R4B  = CompoundValue(1, if newPH then R3B[1] else R4B[1],  Double.NaN);
def R5V  = CompoundValue(1, if newPH then R4V[1] else R5V[1],  Double.NaN);
def R5B  = CompoundValue(1, if newPH then R4B[1] else R5B[1],  Double.NaN);
def R6V  = CompoundValue(1, if newPH then R5V[1] else R6V[1],  Double.NaN);
def R6B  = CompoundValue(1, if newPH then R5B[1] else R6B[1],  Double.NaN);
def R7V  = CompoundValue(1, if newPH then R6V[1] else R7V[1],  Double.NaN);
def R7B  = CompoundValue(1, if newPH then R6B[1] else R7B[1],  Double.NaN);
def R8V  = CompoundValue(1, if newPH then R7V[1] else R8V[1],  Double.NaN);
def R8B  = CompoundValue(1, if newPH then R7B[1] else R8B[1],  Double.NaN);
def R9V  = CompoundValue(1, if newPH then R8V[1] else R9V[1],  Double.NaN);
def R9B  = CompoundValue(1, if newPH then R8B[1] else R9B[1],  Double.NaN);
def R10V = CompoundValue(1, if newPH then R9V[1] else R10V[1], Double.NaN);
def R10B = CompoundValue(1, if newPH then R9B[1] else R10B[1], Double.NaN);

def S1V  = CompoundValue(1, if newPL then PivotL else S1V[1],  Double.NaN);
def S1B  = CompoundValue(1, if newPL then PLBar  else S1B[1],  Double.NaN);
def S2V  = CompoundValue(1, if newPL then S1V[1] else S2V[1],  Double.NaN);
def S2B  = CompoundValue(1, if newPL then S1B[1] else S2B[1],  Double.NaN);
def S3V  = CompoundValue(1, if newPL then S2V[1] else S3V[1],  Double.NaN);
def S3B  = CompoundValue(1, if newPL then S2B[1] else S3B[1],  Double.NaN);
def S4V  = CompoundValue(1, if newPL then S3V[1] else S4V[1],  Double.NaN);
def S4B  = CompoundValue(1, if newPL then S3B[1] else S4B[1],  Double.NaN);
def S5V  = CompoundValue(1, if newPL then S4V[1] else S5V[1],  Double.NaN);
def S5B  = CompoundValue(1, if newPL then S4B[1] else S5B[1],  Double.NaN);
def S6V  = CompoundValue(1, if newPL then S5V[1] else S6V[1],  Double.NaN);
def S6B  = CompoundValue(1, if newPL then S5B[1] else S6B[1],  Double.NaN);
def S7V  = CompoundValue(1, if newPL then S6V[1] else S7V[1],  Double.NaN);
def S7B  = CompoundValue(1, if newPL then S6B[1] else S7B[1],  Double.NaN);
def S8V  = CompoundValue(1, if newPL then S7V[1] else S8V[1],  Double.NaN);
def S8B  = CompoundValue(1, if newPL then S7B[1] else S8B[1],  Double.NaN);
def S9V  = CompoundValue(1, if newPL then S8V[1] else S9V[1],  Double.NaN);
def S9B  = CompoundValue(1, if newPL then S8B[1] else S9B[1],  Double.NaN);
def S10V = CompoundValue(1, if newPL then S9V[1] else S10V[1], Double.NaN);
def S10B = CompoundValue(1, if newPL then S9B[1] else S10B[1], Double.NaN);

#---------------------
# Full-width constant broadcast (so every line spans the screen)
#---------------------
def R1_c  = HighestAll( if lastBar and !IsNaN(R1V)  then R1V  else Double.NaN );
def R2_c  = HighestAll( if lastBar and !IsNaN(R2V)  then R2V  else Double.NaN );
def R3_c  = HighestAll( if lastBar and !IsNaN(R3V)  then R3V  else Double.NaN );
def R4_c  = HighestAll( if lastBar and !IsNaN(R4V)  then R4V  else Double.NaN );
def R5_c  = HighestAll( if lastBar and !IsNaN(R5V)  then R5V  else Double.NaN );
def R6_c  = HighestAll( if lastBar and !IsNaN(R6V)  then R6V  else Double.NaN );
def R7_c  = HighestAll( if lastBar and !IsNaN(R7V)  then R7V  else Double.NaN );
def R8_c  = HighestAll( if lastBar and !IsNaN(R8V)  then R8V  else Double.NaN );
def R9_c  = HighestAll( if lastBar and !IsNaN(R9V)  then R9V  else Double.NaN );
def R10_c = HighestAll( if lastBar and !IsNaN(R10V) then R10V else Double.NaN );

def S1_c  = HighestAll( if lastBar and !IsNaN(S1V)  then S1V  else Double.NaN );
def S2_c  = HighestAll( if lastBar and !IsNaN(S2V)  then S2V  else Double.NaN );
def S3_c  = HighestAll( if lastBar and !IsNaN(S3V)  then S3V  else Double.NaN );
def S4_c  = HighestAll( if lastBar and !IsNaN(S4V)  then S4V  else Double.NaN );
def S5_c  = HighestAll( if lastBar and !IsNaN(S5V)  then S5V  else Double.NaN );
def S6_c  = HighestAll( if lastBar and !IsNaN(S6V)  then S6V  else Double.NaN );
def S7_c  = HighestAll( if lastBar and !IsNaN(S7V)  then S7V  else Double.NaN );
def S8_c  = HighestAll( if lastBar and !IsNaN(S8V)  then S8V  else Double.NaN );
def S9_c  = HighestAll( if lastBar and !IsNaN(S9V)  then S9V  else Double.NaN );
def S10_c = HighestAll( if lastBar and !IsNaN(S10V) then S10V else Double.NaN );

#---------------------
# Scoring by touches  (NO dynamic Sum length anywhere)
#---------------------
def hitR1  = if IsNaN(R1_c)  then 0 else if (AbsValue(high - R1_c)  <= tol) or (AbsValue(low - R1_c)  <= tol)  then 1 else 0;
def hitR2  = if IsNaN(R2_c)  then 0 else if (AbsValue(high - R2_c)  <= tol) or (AbsValue(low - R2_c)  <= tol)  then 1 else 0;
def hitR3  = if IsNaN(R3_c)  then 0 else if (AbsValue(high - R3_c)  <= tol) or (AbsValue(low - R3_c)  <= tol)  then 1 else 0;
def hitR4  = if IsNaN(R4_c)  then 0 else if (AbsValue(high - R4_c)  <= tol) or (AbsValue(low - R4_c)  <= tol)  then 1 else 0;
def hitR5  = if IsNaN(R5_c)  then 0 else if (AbsValue(high - R5_c)  <= tol) or (AbsValue(low - R5_c)  <= tol)  then 1 else 0;
def hitR6  = if IsNaN(R6_c)  then 0 else if (AbsValue(high - R6_c)  <= tol) or (AbsValue(low - R6_c)  <= tol)  then 1 else 0;
def hitR7  = if IsNaN(R7_c)  then 0 else if (AbsValue(high - R7_c)  <= tol) or (AbsValue(low - R7_c)  <= tol)  then 1 else 0;
def hitR8  = if IsNaN(R8_c)  then 0 else if (AbsValue(high - R8_c)  <= tol) or (AbsValue(low - R8_c)  <= tol)  then 1 else 0;
def hitR9  = if IsNaN(R9_c)  then 0 else if (AbsValue(high - R9_c)  <= tol) or (AbsValue(low - R9_c)  <= tol)  then 1 else 0;
def hitR10 = if IsNaN(R10_c) then 0 else if (AbsValue(high - R10_c) <= tol) or (AbsValue(low - R10_c) <= tol) then 1 else 0;

def hitS1  = if IsNaN(S1_c)  then 0 else if (AbsValue(high - S1_c)  <= tol) or (AbsValue(low - S1_c)  <= tol)  then 1 else 0;
def hitS2  = if IsNaN(S2_c)  then 0 else if (AbsValue(high - S2_c)  <= tol) or (AbsValue(low - S2_c)  <= tol)  then 1 else 0;
def hitS3  = if IsNaN(S3_c)  then 0 else if (AbsValue(high - S3_c)  <= tol) or (AbsValue(low - S3_c)  <= tol)  then 1 else 0;
def hitS4  = if IsNaN(S4_c)  then 0 else if (AbsValue(high - S4_c)  <= tol) or (AbsValue(low - S4_c)  <= tol)  then 1 else 0;
def hitS5  = if IsNaN(S5_c)  then 0 else if (AbsValue(high - S5_c)  <= tol) or (AbsValue(low - S5_c)  <= tol)  then 1 else 0;
def hitS6  = if IsNaN(S6_c)  then 0 else if (AbsValue(high - S6_c)  <= tol) or (AbsValue(low - S6_c)  <= tol)  then 1 else 0;
def hitS7  = if IsNaN(S7_c)  then 0 else if (AbsValue(high - S7_c)  <= tol) or (AbsValue(low - S7_c)  <= tol)  then 1 else 0;
def hitS8  = if IsNaN(S8_c)  then 0 else if (AbsValue(high - S8_c)  <= tol) or (AbsValue(low - S8_c)  <= tol)  then 1 else 0;
def hitS9  = if IsNaN(S9_c)  then 0 else if (AbsValue(high - S9_c)  <= tol) or (AbsValue(low - S9_c)  <= tol)  then 1 else 0;
def hitS10 = if IsNaN(S10_c) then 0 else if (AbsValue(high - S10_c) <= tol) or (AbsValue(low - S10_c) <= tol) then 1 else 0;

def cumR1  = CompoundValue(1, cumR1[1]  + hitR1,  hitR1);
def cumR2  = CompoundValue(1, cumR2[1]  + hitR2,  hitR2);
def cumR3  = CompoundValue(1, cumR3[1]  + hitR3,  hitR3);
def cumR4  = CompoundValue(1, cumR4[1]  + hitR4,  hitR4);
def cumR5  = CompoundValue(1, cumR5[1]  + hitR5,  hitR5);
def cumR6  = CompoundValue(1, cumR6[1]  + hitR6,  hitR6);
def cumR7  = CompoundValue(1, cumR7[1]  + hitR7,  hitR7);
def cumR8  = CompoundValue(1, cumR8[1]  + hitR8,  hitR8);
def cumR9  = CompoundValue(1, cumR9[1]  + hitR9,  hitR9);
def cumR10 = CompoundValue(1, cumR10[1] + hitR10, hitR10);

def cumS1  = CompoundValue(1, cumS1[1]  + hitS1,  hitS1);
def cumS2  = CompoundValue(1, cumS2[1]  + hitS2,  hitS2);
def cumS3  = CompoundValue(1, cumS3[1]  + hitS3,  hitS3);
def cumS4  = CompoundValue(1, cumS4[1]  + hitS4,  hitS4);
def cumS5  = CompoundValue(1, cumS5[1]  + hitS5,  hitS5);
def cumS6  = CompoundValue(1, cumS6[1]  + hitS6,  hitS6);
def cumS7  = CompoundValue(1, cumS7[1]  + hitS7,  hitS7);
def cumS8  = CompoundValue(1, cumS8[1]  + hitS8,  hitS8);
def cumS9  = CompoundValue(1, cumS9[1]  + hitS9,  hitS9);
def cumS10 = CompoundValue(1, cumS10[1] + hitS10, hitS10);

def R1_s  = if useWholeChartForStrength then HighestAll(cumR1)  else Sum(hitR1,  touchLookbackBars);
def R2_s  = if useWholeChartForStrength then HighestAll(cumR2)  else Sum(hitR2,  touchLookbackBars);
def R3_s  = if useWholeChartForStrength then HighestAll(cumR3)  else Sum(hitR3,  touchLookbackBars);
def R4_s  = if useWholeChartForStrength then HighestAll(cumR4)  else Sum(hitR4,  touchLookbackBars);
def R5_s  = if useWholeChartForStrength then HighestAll(cumR5)  else Sum(hitR5,  touchLookbackBars);
def R6_s  = if useWholeChartForStrength then HighestAll(cumR6)  else Sum(hitR6,  touchLookbackBars);
def R7_s  = if useWholeChartForStrength then HighestAll(cumR7)  else Sum(hitR7,  touchLookbackBars);
def R8_s  = if useWholeChartForStrength then HighestAll(cumR8)  else Sum(hitR8,  touchLookbackBars);
def R9_s  = if useWholeChartForStrength then HighestAll(cumR9)  else Sum(hitR9,  touchLookbackBars);
def R10_s = if useWholeChartForStrength then HighestAll(cumR10) else Sum(hitR10, touchLookbackBars);

def S1_s  = if useWholeChartForStrength then HighestAll(cumS1)  else Sum(hitS1,  touchLookbackBars);
def S2_s  = if useWholeChartForStrength then HighestAll(cumS2)  else Sum(hitS2,  touchLookbackBars);
def S3_s  = if useWholeChartForStrength then HighestAll(cumS3)  else Sum(hitS3,  touchLookbackBars);
def S4_s  = if useWholeChartForStrength then HighestAll(cumS4)  else Sum(hitS4,  touchLookbackBars);
def S5_s  = if useWholeChartForStrength then HighestAll(cumS5)  else Sum(hitS5,  touchLookbackBars);
def S6_s  = if useWholeChartForStrength then HighestAll(cumS6)  else Sum(hitS6,  touchLookbackBars);
def S7_s  = if useWholeChartForStrength then HighestAll(cumS7)  else Sum(hitS7,  touchLookbackBars);
def S8_s  = if useWholeChartForStrength then HighestAll(cumS8)  else Sum(hitS8,  touchLookbackBars);
def S9_s  = if useWholeChartForStrength then HighestAll(cumS9)  else Sum(hitS9,  touchLookbackBars);
def S10_s = if useWholeChartForStrength then HighestAll(cumS10) else Sum(hitS10, touchLookbackBars);

#---------------------
# Determine strongest (global max across BOTH sides)
#---------------------
def rMax = Max(Max(Max(Max(R1_s, R2_s), Max(R3_s, R4_s)),
                   Max(Max(R5_s, R6_s), Max(R7_s, R8_s))),
               Max(R9_s, R10_s));
def sMax = Max(Max(Max(Max(S1_s, S2_s), Max(S3_s, S4_s)),
                   Max(Max(S5_s, S6_s), Max(S7_s, S8_s))),
               Max(S9_s, S10_s));
def globalMax = Max(rMax, sMax);
def eps = 0.0001;

def isStrongR1  = R1_s  >= globalMax - eps and R1_s  >= minScoreToShow;
def isStrongR2  = R2_s  >= globalMax - eps and R2_s  >= minScoreToShow;
def isStrongR3  = R3_s  >= globalMax - eps and R3_s  >= minScoreToShow;
def isStrongR4  = R4_s  >= globalMax - eps and R4_s  >= minScoreToShow;
def isStrongR5  = R5_s  >= globalMax - eps and R5_s  >= minScoreToShow;
def isStrongR6  = R6_s  >= globalMax - eps and R6_s  >= minScoreToShow;
def isStrongR7  = R7_s  >= globalMax - eps and R7_s  >= minScoreToShow;
def isStrongR8  = R8_s  >= globalMax - eps and R8_s  >= minScoreToShow;
def isStrongR9  = R9_s  >= globalMax - eps and R9_s  >= minScoreToShow;
def isStrongR10 = R10_s >= globalMax - eps and R10_s >= minScoreToShow;

def isStrongS1  = S1_s  >= globalMax - eps and S1_s  >= minScoreToShow;
def isStrongS2  = S2_s  >= globalMax - eps and S2_s  >= minScoreToShow;
def isStrongS3  = S3_s  >= globalMax - eps and S3_s  >= minScoreToShow;
def isStrongS4  = S4_s  >= globalMax - eps and S4_s  >= minScoreToShow;
def isStrongS5  = S5_s  >= globalMax - eps and S5_s  >= minScoreToShow;
def isStrongS6  = S6_s  >= globalMax - eps and S6_s  >= minScoreToShow;
def isStrongS7  = S7_s  >= globalMax - eps and S7_s  >= minScoreToShow;
def isStrongS8  = S8_s  >= globalMax - eps and S8_s  >= minScoreToShow;
def isStrongS9  = S9_s  >= globalMax - eps and S9_s  >= minScoreToShow;
def isStrongS10 = S10_s >= globalMax - eps and S10_s >= minScoreToShow;

#---------------------
# Plots (full width)
#---------------------
plot R1  = if maxLevelsEach >= 1  and R1_s  >= minScoreToShow then R1_c  else Double.NaN;
plot R2  = if maxLevelsEach >= 2  and R2_s  >= minScoreToShow then R2_c  else Double.NaN;
plot R3  = if maxLevelsEach >= 3  and R3_s  >= minScoreToShow then R3_c  else Double.NaN;
plot R4  = if maxLevelsEach >= 4  and R4_s  >= minScoreToShow then R4_c  else Double.NaN;
plot R5  = if maxLevelsEach >= 5  and R5_s  >= minScoreToShow then R5_c  else Double.NaN;
plot R6  = if maxLevelsEach >= 6  and R6_s  >= minScoreToShow then R6_c  else Double.NaN;
plot R7  = if maxLevelsEach >= 7  and R7_s  >= minScoreToShow then R7_c  else Double.NaN;
plot R8  = if maxLevelsEach >= 8  and R8_s  >= minScoreToShow then R8_c  else Double.NaN;
plot R9  = if maxLevelsEach >= 9  and R9_s  >= minScoreToShow then R9_c  else Double.NaN;
plot R10 = if maxLevelsEach >= 10 and R10_s >= minScoreToShow then R10_c else Double.NaN;

plot S1  = if maxLevelsEach >= 1  and S1_s  >= minScoreToShow then S1_c  else Double.NaN;
plot S2  = if maxLevelsEach >= 2  and S2_s  >= minScoreToShow then S2_c  else Double.NaN;
plot S3  = if maxLevelsEach >= 3  and S3_s  >= minScoreToShow then S3_c  else Double.NaN;
plot S4  = if maxLevelsEach >= 4  and S4_s  >= minScoreToShow then S4_c  else Double.NaN;
plot S5  = if maxLevelsEach >= 5  and S5_s  >= minScoreToShow then S5_c  else Double.NaN;
plot S6  = if maxLevelsEach >= 6  and S6_s  >= minScoreToShow then S6_c  else Double.NaN;
plot S7  = if maxLevelsEach >= 7  and S7_s  >= minScoreToShow then S7_c  else Double.NaN;
plot S8  = if maxLevelsEach >= 8  and S8_s  >= minScoreToShow then S8_c  else Double.NaN;
plot S9  = if maxLevelsEach >= 9  and S9_s  >= minScoreToShow then S9_c  else Double.NaN;
plot S10 = if maxLevelsEach >= 10 and S10_s >= minScoreToShow then S10_c else Double.NaN;

# Base gray style
R1.AssignValueColor(GlobalColor("BaseLine"));  R1.SetLineWeight(baseLineWeight);
R2.AssignValueColor(GlobalColor("BaseLine"));  R2.SetLineWeight(baseLineWeight);
R3.AssignValueColor(GlobalColor("BaseLine"));  R3.SetLineWeight(baseLineWeight);
R4.AssignValueColor(GlobalColor("BaseLine"));  R4.SetLineWeight(baseLineWeight);
R5.AssignValueColor(GlobalColor("BaseLine"));  R5.SetLineWeight(baseLineWeight);
R6.AssignValueColor(GlobalColor("BaseLine"));  R6.SetLineWeight(baseLineWeight);
R7.AssignValueColor(GlobalColor("BaseLine"));  R7.SetLineWeight(baseLineWeight);
R8.AssignValueColor(GlobalColor("BaseLine"));  R8.SetLineWeight(baseLineWeight);
R9.AssignValueColor(GlobalColor("BaseLine"));  R9.SetLineWeight(baseLineWeight);
R10.AssignValueColor(GlobalColor("BaseLine")); R10.SetLineWeight(baseLineWeight);

S1.AssignValueColor(GlobalColor("BaseLine"));  S1.SetLineWeight(baseLineWeight);
S2.AssignValueColor(GlobalColor("BaseLine"));  S2.SetLineWeight(baseLineWeight);
S3.AssignValueColor(GlobalColor("BaseLine"));  S3.SetLineWeight(baseLineWeight);
S4.AssignValueColor(GlobalColor("BaseLine"));  S4.SetLineWeight(baseLineWeight);
S5.AssignValueColor(GlobalColor("BaseLine"));  S5.SetLineWeight(baseLineWeight);
S6.AssignValueColor(GlobalColor("BaseLine"));  S6.SetLineWeight(baseLineWeight);
S7.AssignValueColor(GlobalColor("BaseLine"));  S7.SetLineWeight(baseLineWeight);
S8.AssignValueColor(GlobalColor("BaseLine"));  S8.SetLineWeight(baseLineWeight);
S9.AssignValueColor(GlobalColor("BaseLine"));  S9.SetLineWeight(baseLineWeight);
S10.AssignValueColor(GlobalColor("BaseLine")); S10.SetLineWeight(baseLineWeight);

# Strongest overlays (yellow + thicker) based on GLOBAL max touches
plot RH1  = R1;  RH1.SetHiding(!isStrongR1);
plot RH2  = R2;  RH2.SetHiding(!isStrongR2);
plot RH3  = R3;  RH3.SetHiding(!isStrongR3);
plot RH4  = R4;  RH4.SetHiding(!isStrongR4);
plot RH5  = R5;  RH5.SetHiding(!isStrongR5);
plot RH6  = R6;  RH6.SetHiding(!isStrongR6);
plot RH7  = R7;  RH7.SetHiding(!isStrongR7);
plot RH8  = R8;  RH8.SetHiding(!isStrongR8);
plot RH9  = R9;  RH9.SetHiding(!isStrongR9);
plot RH10 = R10; RH10.SetHiding(!isStrongR10);

plot SH1  = S1;  SH1.SetHiding(!isStrongS1);
plot SH2  = S2;  SH2.SetHiding(!isStrongS2);
plot SH3  = S3;  SH3.SetHiding(!isStrongS3);
plot SH4  = S4;  SH4.SetHiding(!isStrongS4);
plot SH5  = S5;  SH5.SetHiding(!isStrongS5);
plot SH6  = S6;  SH6.SetHiding(!isStrongS6);
plot SH7  = S7;  SH7.SetHiding(!isStrongS7);
plot SH8  = S8;  SH8.SetHiding(!isStrongS8);
plot SH9  = S9;  SH9.SetHiding(!isStrongS9);
plot SH10 = S10; SH10.SetHiding(!isStrongS10);

RH1.AssignValueColor(GlobalColor("StrongLine"));  RH1.SetLineWeight(strongestLineWeight);
RH2.AssignValueColor(GlobalColor("StrongLine"));  RH2.SetLineWeight(strongestLineWeight);
RH3.AssignValueColor(GlobalColor("StrongLine"));  RH3.SetLineWeight(strongestLineWeight);
RH4.AssignValueColor(GlobalColor("StrongLine"));  RH4.SetLineWeight(strongestLineWeight);
RH5.AssignValueColor(GlobalColor("StrongLine"));  RH5.SetLineWeight(strongestLineWeight);
RH6.AssignValueColor(GlobalColor("StrongLine"));  RH6.SetLineWeight(strongestLineWeight);
RH7.AssignValueColor(GlobalColor("StrongLine"));  RH7.SetLineWeight(strongestLineWeight);
RH8.AssignValueColor(GlobalColor("StrongLine"));  RH8.SetLineWeight(strongestLineWeight);
RH9.AssignValueColor(GlobalColor("StrongLine"));  RH9.SetLineWeight(strongestLineWeight);
RH10.AssignValueColor(GlobalColor("StrongLine")); RH10.SetLineWeight(strongestLineWeight);

SH1.AssignValueColor(GlobalColor("StrongLine"));  SH1.SetLineWeight(strongestLineWeight);
SH2.AssignValueColor(GlobalColor("StrongLine"));  SH2.SetLineWeight(strongestLineWeight);
SH3.AssignValueColor(GlobalColor("StrongLine"));  SH3.SetLineWeight(strongestLineWeight);
SH4.AssignValueColor(GlobalColor("StrongLine"));  SH4.SetLineWeight(strongestLineWeight);
SH5.AssignValueColor(GlobalColor("StrongLine"));  SH5.SetLineWeight(strongestLineWeight);
SH6.AssignValueColor(GlobalColor("StrongLine"));  SH6.SetLineWeight(strongestLineWeight);
SH7.AssignValueColor(GlobalColor("StrongLine"));  SH7.SetLineWeight(strongestLineWeight);
SH8.AssignValueColor(GlobalColor("StrongLine"));  SH8.SetLineWeight(strongestLineWeight);
SH9.AssignValueColor(GlobalColor("StrongLine"));  SH9.SetLineWeight(strongestLineWeight);
SH10.AssignValueColor(GlobalColor("StrongLine")); SH10.SetLineWeight(strongestLineWeight);

#---------------------
# ZONES: draw clouds directly from the MAIN lines (centered ± z)
#---------------------
AddCloud( if showZones then R1  + z else Double.NaN,  if showZones then R1  - z else Double.NaN,  GlobalColor("BaseResZone"), GlobalColor("BaseResZone"));
AddCloud( if showZones then R2  + z else Double.NaN,  if showZones then R2  - z else Double.NaN,  GlobalColor("BaseResZone"), GlobalColor("BaseResZone"));
AddCloud( if showZones then R3  + z else Double.NaN,  if showZones then R3  - z else Double.NaN,  GlobalColor("BaseResZone"), GlobalColor("BaseResZone"));
AddCloud( if showZones then R4  + z else Double.NaN,  if showZones then R4  - z else Double.NaN,  GlobalColor("BaseResZone"), GlobalColor("BaseResZone"));
AddCloud( if showZones then R5  + z else Double.NaN,  if showZones then R5  - z else Double.NaN,  GlobalColor("BaseResZone"), GlobalColor("BaseResZone"));
AddCloud( if showZones then R6  + z else Double.NaN,  if showZones then R6  - z else Double.NaN,  GlobalColor("BaseResZone"), GlobalColor("BaseResZone"));
AddCloud( if showZones then R7  + z else Double.NaN,  if showZones then R7  - z else Double.NaN,  GlobalColor("BaseResZone"), GlobalColor("BaseResZone"));
AddCloud( if showZones then R8  + z else Double.NaN,  if showZones then R8  - z else Double.NaN,  GlobalColor("BaseResZone"), GlobalColor("BaseResZone"));
AddCloud( if showZones then R9  + z else Double.NaN,  if showZones then R9  - z else Double.NaN,  GlobalColor("BaseResZone"), GlobalColor("BaseResZone"));
AddCloud( if showZones then R10 + z else Double.NaN,  if showZones then R10 - z else Double.NaN,  GlobalColor("BaseResZone"), GlobalColor("BaseResZone"));

AddCloud( if showZones then S1  + z else Double.NaN,  if showZones then S1  - z else Double.NaN,  GlobalColor("BaseSupZone"), GlobalColor("BaseSupZone"));
AddCloud( if showZones then S2  + z else Double.NaN,  if showZones then S2  - z else Double.NaN,  GlobalColor("BaseSupZone"), GlobalColor("BaseSupZone"));
AddCloud( if showZones then S3  + z else Double.NaN,  if showZones then S3  - z else Double.NaN,  GlobalColor("BaseSupZone"), GlobalColor("BaseSupZone"));
AddCloud( if showZones then S4  + z else Double.NaN,  if showZones then S4  - z else Double.NaN,  GlobalColor("BaseSupZone"), GlobalColor("BaseSupZone"));
AddCloud( if showZones then S5  + z else Double.NaN,  if showZones then S5  - z else Double.NaN,  GlobalColor("BaseSupZone"), GlobalColor("BaseSupZone"));
AddCloud( if showZones then S6  + z else Double.NaN,  if showZones then S6  - z else Double.NaN,  GlobalColor("BaseSupZone"), GlobalColor("BaseSupZone"));
AddCloud( if showZones then S7  + z else Double.NaN,  if showZones then S7  - z else Double.NaN,  GlobalColor("BaseSupZone"), GlobalColor("BaseSupZone"));
AddCloud( if showZones then S8  + z else Double.NaN,  if showZones then S8  - z else Double.NaN,  GlobalColor("BaseSupZone"), GlobalColor("BaseSupZone"));
AddCloud( if showZones then S9  + z else Double.NaN,  if showZones then S9  - z else Double.NaN,  GlobalColor("BaseSupZone"), GlobalColor("BaseSupZone"));
AddCloud( if showZones then S10 + z else Double.NaN,  if showZones then S10 - z else Double.NaN,  GlobalColor("BaseSupZone"), GlobalColor("BaseSupZone"));

# Strongest clouds (yellow) drawn last (on top)
AddCloud( if isStrongR1  then R1  + z else Double.NaN,  if isStrongR1  then R1  - z else Double.NaN,  GlobalColor("StrongResZone"), GlobalColor("StrongResZone"));
AddCloud( if isStrongR2  then R2  + z else Double.NaN,  if isStrongR2  then R2  - z else Double.NaN,  GlobalColor("StrongResZone"), GlobalColor("StrongResZone"));
AddCloud( if isStrongR3  then R3  + z else Double.NaN,  if isStrongR3  then R3  - z else Double.NaN,  GlobalColor("StrongResZone"), GlobalColor("StrongResZone"));
AddCloud( if isStrongR4  then R4  + z else Double.NaN,  if isStrongR4  then R4  - z else Double.NaN,  GlobalColor("StrongResZone"), GlobalColor("StrongResZone"));
AddCloud( if isStrongR5  then R5  + z else Double.NaN,  if isStrongR5  then R5  - z else Double.NaN,  GlobalColor("StrongResZone"), GlobalColor("StrongResZone"));
AddCloud( if isStrongR6  then R6  + z else Double.NaN,  if isStrongR6  then R6  - z else Double.NaN,  GlobalColor("StrongResZone"), GlobalColor("StrongResZone"));
AddCloud( if isStrongR7  then R7  + z else Double.NaN,  if isStrongR7  then R7  - z else Double.NaN,  GlobalColor("StrongResZone"), GlobalColor("StrongResZone"));
AddCloud( if isStrongR8  then R8  + z else Double.NaN,  if isStrongR8  then R8  - z else Double.NaN,  GlobalColor("StrongResZone"), GlobalColor("StrongResZone"));
AddCloud( if isStrongR9  then R9  + z else Double.NaN,  if isStrongR9  then R9  - z else Double.NaN,  GlobalColor("StrongResZone"), GlobalColor("StrongResZone"));
AddCloud( if isStrongR10 then R10 + z else Double.NaN,  if isStrongR10 then R10 - z else Double.NaN,  GlobalColor("StrongResZone"), GlobalColor("StrongResZone"));

AddCloud( if isStrongS1  then S1  + z else Double.NaN,  if isStrongS1  then S1  - z else Double.NaN,  GlobalColor("StrongSupZone"), GlobalColor("StrongSupZone"));
AddCloud( if isStrongS2  then S2  + z else Double.NaN,  if isStrongS2  then S2  - z else Double.NaN,  GlobalColor("StrongSupZone"), GlobalColor("StrongSupZone"));
AddCloud( if isStrongS3  then S3  + z else Double.NaN,  if isStrongS3  then S3  - z else Double.NaN,  GlobalColor("StrongSupZone"), GlobalColor("StrongSupZone"));
AddCloud( if isStrongS4  then S4  + z else Double.NaN,  if isStrongS4  then S4  - z else Double.NaN,  GlobalColor("StrongSupZone"), GlobalColor("StrongSupZone"));
AddCloud( if isStrongS5  then S5  + z else Double.NaN,  if isStrongS5  then S5  - z else Double.NaN,  GlobalColor("StrongSupZone"), GlobalColor("StrongSupZone"));
AddCloud( if isStrongS6  then S6  + z else Double.NaN,  if isStrongS6  then S6  - z else Double.NaN,  GlobalColor("StrongSupZone"), GlobalColor("StrongSupZone"));
AddCloud( if isStrongS7  then S7  + z else Double.NaN,  if isStrongS7  then S7  - z else Double.NaN,  GlobalColor("StrongSupZone"), GlobalColor("StrongSupZone"));
AddCloud( if isStrongS8  then S8  + z else Double.NaN,  if isStrongS8  then S8  - z else Double.NaN,  GlobalColor("StrongSupZone"), GlobalColor("StrongSupZone"));
AddCloud( if isStrongS9  then S9  + z else Double.NaN,  if isStrongS9  then S9  - z else Double.NaN,  GlobalColor("StrongSupZone"), GlobalColor("StrongSupZone"));
AddCloud( if isStrongS10 then S10 + z else Double.NaN,  if isStrongS10 then S10 - z else Double.NaN,  GlobalColor("StrongSupZone"), GlobalColor("StrongSupZone"));

#---------------------
# Optional debug
#---------------------
AddChartBubble(showTouchBubbles and hitR1,  R1_c,  "R1",  Color.GRAY,  yes);
AddChartBubble(showTouchBubbles and hitR2,  R2_c,  "R2",  Color.GRAY,  yes);
AddChartBubble(showTouchBubbles and hitR3,  R3_c,  "R3",  Color.GRAY,  yes);
AddChartBubble(showTouchBubbles and hitR4,  R4_c,  "R4",  Color.GRAY,  yes);
AddChartBubble(showTouchBubbles and hitR5,  R5_c,  "R5",  Color.GRAY,  yes);
AddChartBubble(showTouchBubbles and hitR6,  R6_c,  "R6",  Color.GRAY,  yes);
AddChartBubble(showTouchBubbles and hitR7,  R7_c,  "R7",  Color.GRAY,  yes);
AddChartBubble(showTouchBubbles and hitR8,  R8_c,  "R8",  Color.GRAY,  yes);
AddChartBubble(showTouchBubbles and hitR9,  R9_c,  "R9",  Color.GRAY,  yes);
AddChartBubble(showTouchBubbles and hitR10, R10_c, "R10", Color.GRAY,  yes);

AddChartBubble(showTouchBubbles and hitS1,  S1_c,  "S1",  Color.GRAY,  no);
AddChartBubble(showTouchBubbles and hitS2,  S2_c,  "S2",  Color.GRAY,  no);
AddChartBubble(showTouchBubbles and hitS3,  S3_c,  "S3",  Color.GRAY,  no);
AddChartBubble(showTouchBubbles and hitS4,  S4_c,  "S4",  Color.GRAY,  no);
AddChartBubble(showTouchBubbles and hitS5,  S5_c,  "S5",  Color.GRAY,  no);
AddChartBubble(showTouchBubbles and hitS6,  S6_c,  "S6",  Color.GRAY,  no);
AddChartBubble(showTouchBubbles and hitS7,  S7_c,  "S7",  Color.GRAY,  no);
AddChartBubble(showTouchBubbles and hitS8,  S8_c,  "S8",  Color.GRAY,  no);
AddChartBubble(showTouchBubbles and hitS9,  S9_c,  "S9",  Color.GRAY,  no);
AddChartBubble(showTouchBubbles and hitS10, S10_c, "S10", Color.GRAY,  no);

# ---------------------
# Base gray style (toggleable)
# ---------------------
R1.AssignValueColor(GlobalColor("BaseLine"));  R1.SetLineWeight(baseLineWeight);  R1.SetHiding(!showBaseLines);
R2.AssignValueColor(GlobalColor("BaseLine"));  R2.SetLineWeight(baseLineWeight);  R2.SetHiding(!showBaseLines);
R3.AssignValueColor(GlobalColor("BaseLine"));  R3.SetLineWeight(baseLineWeight);  R3.SetHiding(!showBaseLines);
R4.AssignValueColor(GlobalColor("BaseLine"));  R4.SetLineWeight(baseLineWeight);  R4.SetHiding(!showBaseLines);
R5.AssignValueColor(GlobalColor("BaseLine"));  R5.SetLineWeight(baseLineWeight);  R5.SetHiding(!showBaseLines);
R6.AssignValueColor(GlobalColor("BaseLine"));  R6.SetLineWeight(baseLineWeight);  R6.SetHiding(!showBaseLines);
R7.AssignValueColor(GlobalColor("BaseLine"));  R7.SetLineWeight(baseLineWeight);  R7.SetHiding(!showBaseLines);
R8.AssignValueColor(GlobalColor("BaseLine"));  R8.SetLineWeight(baseLineWeight);  R8.SetHiding(!showBaseLines);
R9.AssignValueColor(GlobalColor("BaseLine"));  R9.SetLineWeight(baseLineWeight);  R9.SetHiding(!showBaseLines);
R10.AssignValueColor(GlobalColor("BaseLine")); R10.SetLineWeight(baseLineWeight); R10.SetHiding(!showBaseLines);

S1.AssignValueColor(GlobalColor("BaseLine"));  S1.SetLineWeight(baseLineWeight);  S1.SetHiding(!showBaseLines);
S2.AssignValueColor(GlobalColor("BaseLine"));  S2.SetLineWeight(baseLineWeight);  S2.SetHiding(!showBaseLines);
S3.AssignValueColor(GlobalColor("BaseLine"));  S3.SetLineWeight(baseLineWeight);  S3.SetHiding(!showBaseLines);
S4.AssignValueColor(GlobalColor("BaseLine"));  S4.SetLineWeight(baseLineWeight);  S4.SetHiding(!showBaseLines);
S5.AssignValueColor(GlobalColor("BaseLine"));  S5.SetLineWeight(baseLineWeight);  S5.SetHiding(!showBaseLines);
S6.AssignValueColor(GlobalColor("BaseLine"));  S6.SetLineWeight(baseLineWeight);  S6.SetHiding(!showBaseLines);
S7.AssignValueColor(GlobalColor("BaseLine"));  S7.SetLineWeight(baseLineWeight);  S7.SetHiding(!showBaseLines);
S8.AssignValueColor(GlobalColor("BaseLine"));  S8.SetLineWeight(baseLineWeight);  S8.SetHiding(!showBaseLines);
S9.AssignValueColor(GlobalColor("BaseLine"));  S9.SetLineWeight(baseLineWeight);  S9.SetHiding(!showBaseLines);
S10.AssignValueColor(GlobalColor("BaseLine")); S10.SetLineWeight(baseLineWeight); S10.SetHiding(!showBaseLines);

# ==== Level bubbles: raw touch count or 1–10 scale ====
input showStrengthBubbles = yes;      # master on/off
input bubblesAtRightEdge  = yes;      # only show at the last bar
input bubbleDisplay       = {default TouchCount, Scaled1to10};  # what to show

def rightEdge = if bubblesAtRightEdge then BarNumber() == HighestAll(BarNumber()) else 1;

# side-wise denominators for scaled mode; protect against 0
def rDen = if rMax > 0 then rMax else 1;
def sDen = if sMax > 0 then sMax else 1;

# values to display per mode
def R1_val  = if bubbleDisplay == bubbleDisplay.TouchCount then R1_s  else Round(Min(10, 10 * R1_s  / rDen), 0);
def R2_val  = if bubbleDisplay == bubbleDisplay.TouchCount then R2_s  else Round(Min(10, 10 * R2_s  / rDen), 0);
def R3_val  = if bubbleDisplay == bubbleDisplay.TouchCount then R3_s  else Round(Min(10, 10 * R3_s  / rDen), 0);
def R4_val  = if bubbleDisplay == bubbleDisplay.TouchCount then R4_s  else Round(Min(10, 10 * R4_s  / rDen), 0);
def R5_val  = if bubbleDisplay == bubbleDisplay.TouchCount then R5_s  else Round(Min(10, 10 * R5_s  / rDen), 0);
def R6_val  = if bubbleDisplay == bubbleDisplay.TouchCount then R6_s  else Round(Min(10, 10 * R6_s  / rDen), 0);
def R7_val  = if bubbleDisplay == bubbleDisplay.TouchCount then R7_s  else Round(Min(10, 10 * R7_s  / rDen), 0);
def R8_val  = if bubbleDisplay == bubbleDisplay.TouchCount then R8_s  else Round(Min(10, 10 * R8_s  / rDen), 0);
def R9_val  = if bubbleDisplay == bubbleDisplay.TouchCount then R9_s  else Round(Min(10, 10 * R9_s  / rDen), 0);
def R10_val = if bubbleDisplay == bubbleDisplay.TouchCount then R10_s else Round(Min(10, 10 * R10_s / rDen), 0);

def S1_val  = if bubbleDisplay == bubbleDisplay.TouchCount then S1_s  else Round(Min(10, 10 * S1_s  / sDen), 0);
def S2_val  = if bubbleDisplay == bubbleDisplay.TouchCount then S2_s  else Round(Min(10, 10 * S2_s  / sDen), 0);
def S3_val  = if bubbleDisplay == bubbleDisplay.TouchCount then S3_s  else Round(Min(10, 10 * S3_s  / sDen), 0);
def S4_val  = if bubbleDisplay == bubbleDisplay.TouchCount then S4_s  else Round(Min(10, 10 * S4_s  / sDen), 0);
def S5_val  = if bubbleDisplay == bubbleDisplay.TouchCount then S5_s  else Round(Min(10, 10 * S5_s  / sDen), 0);
def S6_val  = if bubbleDisplay == bubbleDisplay.TouchCount then S6_s  else Round(Min(10, 10 * S6_s  / sDen), 0);
def S7_val  = if bubbleDisplay == bubbleDisplay.TouchCount then S7_s  else Round(Min(10, 10 * S7_s  / sDen), 0);
def S8_val  = if bubbleDisplay == bubbleDisplay.TouchCount then S8_s  else Round(Min(10, 10 * S8_s  / sDen), 0);
def S9_val  = if bubbleDisplay == bubbleDisplay.TouchCount then S9_s  else Round(Min(10, 10 * S9_s  / sDen), 0);
def S10_val = if bubbleDisplay == bubbleDisplay.TouchCount then S10_s else Round(Min(10, 10 * S10_s / sDen), 0);

# color: gold if that level is currently the strongest; else gray
def cR1  = if isStrongR1  then 1 else 0;
def cR2  = if isStrongR2  then 1 else 0;
def cR3  = if isStrongR3  then 1 else 0;
def cR4  = if isStrongR4  then 1 else 0;
def cR5  = if isStrongR5  then 1 else 0;
def cR6  = if isStrongR6  then 1 else 0;
def cR7  = if isStrongR7  then 1 else 0;
def cR8  = if isStrongR8  then 1 else 0;
def cR9  = if isStrongR9  then 1 else 0;
def cR10 = if isStrongR10 then 1 else 0;

def cS1  = if isStrongS1  then 1 else 0;
def cS2  = if isStrongS2  then 1 else 0;
def cS3  = if isStrongS3  then 1 else 0;
def cS4  = if isStrongS4  then 1 else 0;
def cS5  = if isStrongS5  then 1 else 0;
def cS6  = if isStrongS6  then 1 else 0;
def cS7  = if isStrongS7  then 1 else 0;
def cS8  = if isStrongS8  then 1 else 0;
def cS9  = if isStrongS9  then 1 else 0;
def cS10 = if isStrongS10 then 1 else 0;

AddChartBubble(showStrengthBubbles and rightEdge and !IsNaN(R1),  R1,  R1_val,  if cR1  then GlobalColor("StrongLine") else GlobalColor("BaseLine"),  yes);
AddChartBubble(showStrengthBubbles and rightEdge and !IsNaN(R2),  R2,  R2_val,  if cR2  then GlobalColor("StrongLine") else GlobalColor("BaseLine"),  yes);
AddChartBubble(showStrengthBubbles and rightEdge and !IsNaN(R3),  R3,  R3_val,  if cR3  then GlobalColor("StrongLine") else GlobalColor("BaseLine"),  yes);
AddChartBubble(showStrengthBubbles and rightEdge and !IsNaN(R4),  R4,  R4_val,  if cR4  then GlobalColor("StrongLine") else GlobalColor("BaseLine"),  yes);
AddChartBubble(showStrengthBubbles and rightEdge and !IsNaN(R5),  R5,  R5_val,  if cR5  then GlobalColor("StrongLine") else GlobalColor("BaseLine"),  yes);
AddChartBubble(showStrengthBubbles and rightEdge and !IsNaN(R6),  R6,  R6_val,  if cR6  then GlobalColor("StrongLine") else GlobalColor("BaseLine"),  yes);
AddChartBubble(showStrengthBubbles and rightEdge and !IsNaN(R7),  R7,  R7_val,  if cR7  then GlobalColor("StrongLine") else GlobalColor("BaseLine"),  yes);
AddChartBubble(showStrengthBubbles and rightEdge and !IsNaN(R8),  R8,  R8_val,  if cR8  then GlobalColor("StrongLine") else GlobalColor("BaseLine"),  yes);
AddChartBubble(showStrengthBubbles and rightEdge and !IsNaN(R9),  R9,  R9_val,  if cR9  then GlobalColor("StrongLine") else GlobalColor("BaseLine"),  yes);
AddChartBubble(showStrengthBubbles and rightEdge and !IsNaN(R10), R10, R10_val, if cR10 then GlobalColor("StrongLine") else GlobalColor("BaseLine"), yes);

AddChartBubble(showStrengthBubbles and rightEdge and !IsNaN(S1),  S1,  S1_val,  if cS1  then GlobalColor("StrongLine") else GlobalColor("BaseLine"),  no);
AddChartBubble(showStrengthBubbles and rightEdge and !IsNaN(S2),  S2,  S2_val,  if cS2  then GlobalColor("StrongLine") else GlobalColor("BaseLine"),  no);
AddChartBubble(showStrengthBubbles and rightEdge and !IsNaN(S3),  S3,  S3_val,  if cS3  then GlobalColor("StrongLine") else GlobalColor("BaseLine"),  no);
AddChartBubble(showStrengthBubbles and rightEdge and !IsNaN(S4),  S4,  S4_val,  if cS4  then GlobalColor("StrongLine") else GlobalColor("BaseLine"),  no);
AddChartBubble(showStrengthBubbles and rightEdge and !IsNaN(S5),  S5,  S5_val,  if cS5  then GlobalColor("StrongLine") else GlobalColor("BaseLine"),  no);
AddChartBubble(showStrengthBubbles and rightEdge and !IsNaN(S6),  S6,  S6_val,  if cS6  then GlobalColor("StrongLine") else GlobalColor("BaseLine"),  no);
AddChartBubble(showStrengthBubbles and rightEdge and !IsNaN(S7),  S7,  S7_val,  if cS7  then GlobalColor("StrongLine") else GlobalColor("BaseLine"),  no);
AddChartBubble(showStrengthBubbles and rightEdge and !IsNaN(S8),  S8,  S8_val,  if cS8  then GlobalColor("StrongLine") else GlobalColor("BaseLine"),  no);
AddChartBubble(showStrengthBubbles and rightEdge and !IsNaN(S9),  S9,  S9_val,  if cS9  then GlobalColor("StrongLine") else GlobalColor("BaseLine"),  no);
AddChartBubble(showStrengthBubbles and rightEdge and !IsNaN(S10), S10, S10_val, if cS10 then GlobalColor("StrongLine") else GlobalColor("BaseLine"), no);

# Optional mode label
AddLabel(showStrengthBubbles, "Bubble metric: " +
    (if bubbleDisplay == bubbleDisplay.TouchCount then "raw touches" else "scaled 1–10"),
    GlobalColor("BaseLine"));


#def rTop = rMax;
#def sTop = sMax;
#AddLabel(showScoreLabels, "Strongest R touches: " + rTop + " | Strongest S touches: " + sTop, GlobalColor("BaseLine"));
 
Last edited by a moderator:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
854 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top