Fibonacci MAs – 8-Slot Engine

Ricky_005

New member
Plus
thinkorswim_VFQUyJM19z.png


thinkorswim_CB6fZlicMB.png


thinkorswim_rawTXmEH5w.png

Hey everyone,

This is my first time posting a study on the UseThinkScript forum, so I’m coming in straight and simple: this is a Moving Average stack I built for day-to-day chart work and quick visual alignment.

What it is
Fibonacci MAs – 8-Slot Engine (Per-MA AvgType + Per-MA PriceSource)
It plots up to 8 MA “slots” (default Fib lengths like 3/5/8/13/21/55/144/377), but you can change anything. Each slot has:
  • On/Off toggle
  • Length
  • Average type (AvgType per slot)
  • Price source per slot (Close/Open/High/Low/HL2/HLC3/OHLC4)
Why I made it
I wanted a clean way to run multiple MA lengths without constantly rewriting studies or juggling separate indicators. This keeps everything in one place, gives you consistent color mapping by slot, and prints useful labels so you always know exactly what’s on your chart.

Extra features
  • Color schemes: Rainbow / Classic / Dark
  • Label location control: Top/Bottom + Left/Right
  • Bar-safety WARNING label: tells you when you don’t have enough bars for the longest enabled MA (with a barMultiplier buffer)
Notes
  • The warning label is informational only—Thinkorswim can still throw “N/A” if you push extreme lengths on certain aggregations. That’s a platform limitation.
  • I kept it readable and modular so it’s easy to tweak.
Looking for improvements
I’m not pretending this is perfect. If you see ways to make it cleaner, faster, or smarter—improve it. If you add something useful (better label formatting, add a scoring system, better logic, performance ideas, anything), post it back so everyone benefits.

Appreciate the time, and thanks in advance for any feedback.

— Tricky Rick


