Scalper's Volatility Filter For ThinkOrSwim

The Author's states:
The ๐’ฎ๐’ธ๐’ถ๐“๐“…๐‘’๐“‡'๐“ˆ ๐’ฑ๐‘œ๐“๐’ถ๐“‰๐’พ๐“๐’พ๐“‰๐“Ž ๐น๐’พ๐“๐“‰๐‘’๐“‡ (๐’ฎ๐’ฑ๐น) is a sophisticated technical indicator, designed to increase the profitability of lower timeframe trading.
Due to the inherent decrease in the signal-to-noise ratio when trading on lower timeframes, it is critical to develop analysis methods to inform traders of the optimal market periods to trade - and more importantly, when you shouldnโ€™t trade.
The ๐’ฎ๐’ฑ๐น uses a blend of volatility and momentum measurements, to signal the dominant market condition - trending or ranging.

The ๐’ฎ๐’ฑ๐น consists of a signal line that moves above and below a central zero line, serving as the indication of market regime.
  • When the signal line is positioned above zero, it indicates a period of elevated volatility. These periods are more profitable for trading, as an asset will experience larger price swings, and by design, trend-following indicators will give less false signals.
  • Conversely, when the signal line moves below zero, a low volatility or mean-reverting market regime dominates.
fPGO5iB.png


https://www.tradingview.com/script/VpeVyX0N-Scalper-s-Volatility-Filter-QuantraAI/

 
Last edited by a moderator:

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

UPDATE - 07 /2024
  • Modified normalization logic.
  • Added 'Compressed Signal Mode'.
  • Added a Heikin Ashi volatility visualization - for faster measurements.
  • Added 'HA-Width' another experimental measure of volatility.
  • Added MTF capability.

CODE:
CSS:
#// Indicator forceIndex TOS
#// ยฉ QuantraAI
#indicator("Scalper's Volatility Filter", "SVF",
# Converted by Sam4Cok@Samer800    - 02/2024
# Updated by Sam4Cok@Samer800    - 07/2024 - Added MTF
declare lower;
input useChartTimeframe =  {default "Yes", "No"};
input manualTimeframe   = AggregationPeriod.FIFTEEN_MIN;
input displayType   = {Default "Line", "Histogram", "Heikin-Ashi", "HA-Width"}; # "Display Type"
input Speed           = 10;                 #  "Speed"
input BaseAtrLength   = 13;                 #  "Base ATR Length"
input SecondAtrLength = 40;                 #  "Second ATR Length"
input BaseStdDevLength   = 20;              # "Base StdDev"
input SecondStdDevLength = 100;             # "Second StdDev"
input AdxSmoothingLength = 14;              # "ADX Smoothing"
input adxThreshold     = 25;                # "ADX Baseline"
input diLength         = 14;                # "DI Length"
input RegressionLength = 20;                # "Regression Length"
input RegressionSensitivity = 350;          # "Regression Sensitivity"
input HistoricalVolatilityLookback = 50;    # "Historical Volatility Lookback"
input colorBars      = no;                  # "Bar Coloring"
input HollowCandles  = yes;                 # "Hollow Candles"
input CompressedMode = no;                  # "Compressed Mode"
input showLabel      = yes;                 # "Labels"


