Scalper's Volatility Filter For ThinkOrSwim

Darth Tradicus

Member
VIP
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:
check the below:

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

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