Code:
declare upper;
#===================================================================
# ThinkOrSwim Study: MovingAverage Average Study
# Author: Tricky Rick
# Created: December 28, 2025
#====================================================================================================================
# USER GUIDE — Fibonacci MAs (8-Slot Engine | Per-MA AvgType + Per-MA PriceSource)
# Author: Tricky Rick
#
# PURPOSE
#   • Plots up to 8 Moving Averages (MA1–MA8) on the price chart (declare upper).
#   • Each MA slot has its own:
#       – Show toggle
#       – Length
#       – Average Type (AvgType)
#       – Price Source (Close/Open/High/Low/HL2/HLC3/OHLC4)
#   • Includes informative on-screen labels (Title, Bars/Multiplier, WARNING, per-MA details).
#
# INPUTS (WHAT THEY DO)
#   A) UI SEPARATORS (no functional effect)
#      • StandardFibNumbers : Drop-down reference list of Fibonacci numbers (documentation only).
#      • MaOptions          : Input-panel separator label (no functional effect).
#      • MaSettings         : Input-panel separator label (no functional effect).
#
#   B) GLOBAL CONTROLS
#      • colorScheme (Rainbow / Classic / Dark)
#          – Selects the color palette used by MA lines and their matching labels.
#          – Colors are assigned by slot index (MA1..MA8).
#
#      • barMultiplier (default 1.1)
#          – Used ONLY for the WARNING label threshold:
#              Need ≥ (max enabled MA length) × barMultiplier
#          – Think of this as a “safety buffer” on top of the longest enabled MA length.
#          – Examples:
#              • If maxLen = 144 and barMultiplier = 1.0  → Need ≥ 144 bars
#              • If maxLen = 144 and barMultiplier = 1.1  → Need ≥ 158.4 bars (ToS may display .0/.4)
#              • If maxLen = 377 and barMultiplier = 1.2  → Need ≥ 452.4 bars
#          – Why it exists:
#              • Some MA types / sources can look unstable or “half-baked” right at the minimum bar count.
#              • Using >1.0 gives the MA more bars to “settle in” before you trust it visually.
#          – How to tune it:
#              • 1.0  = strict minimum (warn only when you’re below the raw length)
#              • 1.05–1.15 = practical buffer (recommended for most use)
#              • 1.2+ = conservative buffer (warns earlier; useful on very noisy intraday charts)
#          – Higher values warn sooner (more conservative). Lower values warn later.
#          – IMPORTANT: This does NOT prevent ToS from showing “N/A”; it’s informational only.
#
#      • showLabels (yes/no)
#          – Enables/disables ALL labels: title, bars/multiplier, WARNING, spacer, and per-MA labels.
#
#      • MaLabelLocation (Top-Left / Top-Right / Bottom-Left / Bottom-Right)
#          – Sets the on-screen anchor location for the entire label group.
#
#   C) PER-MA SLOT INPUTS (MA1…MA8)
#      • showMA#         : Enables/disables that MA plot + its detail label.
#      • MA#_Len         : Length for that slot’s moving average.
#      • MA#_AvgType     : Average type for that slot (Thinkorswim AverageType enum).
#      • MA#_PriceSource : Input price series for that slot:
#           Close, Open, High, Low
#           HL2   = (High + Low) / 2
#           HLC3  = (High + Low + Close) / 3
#           OHLC4 = (Open + High + Low + Close) / 4
#
# HOW PLOTTING WORKS (IMPORTANT)
#   • Each slot computes: MovingAverage(MA#_AvgType, src#, len#).
#   • “Lazy Engine” lengths:
#       – When a slot is OFF (showMA# = no), its effective length becomes 1, and the plot is hidden.
#       – NOTE: Some ToS builds can be strict about “constant length” in certain contexts. If you ever see
#         “Only constants expected here … length”, use MA#_Len directly (no conditional len#) and rely on
#         SetHiding() for OFF slots.
#
# LABELS (WHAT YOU WILL SEE)
#   • Title label:
#       – “Fibonacci MA’s”
#
#   • Bars / Bar Multiplier label:
#       – Bars = barCount (HighestAll(BarNumber()))
#       – Bar Multiplier = barMultiplier
#       – Note: ToS may display numbers with “.0” because values are treated as doubles internally.
#
#   • WARNING label (bar safety / informational only):
#       – Appears when: any MA is ON AND barCount < (max enabled MA length × barMultiplier).
#       – Displays maxLen, Bars, and the “Need ≥ …” threshold.
#       – Limitation: This label cannot prevent Thinkorswim from showing “N/A” if extreme lengths or
#         aggregation constraints cause the study to stop evaluating. It is informational only.
#
#   • Spacer label:
#       – A blank label using GlobalColor("Spacer") (dark gray), used to visually separate label groups.
#
#   • Per-MA detail labels:
#       – For each enabled MA slot, prints:
#           “Length | AvgType | PriceSource”
#       – AvgType text is mapped as:
#           SMA / EMA / WMA / Wilder / (anything else shown as “Hull” per the current label mapping)
#       – Label color matches that MA line under the selected colorScheme.
#
# COLOR SCHEMES
#   • Rainbow : VIBGYOR-style + off-white for slot 8 (mapped by slot index).
#   • Classic : Cyan, Yellow, Magenta, Green, Red, White, Gray, Orange (mapped by slot index).
#   • Dark    : Subdued colors designed for dark charts (mapped by slot index).
#   • Spacer  : Dark gray used only for blank spacer labels (not an MA line color).
#
# PRACTICAL NOTES
#   • Very large lengths on low timeframes can cause ToS “N/A” (study disappears). This is a ToS limitation.
#   • Per-MA PriceSource allows mixing sources across slots (e.g., MA1=Close, MA2=HL2, etc.).
#====================================================================================================================