def na = Double.NaN;
def last = IsNaN(close);
#-- MTF
def cl; def hi; def lo;
Switch (useChartTimeframe) {
case "No"  :
    cl = close(Period=manualTimeframe);
    hi = high(Period=manualTimeframe);
    lo = low(Period=manualTimeframe);
Default :
    cl = close;
    hi = high;
    lo = low;
}
#//    Functions    //
#// Modified Damiani Voltemter // Credit to @xinolia
script DV {
    input src = close;
    input vis_atr = 13;
    input vis_std = 20;
    input sed_atr = 40;
    input sed_std = 100;
    input h = high;
    input c = close;
    input l = low;
    def tr = TrueRange(h, c, l);
    def lag_s_K = 0.5;
    def vol;
    def visAtr = WildersAverage(tr, vis_atr);
    def sedAtr = WildersAverage(tr, sed_atr);
    def visStd = StDev(src, vis_std);
    def sedStd = StDev(src, sed_std);
    def anti_thres = visStd / sedStd;
    def t1 = 1.4 - anti_thres;
    def s1 = CompoundValue(1, vol[1], 0);
    def s3 = CompoundValue(1, vol[3], 0);
        vol = CompoundValue(1, visAtr / sedAtr + lag_s_K * (s1 - s3), t1);
    def th = t1 - vol;
    def DV = -th * 100;
    plot out = if IsNaN(DV) then 0 else DV;
}
#// Average Directional Index
script nADX {
    input dilen = 14;
    input adxlen = 14;
    input h = high;
    input c = close;
    input l = low;
    def tr = TrueRange(h, c, l);
    def hiDiff = h - h[1];
    def loDiff = l[1] - l;
    def plusDM = if hiDiff > loDiff and hiDiff > 0 then hiDiff else 0;
    def minusDM =  if loDiff > hiDiff and loDiff > 0 then loDiff else 0;
    def ATR = WildersAverage(tr, dilen);
    def "DI+" = 100 * WildersAverage(plusDM, dilen) / ATR;
    def "DI-" = 100 * WildersAverage(minusDM, dilen) / ATR;
    def DX = if ("DI+" + "DI-" > 0) then 100 * AbsValue("DI+" - "DI-") / ("DI+" + "DI-") else 0;
    def nADX = WildersAverage(DX, adxlen);
    plot out = nADX;
}
#// Linear Regression Dispersion
script dispersion {
    input src = close;
    input period = 20;
    input TrSens = 350;
    def linRegLine = Inertia(src, period);
    def tes = StDev(src - linRegLine, period);
    def median = Median(tes, TrSens);
    def dispersion = (tes - median) / 2;
    plot out = dispersion;
}
Script normalize {
input currentValue = close;
input targetMin = -100;
input targetMax = 100;
input window = 100;
    def targetDiff = (targetMax - targetMin);
    def dynCurrentVal = CompoundValue(1, currentValue, 0);
    def minValue   = lowest(dynCurrentVal, window);
    def maxValue   = highest(dynCurrentVal, window);
    def minNew     = min(dynCurrentVal, minValue);
    def maxNew     = max(dynCurrentVal, maxValue);
    def newDiff = (maxNew - minNew);
    def scale = targetMin + targetDiff * (dynCurrentVal - minNew) / newDiff;
    def norm = if minValue!= maxValue then scale else dynCurrentVal;
    plot out = if isNaN(norm) then 0 else norm;
}
#//  โ•‘      CALCULATE RAW VALUES      โ•‘  //
def dvmR = DV(cl , BaseAtrLength, BaseStdDevLength, SecondAtrLength, SecondStdDevLength, hi, cl, lo);
def sigR = (nADX(diLength, AdxSmoothingLength, hi, cl, lo) - adxThreshold) * 3;
def disR = dispersion(cl, RegressionLength, RegressionSensitivity);
#//  โ•‘ PREPROCESSING BY NORMALIZATION โ•‘  //
def dvm = normalize(dvmR, -100, 100, Speed * 10);
def sig = normalize(sigR, -100, 100, Speed * 10);
def dis = normalize(disR, -100, 100, Speed * 10);
#//  โ•‘     CUSTOM 'MEAN' FUNCTION     โ•‘  //
def sumDVM = if !isNaN(dvm) then dvm else 0;
def sumSIG = if !isNaN(sig) then sig else 0;
def sumDIS = if !isNaN(dis) then dis else 0;
def cntDVM = if !isNaN(dvm) then 1 else 0;
def cntSIG = if !isNaN(sig) then 1 else 0;
def cntDIS = if !isNaN(dis) then 1 else 0;
def sum = sumDVM + sumSIG + sumDIS;
def cnt = cntDVM + cntSIG + cntDIS;
def av  = if last then na else if cnt > 0 then sum / cnt else 0;
#// Function to calculate Heikin Ashi values
def o = if isNaN(av[1]) then av else av[1];
def h = Max(av, av[1]);
def l = Min(av, av[1]);
def c = av;
def xc = (o + h + l + c) / 4;
def xo = CompoundValue(1, if !xo[1] then (o + c) / 2 else (xo[1] + xc[1]) / 2, (o + c) / 2);
def xh = max(h, max(xo, xc));
def xl = min(l, min(xo, xc));
def hac = xc;
def hao = xo;
def hah = xh;
def hal = xl;
#//  โ•‘           HA WIDTH             โ•‘  //
def volatility            = AbsValue(hac - hao);
def Hisotrical_Volatility = Average(volatility, HistoricalVolatilityLookback);
def col; def disp;
Switch (displayType) {
Case "Histogram" :
    col = if av > 0 then if av > av[1] then  2 else  1 else
          if av < 0 then if av < av[1] then -1 else -2 else 0;
    disp = if last then na else 2;
Case "Heikin-Ashi" :
    col = if hac > hao then 2 else 1;
    disp = if last then na else 3;
Case "HA-Width" :
    col = if volatility < Hisotrical_Volatility then -2 else
          if hac > hao then 2 else 1;
    disp = if last then na else 4;
Default :
    col = if av > 0 then if av > av[1] then  2 else 1 else
          if av < 0 then if av < av[1] then -1 else -2 else 0;
    disp = if last then na else 1;
}
# Heikin Ashi Style
def up = !CompressedMode and disp==3 and col==2;
def dn = !CompressedMode and disp==3 and col==1;
def upO = if HollowCandles then hao else hac;
def upC = if HollowCandles then hac else hao;