#---------------------------------------------------------------------------------------------
# Helper Toggle – Standard Fibonacci Numbers (documentation only)
#---------------------------------------------------------------------------------------------
input StandardFibNumbers = {
    default "<<<<<< Standard Fib Numbers >>>>>>",
    "3 5 8 13 21 34 55 89",
    "144 233 377 610 987",
    "1597 2584 4181",
    "6765 10946 17711 28657"
};
input MaOptions = { default "<<<<<< MA Option Settings >>>>>>" };
#---------------------------------------------------------------------------------------------
# Global Controls – Color Scheme, Bar Safety (warning), and Labels
#---------------------------------------------------------------------------------------------
input barMultiplier = 1.1;
input colorScheme   = {default Rainbow, Classic, Dark};
input showLabels    = yes;
input MaLabelLocation = {default "Top-Left", "Top-Right", "Bottom-Left", "Bottom-Right"};

input MaSettings = { default "<<<<<< MA Inputs & Settings >>>>>>" };
#---------------------------------------------------------------------------------------------
# MA Slot Inputs – 8 Independent MAs (Show / Length / AvgType / PriceSource)
#---------------------------------------------------------------------------------------------
input MA1_Len = 3;
input showMA1 = yes;
input MA1_AvgType = AverageType.EXPONENTIAL;
input MA1_PriceSource = {default Close, Open, High, Low, HL2, HLC3, OHLC4};
input MA2_Len = 5;
input showMA2 = yes;
input MA2_AvgType = AverageType.EXPONENTIAL;
input MA2_PriceSource = {default Close, Open, High, Low, HL2, HLC3, OHLC4};
input MA3_Len = 8;
input showMA3 = yes;
input MA3_AvgType = AverageType.EXPONENTIAL;
input MA3_PriceSource = {default Close, Open, High, Low, HL2, HLC3, OHLC4};
input MA4_Len = 13;
input showMA4 = yes;
input MA4_AvgType = AverageType.EXPONENTIAL;
input MA4_PriceSource = {default Close, Open, High, Low, HL2, HLC3, OHLC4};
input MA5_Len = 21;
input showMA5 = yes;
input MA5_AvgType = AverageType.EXPONENTIAL;
input MA5_PriceSource = {default Close, Open, High, Low, HL2, HLC3, OHLC4};
input MA6_Len = 55;
input showMA6 = yes;
input MA6_AvgType = AverageType.EXPONENTIAL;
input MA6_PriceSource = {default Close, Open, High, Low, HL2, HLC3, OHLC4};
input MA7_Len = 144;
input showMA7 = yes;
input MA7_AvgType = AverageType.EXPONENTIAL;
input MA7_PriceSource = {default Close, Open, High, Low, HL2, HLC3, OHLC4};
input MA8_Len = 377;
input showMA8 = yes;
input MA8_AvgType = AverageType.EXPONENTIAL;
input MA8_PriceSource = {default Close, Open, High, Low, HL2, HLC3, OHLC4};

#---------------------------------------------------------------------------------------------
# Bar Safety – Max enabled MA length vs available bars
# Note: Used ONLY for the WARNING label. Does not prevent ToS "N/A" if extreme lengths cause the study to disappear.
#---------------------------------------------------------------------------------------------
def barCount = HighestAll(BarNumber());

def maxLenPart1 = Max(
    if showMA1 then MA1_Len else 0,
    if showMA2 then MA2_Len else 0
);

def maxLenPart2 = Max(
    if showMA3 then MA3_Len else 0,
    if showMA4 then MA4_Len else 0
);

def maxLenPart3 = Max(
    if showMA5 then MA5_Len else 0,
    if showMA6 then MA6_Len else 0
);

def maxLenPart4 = Max(
    if showMA7 then MA7_Len else 0,
    if showMA8 then MA8_Len else 0
);

def maxLen = Max(Max(maxLenPart1, maxLenPart2), Max(maxLenPart3, maxLenPart4));
def anyMAOn = maxLen > 0;
def enoughBarsForMaxLen = barCount >= maxLen * barMultiplier;

#---------------------------------------------------------------------------------------------
# Price Source Resolver — Close/Open/High/Low/HL2/HLC3/OHLC4 (PER-MA)
#---------------------------------------------------------------------------------------------
script SelectPrice {
    input priceSource = {default Close, Open, High, Low, HL2, HLC3, OHLC4};
    input o = 0.0;
    input h = 0.0;
    input l = 0.0;
    input c = 0.0;

    def src =
        if      priceSource == priceSource.Close then c
        else if priceSource == priceSource.Open  then o
        else if priceSource == priceSource.High  then h
        else if priceSource == priceSource.Low   then l
        else if priceSource == priceSource.HL2   then (h + l) / 2
        else if priceSource == priceSource.HLC3  then (h + l + c) / 3
        else (o + h + l + c) / 4;  # OHLC4

    plot out = src;
}

# Per-MA price series (all computed on the chart’s base timeframe)
def src1 = SelectPrice(MA1_PriceSource, open, high, low, close).out;
def src2 = SelectPrice(MA2_PriceSource, open, high, low, close).out;
def src3 = SelectPrice(MA3_PriceSource, open, high, low, close).out;
def src4 = SelectPrice(MA4_PriceSource, open, high, low, close).out;
def src5 = SelectPrice(MA5_PriceSource, open, high, low, close).out;
def src6 = SelectPrice(MA6_PriceSource, open, high, low, close).out;
def src7 = SelectPrice(MA7_PriceSource, open, high, low, close).out;
def src8 = SelectPrice(MA8_PriceSource, open, high, low, close).out;

#---------------------------------------------------------------------------------------------
# GLOBAL COLOR DEFINITIONS
#---------------------------------------------------------------------------------------------
# TRUE RAINBOW (VIBGYOR + Off-White) for Rainbow scheme
DefineGlobalColor("Rainbow1", CreateColor(255,   0,   0));   # Red
DefineGlobalColor("Rainbow2", CreateColor(255, 140,   0));   # Orange / DarkOrange-ish
DefineGlobalColor("Rainbow3", CreateColor(255, 215,   0));   # Gold / Yellow
DefineGlobalColor("Rainbow4", CreateColor(  0, 200,   0));   # Green
DefineGlobalColor("Rainbow5", CreateColor(102, 179, 255));   # Light Blue / SkyBlue-ish
DefineGlobalColor("Rainbow6", CreateColor(  0, 128, 255));   # Blue / DodgerBlue-ish
DefineGlobalColor("Rainbow7", CreateColor(128,   0, 255));   # Violet / Purple
DefineGlobalColor("Rainbow8", CreateColor(240, 240, 240));   # Off-White / Very Light Gray

# CLASSIC scheme
DefineGlobalColor("Classic1", Color.CYAN);
DefineGlobalColor("Classic2", Color.YELLOW);
DefineGlobalColor("Classic3", Color.MAGENTA);
DefineGlobalColor("Classic4", Color.GREEN);
DefineGlobalColor("Classic5", Color.RED);
DefineGlobalColor("Classic6", Color.WHITE);
DefineGlobalColor("Classic7", Color.GRAY);
DefineGlobalColor("Classic8", CreateColor(255, 165, 0));     # Orange

# DARK scheme (subdued for dark charts)
DefineGlobalColor("Dark1",  CreateColor(255,  64,  64));     # Soft Red / Light Dark-Red
DefineGlobalColor("Dark2",  CreateColor(255, 128,   0));     # Dark Orange / Amber
DefineGlobalColor("Dark3",  CreateColor(255, 255,  64));     # Soft Yellow / Lemon
DefineGlobalColor("Dark4",  CreateColor( 64, 255,  64));     # Soft Green / Light Neon Green
DefineGlobalColor("Dark5",  CreateColor( 64, 255, 255));     # Soft Cyan / Aqua
DefineGlobalColor("Dark6",  CreateColor( 64, 128, 255));     # Soft Blue / Cornflower-ish
DefineGlobalColor("Dark7",  CreateColor(128,  64, 255));     # Soft Purple / Blue-Violet
DefineGlobalColor("Dark8",  CreateColor(255,  64, 255));     # Soft Magenta / Fuchsia