def dnO = if HollowCandles then hac else hao;
def dnC = if HollowCandles then hao else hac;

# -- Display
plot CompressedLine = if CompressedMode and !last then 0 else na;
plot pavHist = if !CompressedMode and disp==2 then av else na; # "Average Volatility Hist"
plot pavLine = if !CompressedMode and disp==1 then av else na; # "Average Volatility Cross"
plot pavAvgHa = if !CompressedMode and disp==4 then Hisotrical_Volatility else na; # "Average HA Volatility
plot pavWidth = if !CompressedMode and disp==4 then volatility else na; # "HA Volatility Width"
plot zeroLine = if !CompressedMode and !last then 0 else na;    # "Zero Line"
zeroLine.SetDefaultColor(Color.GRAY);
CompressedLine.SetLineWeight(5);
CompressedLine.SetPaintingStrategy(PaintingStrategy.SQUARES);
CompressedLine.AssignValueColor(if col== 2 then Color.CYAN else
                         if col== 1 then Color.MAGENTA else
                         if col==-2 then Color.DARK_GRAY else Color.LIGHT_GRAY);
pavHist.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
pavHist.AssignValueColor(if col== 2 then Color.CYAN else
                         if col== 1 then Color.MAGENTA else
                         if col==-2 then Color.DARK_GRAY else Color.LIGHT_GRAY);
pavLine.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
pavLine.AssignValueColor(if col== 2 then Color.CYAN else
                         if col== 1 then Color.MAGENTA else
                         if col==-2 then Color.DARK_GRAY else Color.LIGHT_GRAY);
pavWidth.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
pavWidth.AssignValueColor(if col== 2 then Color.CYAN else
                          if col== 1 then Color.MAGENTA else
                          if col==-2 then Color.DARK_GRAY else Color.LIGHT_GRAY);
pavAvgHa.SetDefaultColor(Color.ORANGE);
pavAvgHa.SetLineWeight(2);

# Heikin Ashi Candles

AddChart(open = if up then upO else na, high = if up then hah else na , low = hal , close = upC,
         type = ChartType.CANDLE, growcolor = Color.CYAN);
AddChart(open = if dn then dnO else na, high = if dn then hah else na , low = hal , close = dnC,
         type = ChartType.CANDLE, growcolor = Color.MAGENTA);

#-- bar color
AssignPriceColor(if !colorBars then Color.CURRENT else
                 if col== 2 then Color.CYAN else
                 if col== 1 then Color.MAGENTA else
                 if col==-2 then Color.DARK_GRAY else Color.LIGHT_GRAY);
#-- Label
#// Output Stream (For Quantra's Trading Station)

AddLabel(showLabel and col == 2, "Volatility Up!", Color.CYAN);
AddLabel(showLabel and col == 1, "Volatility Dn!", Color.MAGENTA);
AddLabel(showLabel and col <= 0, "No Volatility!", if col < 1 then Color.DARK_GRAY else Color.LIGHT_GRAY);


#-- END of CODE


CODE - 02/2024
CSS:
#/ This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// ยฉ QuantraAI
#indicator("Scalper's Volatility Filter", "SVF", false, timeframe = '', timeframe_gaps = false)
# Converted by Sam4Cok@Samer800    - 02/2024
declare lower;

input DisplayType = {default "Crosses", "Histogram"};     # " Display Type"
input BaseAtrLength = 13;             # "Base ATR Length"
input SecondAtrLength = 40;           # "Second ATR Length"
input BaseStdDevLength = 20;          # "Base StdDev"
input SecondStdDevLength = 100;       # "Second StdDev"
input adxSmoothing  = 14;             # "ADX Smoothing"
input diLength   = 14;                # "DI Length"
input adxBaseline = 25;               # "ADX Baseline"
input RegressionLengt  = 20;          # "Regression Length"
input RegressionSensitivity  = 350;   # "Regression Sensitivity"
input BarColoring    = no;            # "Bar Coloring"
input showLabel      = yes;