DefineGlobalColor("Spacer", CreateColor(36, 36, 36));    # Dark Gray label spacer

#---------------------------------------------------------------------------------------------
# Effective Lengths (Lazy Engine) – length=1 when OFF (keeps OFF slots cheap while still compiling reliably)
#---------------------------------------------------------------------------------------------
def len1 = if showMA1 then MA1_Len else 1;
def len2 = if showMA2 then MA2_Len else 1;
def len3 = if showMA3 then MA3_Len else 1;
def len4 = if showMA4 then MA4_Len else 1;
def len5 = if showMA5 then MA5_Len else 1;
def len6 = if showMA6 then MA6_Len else 1;
def len7 = if showMA7 then MA7_Len else 1;
def len8 = if showMA8 then MA8_Len else 1;

#---------------------------------------------------------------------------------------------
# Plots – 8 MA Slots (Per-MA AvgType + Per-MA PriceSource)
#---------------------------------------------------------------------------------------------
plot MA1 = MovingAverage(MA1_AvgType, src1, len1);
MA1.SetHiding(!showMA1);

plot MA2 = MovingAverage(MA2_AvgType, src2, len2);
MA2.SetHiding(!showMA2);

plot MA3 = MovingAverage(MA3_AvgType, src3, len3);
MA3.SetHiding(!showMA3);

plot MA4 = MovingAverage(MA4_AvgType, src4, len4);
MA4.SetHiding(!showMA4);

plot MA5 = MovingAverage(MA5_AvgType, src5, len5);
MA5.SetHiding(!showMA5);

plot MA6 = MovingAverage(MA6_AvgType, src6, len6);
MA6.SetHiding(!showMA6);

plot MA7 = MovingAverage(MA7_AvgType, src7, len7);
MA7.SetHiding(!showMA7);

plot MA8 = MovingAverage(MA8_AvgType, src8, len8);
MA8.SetHiding(!showMA8);

#---------------------------------------------------------------------------------------------
# Color Scheme Logic – Slot -> (Rainbow / Classic / Dark)
#---------------------------------------------------------------------------------------------
def isRainbow = colorScheme == colorScheme.Rainbow;
def isClassic = colorScheme == colorScheme.Classic;

MA1.AssignValueColor(
    if isRainbow then GlobalColor("Rainbow1")
    else if isClassic then GlobalColor("Classic1")
    else GlobalColor("Dark1")
);

MA2.AssignValueColor(
    if isRainbow then GlobalColor("Rainbow2")
    else if isClassic then GlobalColor("Classic2")
    else GlobalColor("Dark2")
);

MA3.AssignValueColor(
    if isRainbow then GlobalColor("Rainbow3")
    else if isClassic then GlobalColor("Classic3")
    else GlobalColor("Dark3")
);

MA4.AssignValueColor(
    if isRainbow then GlobalColor("Rainbow4")
    else if isClassic then GlobalColor("Classic4")
    else GlobalColor("Dark4")
);

MA5.AssignValueColor(
    if isRainbow then GlobalColor("Rainbow5")
    else if isClassic then GlobalColor("Classic5")
    else GlobalColor("Dark5")
);

MA6.AssignValueColor(
    if isRainbow then GlobalColor("Rainbow6")
    else if isClassic then GlobalColor("Classic6")
    else GlobalColor("Dark6")
);

MA7.AssignValueColor(
    if isRainbow then GlobalColor("Rainbow7")
    else if isClassic then GlobalColor("Classic7")
    else GlobalColor("Dark7")
);

MA8.AssignValueColor(
    if isRainbow then GlobalColor("Rainbow8")
    else if isClassic then GlobalColor("Classic8")
    else GlobalColor("Dark8")
);

MA1.SetLineWeight(1);
MA2.SetLineWeight(1);
MA3.SetLineWeight(1);
MA4.SetLineWeight(1);
MA5.SetLineWeight(1);
MA6.SetLineWeight(1);
MA7.SetLineWeight(1);
MA8.SetLineWeight(1);

#---------------------------------------------------------------------------------------------
# Screen Labels Location
#---------------------------------------------------------------------------------------------
def tfLblLoc =
    if MaLabelLocation == MaLabelLocation."Top-Left" then Location.TOP_LEFT
    else if MaLabelLocation == MaLabelLocation."Top-Right" then Location.TOP_RIGHT
    else if MaLabelLocation == MaLabelLocation."Bottom-Left" then Location.BOTTOM_LEFT
    else Location.BOTTOM_RIGHT;

#---------------------------------------------------------------------------------------------
# Header Labels – Title + Bars + Bar Multiplier + WARNING (bar-safety)
#---------------------------------------------------------------------------------------------
AddLabel(
    showLabels,
    "   Fibonacci MA's   ",
    Color.LIGHT_GREEN, location = tfLblLoc
);

AddLabel(
    showLabels,
    "  Bars  " + barCount
    + "   | Bar Multiplier  " + barMultiplier
    + "   ",
    Color.LIGHT_GRAY, location = tfLblLoc
);

AddLabel(
    showLabels and anyMAOn and !enoughBarsForMaxLen,
    "  WARNING: Not enough bars for max length (" + maxLen + ")  | Bars=" + barCount
    + "  | Need ≥ " + (maxLen * barMultiplier) + "  ",
    Color.RED, location = tfLblLoc
);

AddLabel(showLabels, "  ", GlobalColor("Spacer"), location = tfLblLoc); # Visual spacer

#---------------------------------------------------------------------------------------------
# MA Labels – "Length | AvgType | PriceSource" with matching line color
#---------------------------------------------------------------------------------------------
AddLabel(
    showLabels and showMA1,
    "  " + MA1_Len
    + "  |  "
    + (
        if MA1_AvgType == AverageType.SIMPLE      then "SMA"
        else if MA1_AvgType == AverageType.EXPONENTIAL then "EMA"
        else if MA1_AvgType == AverageType.WEIGHTED    then "WMA"
        else if MA1_AvgType == AverageType.WILDERS     then "Wilder"
        else "Hull"
      )
    + "  |  "
    + (
        if MA1_PriceSource == MA1_PriceSource.Close then "Close"
        else if MA1_PriceSource == MA1_PriceSource.Open then "Open"
        else if MA1_PriceSource == MA1_PriceSource.High then "High"
        else if MA1_PriceSource == MA1_PriceSource.Low then "Low"
        else if MA1_PriceSource == MA1_PriceSource.HL2 then "HL2"
        else if MA1_PriceSource == MA1_PriceSource.HLC3 then "HLC3"
        else "OHLC4"
      )
    + "  ",
    if isRainbow then GlobalColor("Rainbow1")
    else if isClassic then GlobalColor("Classic1")
    else GlobalColor("Dark1"), location = tfLblLoc
);

AddLabel(
    showLabels and showMA2,
    "  " + MA2_Len
    + "  |  "
    + (
        if MA2_AvgType == AverageType.SIMPLE then "SMA"
        else if MA2_AvgType == AverageType.EXPONENTIAL then "EMA"
        else if MA2_AvgType == AverageType.WEIGHTED then "WMA"
        else if MA2_AvgType == AverageType.WILDERS then "Wilder"
        else "Hull"
      )
    + "  |  "
    + (
        if MA2_PriceSource == MA2_PriceSource.Close then "Close"
        else if MA2_PriceSource == MA2_PriceSource.Open then "Open"
        else if MA2_PriceSource == MA2_PriceSource.High then "High"
        else if MA2_PriceSource == MA2_PriceSource.Low then "Low"
        else if MA2_PriceSource == MA2_PriceSource.HL2 then "HL2"
        else if MA2_PriceSource == MA2_PriceSource.HLC3 then "HLC3"
        else "OHLC4"
      )
    + "  ",
    if isRainbow then GlobalColor("Rainbow2")
    else if isClassic then GlobalColor("Classic2")
    else GlobalColor("Dark2"), location = tfLblLoc
);