def na = Double.NaN;
def last = IsNaN(close);
def his = DisplayType==DisplayType."Histogram";
#//    Functions    //
#// Modified Damiani Voltemter                // Credit to @xinolia
script DV {
    input src = close;
    input vis_atr = 13;
    input vis_std = 20;
    input sed_atr = 40;
    input sed_std = 100;
    def lag_s_K = 0.5;
    def vol;
    def s1 = if IsNaN(vol[1]) then 0 else vol[1];
    def s3 = if IsNaN(vol[3]) then 0 else vol[3];
    def visAtr = ATR(Length = vis_atr);
    def sedAtr = ATR(Length = sed_atr);
    def visStd = StDev(src, vis_std);
    def sedStd = StDev(src, sed_std);
    vol = visAtr / sedAtr + lag_s_K * (s1 - s3);
    def anti_thres = visStd / sedStd;
    def t1 = 1.4 - anti_thres;
    def t = t1 - vol;
    def DV = -t * 100;
    plot out = if IsNaN(DV) then 0 else DV;
}
#// Average Directional Index
script nADX {
    input dilen = 14;
    input adxlen = 14;
    def averageType = AverageType.WILDERS;
    def hiDiff = high - high[1];
    def loDiff = low[1] - low;
    def plusDM = if hiDiff > loDiff and hiDiff > 0 then hiDiff else 0;
    def minusDM =  if loDiff > hiDiff and loDiff > 0 then loDiff else 0;
    def ATR = MovingAverage(averageType, TrueRange(high, close, low), dilen);
    def "DI+" = 100 * MovingAverage(averageType, plusDM, dilen) / ATR;
    def "DI-" = 100 * MovingAverage(averageType, minusDM, dilen) / ATR;
    def DX = if ("DI+" + "DI-" > 0) then 100 * AbsValue("DI+" - "DI-") / ("DI+" + "DI-") else 0;
    def nADX = MovingAverage(averageType, DX, adxlen);
    plot out = nADX;
}
#// Linear Regression Dispersion
script dispersion {
    input period = 20;
    input TrSens = 350;
    def linRegLine = Inertia(close, period);
    def tes = StDev(close - linRegLine, period);
    def dispersion = (tes - Median(tes, TrSens)) / 2;
    plot out = dispersion;
}

# /    Calculations    //
def dvm = DV(close, BaseAtrLength, BaseStdDevLength, SecondAtrLength, SecondStdDevLength);
def sig = (nADX(diLength, adxSmoothing) - adxBaseline) * 3;
def dis = dispersion(RegressionLengt, RegressionSensitivity);
def av  = (dvm + sig + dis) / 3;
def clr = if av > 0 then if av > av[1] then 2 else -2 else
          if av < 0 then if av < av[1] then 1 else -1 else 0;

plot pavHist = if his then av else na;#, "Average Volatility", clr, 3, disp)
plot pavLine = if his then na else av; #, "Average Volatility", clr, 3, disp)
plot zeroLine = if last then na else 0; #,  "Zero Line", color.white, 1)
zeroLine.SetDefaultColor(Color.GRAY);
pavHist.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
pavHist.AssignValueColor(if clr== 2 then Color.CYAN else
                         if clr==-2 then Color.MAGENTA else
                         if clr== 1 then Color.DARK_GRAY else Color.LIGHT_GRAY);
pavLine.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
pavLine.AssignValueColor(if clr== 2 then Color.CYAN else
                         if clr==-2 then Color.MAGENTA else
                         if clr== 1 then Color.DARK_GRAY else Color.LIGHT_GRAY);
AssignPriceColor(if !BarColoring then Color.CURRENT else
                 if clr== 2 then Color.CYAN else
                 if clr==-2 then Color.MAGENTA else
                 if clr== 1 then Color.DARK_GRAY else Color.LIGHT_GRAY);
#-- Label
#// Output Stream (For Quantra's Trading Station)
def stream1  = if av > 0 then 1 else 0;
def stream = if !clr then 0 else stream1;

AddLabel(showLabel and stream > 0, "Market Trending!", if clr > 0 then Color.CYAN else Color.MAGENTA);
AddLabel(showLabel and stream == 0, "Market Ranging!", if clr > 0 then Color.DARK_GRAY else Color.LIGHT_GRAY);


#-- END of CODE
 