AddLabel(
    showLabels and showMA3,
    "  " + MA3_Len
    + "  |  "
    + (
        if MA3_AvgType == AverageType.SIMPLE then "SMA"
        else if MA3_AvgType == AverageType.EXPONENTIAL then "EMA"
        else if MA3_AvgType == AverageType.WEIGHTED then "WMA"
        else if MA3_AvgType == AverageType.WILDERS then "Wilder"
        else "Hull"
      )
    + "  |  "
    + (
        if MA3_PriceSource == MA3_PriceSource.Close then "Close"
        else if MA3_PriceSource == MA3_PriceSource.Open then "Open"
        else if MA3_PriceSource == MA3_PriceSource.High then "High"
        else if MA3_PriceSource == MA3_PriceSource.Low then "Low"
        else if MA3_PriceSource == MA3_PriceSource.HL2 then "HL2"
        else if MA3_PriceSource == MA3_PriceSource.HLC3 then "HLC3"
        else "OHLC4"
      )
    + "  ",
    if isRainbow then GlobalColor("Rainbow3")
    else if isClassic then GlobalColor("Classic3")
    else GlobalColor("Dark3"), location = tfLblLoc
);

AddLabel(
    showLabels and showMA4,
    "  " + MA4_Len
    + "  |  "
    + (
        if MA4_AvgType == AverageType.SIMPLE then "SMA"
        else if MA4_AvgType == AverageType.EXPONENTIAL then "EMA"
        else if MA4_AvgType == AverageType.WEIGHTED then "WMA"
        else if MA4_AvgType == AverageType.WILDERS then "Wilder"
        else "Hull"
      )
    + "  |  "
    + (
        if MA4_PriceSource == MA4_PriceSource.Close then "Close"
        else if MA4_PriceSource == MA4_PriceSource.Open then "Open"
        else if MA4_PriceSource == MA4_PriceSource.High then "High"
        else if MA4_PriceSource == MA4_PriceSource.Low then "Low"
        else if MA4_PriceSource == MA4_PriceSource.HL2 then "HL2"
        else if MA4_PriceSource == MA4_PriceSource.HLC3 then "HLC3"
        else "OHLC4"
      )
    + "  ",
    if isRainbow then GlobalColor("Rainbow4")
    else if isClassic then GlobalColor("Classic4")
    else GlobalColor("Dark4"), location = tfLblLoc
);

AddLabel(
    showLabels and showMA5,
    "  " + MA5_Len
    + "  |  "
    + (
        if MA5_AvgType == AverageType.SIMPLE then "SMA"
        else if MA5_AvgType == AverageType.EXPONENTIAL then "EMA"
        else if MA5_AvgType == AverageType.WEIGHTED then "WMA"
        else if MA5_AvgType == AverageType.WILDERS then "Wilder"
        else "Hull"
      )
    + "  |  "
    + (
        if MA5_PriceSource == MA5_PriceSource.Close then "Close"
        else if MA5_PriceSource == MA5_PriceSource.Open then "Open"
        else if MA5_PriceSource == MA5_PriceSource.High then "High"
        else if MA5_PriceSource == MA5_PriceSource.Low then "Low"
        else if MA5_PriceSource == MA5_PriceSource.HL2 then "HL2"
        else if MA5_PriceSource == MA5_PriceSource.HLC3 then "HLC3"
        else "OHLC4"
      )
    + "  ",
    if isRainbow then GlobalColor("Rainbow5")
    else if isClassic then GlobalColor("Classic5")
    else GlobalColor("Dark5"), location = tfLblLoc
);

AddLabel(
    showLabels and showMA6,
    "  " + MA6_Len
    + "  |  "
    + (
        if MA6_AvgType == AverageType.SIMPLE then "SMA"
        else if MA6_AvgType == AverageType.EXPONENTIAL then "EMA"
        else if MA6_AvgType == AverageType.WEIGHTED then "WMA"
        else if MA6_AvgType == AverageType.WILDERS then "Wilder"
        else "Hull"
      )
    + "  |  "
    + (
        if MA6_PriceSource == MA6_PriceSource.Close then "Close"
        else if MA6_PriceSource == MA6_PriceSource.Open then "Open"
        else if MA6_PriceSource == MA6_PriceSource.High then "High"
        else if MA6_PriceSource == MA6_PriceSource.Low then "Low"
        else if MA6_PriceSource == MA6_PriceSource.HL2 then "HL2"
        else if MA6_PriceSource == MA6_PriceSource.HLC3 then "HLC3"
        else "OHLC4"
      )
    + "  ",
    if isRainbow then GlobalColor("Rainbow6")
    else if isClassic then GlobalColor("Classic6")
    else GlobalColor("Dark6"), location = tfLblLoc
);

AddLabel(
    showLabels and showMA7,
    "  " + MA7_Len
    + "  |  "
    + (
        if MA7_AvgType == AverageType.SIMPLE then "SMA"
        else if MA7_AvgType == AverageType.EXPONENTIAL then "EMA"
        else if MA7_AvgType == AverageType.WEIGHTED then "WMA"
        else if MA7_AvgType == AverageType.WILDERS then "Wilder"
        else "Hull"
      )
    + "  |  "
    + (
        if MA7_PriceSource == MA7_PriceSource.Close then "Close"
        else if MA7_PriceSource == MA7_PriceSource.Open then "Open"
        else if MA7_PriceSource == MA7_PriceSource.High then "High"
        else if MA7_PriceSource == MA7_PriceSource.Low then "Low"
        else if MA7_PriceSource == MA7_PriceSource.HL2 then "HL2"
        else if MA7_PriceSource == MA7_PriceSource.HLC3 then "HLC3"
        else "OHLC4"
      )
    + "  ",
    if isRainbow then GlobalColor("Rainbow7")
    else if isClassic then GlobalColor("Classic7")
    else GlobalColor("Dark7"), location = tfLblLoc
);

AddLabel(
    showLabels and showMA8,
    "  " + MA8_Len
    + "  |  "
    + (
        if MA8_AvgType == AverageType.SIMPLE then "SMA"
        else if MA8_AvgType == AverageType.EXPONENTIAL then "EMA"
        else if MA8_AvgType == AverageType.WEIGHTED then "WMA"
        else if MA8_AvgType == AverageType.WILDERS then "Wilder"
        else "Hull"
      )
    + "  |  "
    + (
        if MA8_PriceSource == MA8_PriceSource.Close then "Close"
        else if MA8_PriceSource == MA8_PriceSource.Open then "Open"
        else if MA8_PriceSource == MA8_PriceSource.High then "High"
        else if MA8_PriceSource == MA8_PriceSource.Low then "Low"
        else if MA8_PriceSource == MA8_PriceSource.HL2 then "HL2"
        else if MA8_PriceSource == MA8_PriceSource.HLC3 then "HLC3"
        else "OHLC4"
      )
    + "  ",
    if isRainbow then GlobalColor("Rainbow8")
    else if isClassic then GlobalColor("Classic8")
    else GlobalColor("Dark8"), location = tfLblLoc
);


AddLabel(showLabels, "  ", GlobalColor("Spacer"), location = tfLblLoc); # Visual spacer between other active studies
 

Attachments

  • thinkorswim_VFQUyJM19z.png
    thinkorswim_VFQUyJM19z.png
    182.9 KB · Views: 95
Last edited:

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
807 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