Last edited:
Thank you for posting this Vol tool, it's exactly what I was looking for and it has done a lot to keep me out of trouble. Do you have a scanner for this? I was able to convert the code into one but it will not run for anything between 15min and 2 hrs. I have no clue as to why. Any advice?
 
Thank you for posting this Vol tool, it's exactly what I was looking for and it has done a lot to keep me out of trouble. Do you have a scanner for this? I was able to convert the code into one but it will not run for anything between 15min and 2 hrs. I have no clue as to why. Any advice?

You did not provide your scan code so it is not possible to say where you went astray.

Scalper's Volatility Filter Scan:
Add this to the bottom of your study:
plot scan = clr == 2 and clr[1] !=2 ;
scan.hide();

Your scan filter condition is:
scan is true

To set up your filter in the scan hacker, follow this tutorial:
https://usethinkscript.com/threads/how-to-use-thinkorswim-stock-hacker-scans.284/

a2KPfhF.png
 
Last edited by a moderator:
The Author's states:
The ๐’ฎ๐’ธ๐’ถ๐“๐“…๐‘’๐“‡'๐“ˆ ๐’ฑ๐‘œ๐“๐’ถ๐“‰๐’พ๐“๐’พ๐“‰๐“Ž ๐น๐’พ๐“๐“‰๐‘’๐“‡ (๐’ฎ๐’ฑ๐น) is a sophisticated technical indicator, designed to increase the profitability of lower timeframe trading.
Due to the inherent decrease in the signal-to-noise ratio when trading on lower timeframes, it is critical to develop analysis methods to inform traders of the optimal market periods to trade - and more importantly, when you shouldnโ€™t trade.
The ๐’ฎ๐’ฑ๐น uses a blend of volatility and momentum measurements, to signal the dominant market condition - trending or ranging.

The ๐’ฎ๐’ฑ๐น consists of a signal line that moves above and below a central zero line, serving as the indication of market regime.
  • When the signal line is positioned above zero, it indicates a period of elevated volatility. These periods are more profitable for trading, as an asset will experience larger price swings, and by design, trend-following indicators will give less false signals.
  • Conversely, when the signal line moves below zero, a low volatility or mean-reverting market regime dominates.
fPGO5iB.png


https://www.tradingview.com/script/VpeVyX0N-Scalper-s-Volatility-Filter-QuantraAI/

I like all the technical analysis posted on Think Script including this one on volatility. I went to the Trading View website for more info. The chart on ETH seems to have some conflicting views on how to interpret the method .I am attaching the view. Please look at data on the 12th.Help me understand there comments on why not long. Many thanks.
 

Attachments

  • IMG_7135.jpg
    IMG_7135.jpg
    280.4 KB · Views: 378
I like all the technical analysis posted on Think Script including this one on volatility. I went to the Trading View website for more info. The chart on ETH seems to have some conflicting views on how to interpret the method .I am attaching the view. Please look at data on the 12th.Help me understand there comments on why not long. Many thanks.
Here is a code that when the market trend is increasing it turns green for an up trend, red for a down trend, magenta when the trend strength is decreasing, and gray when the market is ranging.
Screen Shot 2024-05-29 at 7.52.18 PM.png


Here is the full code :
Code:
declare lower;

input DisplayType = {default "Crosses", "Histogram"};
input BaseAtrLength = 13;
input SecondAtrLength = 40;
input BaseStdDevLength = 20;
input SecondStdDevLength = 100;
input adxSmoothing = 14;
input diLength = 14;
input adxBaseline = 25;
input RegressionLength = 20;
input RegressionSensitivity = 350;
input BarColoring = no;
input showLabel = yes;

def na = Double.NaN;
def last = IsNaN(close);
def his = DisplayType == DisplayType.Histogram;

script DV {
    input src = close;
    input vis_atr = 13;
    input vis_std = 20;
    input sed_atr = 40;
    input sed_std = 100;
    def lag_s_K = 0.5;
    def vol;
    def s1 = if IsNaN(vol[1]) then 0 else vol[1];
    def s3 = if IsNaN(vol[3]) then 0 else vol[3];
    def visAtr = ATR(vis_atr);
    def sedAtr = ATR(sed_atr);
    def visStd = StDev(src, vis_std);
    def sedStd = StDev(src, sed_std);
    vol = visAtr / sedAtr + lag_s_K * (s1 - s3);
    def anti_thres = visStd / sedStd;
    def t1 = 1.4 - anti_thres;
    def t = t1 - vol;
    def DV = -t * 100;
    plot out = if IsNaN(DV) then 0 else DV;
}

script nADX {
    input dilen = 14;
    input adxlen = 14;
    def averageType = AverageType.WILDERS;
    def hiDiff = high - high[1];
    def loDiff = low[1] - low;
    def plusDM = if hiDiff > loDiff and hiDiff > 0 then hiDiff else 0;
    def minusDM = if loDiff > hiDiff and loDiff > 0 then loDiff else 0;
    def ATR = MovingAverage(averageType, TrueRange(high, close, low), dilen);
    def DIPlus = 100 * MovingAverage(averageType, plusDM, dilen) / ATR;
    def DIMinus = 100 * MovingAverage(averageType, minusDM, dilen) / ATR;
    def DX = if (DIPlus + DIMinus > 0) then 100 * AbsValue(DIPlus - DIMinus) / (DIPlus + DIMinus) else 0;
    def nADX = MovingAverage(averageType, DX, adxlen);
    plot out = nADX;
}

script dispersion {
    input period = 20;
    input TrSens = 350;
    def linRegLine = Inertia(close, period);
    def tes = StDev(close - linRegLine, period);
    def dispersion = (tes - Median(tes, TrSens)) / 2;
    plot out = dispersion;
}

def dvm = DV(close, BaseAtrLength, BaseStdDevLength, SecondAtrLength, SecondStdDevLength);
def sig = (nADX(diLength, adxSmoothing) - adxBaseline) * 3;
def dis = dispersion(RegressionLength, RegressionSensitivity);
def av = (dvm + sig + dis) / 3;
def clr = if av > 0 then if av > av[1] then 2 else -2 else if av < 0 then if av < av[1] then 1 else -1 else 0;

plot pavHist = if his then av else na;
plot pavLine = if his then na else av;
plot zeroLine = if last then na else 0;
zeroLine.SetDefaultColor(Color.GRAY);
pavHist.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
pavHist.AssignValueColor(if clr == 2 then Color.CYAN else if clr == -2 then Color.MAGENTA else if clr == 1 then Color.DARK_GRAY else Color.LIGHT_GRAY);
pavLine.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);


#_____________________________________________________
 input dilen = 14;
    input adxlen = 14;
    def averageType = AverageType.WILDERS;
    def hiDiff = high - high[1];
    def loDiff = low[1] - low;
    def plusDM = if hiDiff > loDiff and hiDiff > 0 then hiDiff else 0;
    def minusDM = if loDiff > hiDiff and loDiff > 0 then loDiff else 0;
    def ATR = MovingAverage(averageType, TrueRange(high, close, low), dilen);
    def DIPlus = 100 * MovingAverage(averageType, plusDM, dilen) / ATR;
    def DIMinus = 100 * MovingAverage(averageType, minusDM, dilen) / ATR;



pavLine.AssignValueColor(if clr == 2 and (DIminus >  DIPlus) then color.red else if clr == 2 and ( DIminus <  DIPlus) then color.green else if clr == 2 then Color.CYAN else if clr == -2 then Color.MAGENTA else if clr == 1 then Color.DARK_GRAY else Color.LIGHT_GRAY);


#_____________________________________________________
#pavLine.AssignValueColor(if clr == 2 then Color.CYAN else if clr == -2 then Color.MAGENTA else if clr == 1 then Color.DARK_GRAY else Color.LIGHT_GRAY);

AssignPriceColor(if !BarColoring then Color.CURRENT else if clr == 2 then Color.CYAN else if clr == -2 then Color.MAGENTA else if clr == 1 then Color.DARK_GRAY else Color.LIGHT_GRAY);

def stream1 = if av > 0 then 1 else 0;
def stream = if clr == 0 then 0 else stream1;

AddLabel(showLabel and stream > 0, "Market Trending!", if clr > 0 then Color.CYAN else Color.MAGENTA);
AddLabel(showLabel and stream == 0, "Market Ranging!", if clr > 0 then Color.DARK_GRAY else Color.LIGHT_GRAY);
 
Last edited by a moderator:
I like all the technical analysis posted on Think Script including this one on volatility. I went to the Trading View website for more info. The chart on ETH seems to have some conflicting views on how to interpret the method .I am attaching the view. Please look at data on the 12th.Help me understand there comments on why not long. Many thanks.
The coloring is deceptive. The indicator he is using to color the bars on the chart is not the volatility indicator but something else he is using as a trigger. If you place your mouse on the first blue bar on the chart and scroll downward with the mouse wheel, you'll see that the volatility indicator is in the gray.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
318 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