StockFetcher Forums · Filter Exchange · RVOL Scan with 95% Buying Bar<< >>Post Follow-up
kmadnani
17 posts
msg #153146
Ignore kmadnani
7/16/2020 12:29:12 PM

Experts would appreciate your help in converting the following Thinkorswim Thinkscript scan to stockfetcher.
This is basically requesting combining 2 scripts into one :
1. scanning for high RVOL-Relative Volume (>2STD Dev)
2. the volume bar having > 95% Buying

Reason for requesting this is that on stockfetcher we can run these scans back in time which can make it easier to track stocks with recent high RVOL+95% buying. Good candidates for a long.

1. RVOL Script:

# TD Ameritrade IP Company, Inc. (c) 2014-2018
#

declare lower;
declare zerobase;

input length = 60;
input numDev = 2.0;
input allowNegativeValues = no;

def rawRelVol = ROUND((volume - Average(volume, length)) / StDev(volume, length),1);
plot RelVol = if allowNegativeValues then rawRelVol else Max(0, rawRelVol);
#plot StDevLevel = numDev;

#RelVol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
#RelVol.SetLineWeight(3);
RelVol.DefineColor("Above", GetColor(0));
RelVol.DefineColor("Below", GetColor(2));
RelVol.AssignValueColor(if RelVol >= numDev then RelVol.Color("Above") else RelVol.Color("Below"));
#StDevLevel.SetDefaultColor(GetColor(7));
#StDevLevel.SetStyle(Curve.SHORT_DASH);

#AddLabel(yes, RelVol);

AddLabel(1, Concat ("", RelVol ), if RelVol >0 then Color.WHITE else Color.BLACK);

AssignBACKGROUNDColor(if RelVol>0 then color.red else color.BLACK);

2. 95% Volume Bar is Buying script
# CustVolumeStudy by 7of9 for BRT

declare lower;

#Inputs

input Show30DayAvg = yes;
input ShowTodayVolume = yes;
input ShowPercentOf30DayAvg = yes;
input UnusualVolumePercent = 200;
input Show30BarAvg = yes;
input ShowCurrentBar = yes;
input ShowPercentOf30BarAvg = yes;
input ShowSellVolumePercent = yes;
input ShowBuyVolumePercent=yes;

def O = open;
def H = high;
def C = close;
def L = low;
def V = volume;
def buying = V*(C-L)/(H-L);
def selling = V*(H-C)/(H-L);

# Selling Volume

Plot SellVol = selling;
SellVol.setPaintingStrategy(PaintingStrategy.Histogram);
SellVol.SetDefaultColor(Color.Red);
SellVol.HideTitle();
SellVol.HideBubble();
SellVol.SetLineWeight(5);

# Total Volume

Plot BuyVol = volume;
BuyVol.setPaintingStrategy(PaintingStrategy.Histogram);
BuyVol.SetDefaultColor(Color.Dark_Green);
BuyVol.HideTitle();
BuyVol.HideBubble();
BuyVol.SetLineWeight(5);

#Volume Data

def volLast30DayAvg = (volume(period = "DAY")[1] + volume(period = "DAY")[2] + volume(period = "DAY")[3] + volume(period = "DAY")[4] + volume(period = "DAY")[5] + volume(period = "DAY")[6] + volume(period = "DAY")[7] + volume(period = "DAY")[8] + volume(period = "DAY")[9] + volume(period = "DAY")[10] + volume(period = "DAY")[11] + volume(period = "DAY")[12] + volume(period = "DAY")[13] + volume(period = "DAY")[14] + volume(period = "DAY")[15] + volume(period = "DAY")[16] + volume(period = "DAY")[17] + volume(period = "DAY")[18] + volume(period = "DAY")[19] + volume(period = "DAY")[20] + volume(period = "DAY")[21] + volume(period = "DAY")[22] + volume(period = "DAY")[23] + volume(period = "DAY")[24] + volume(period = "DAY")[25] + volume(period = "DAY")[26] + volume(period = "DAY")[27] + volume(period = "DAY")[28] + volume(period = "DAY")[29] + volume(period = "DAY")[30]) / 30;
def today = volume(period = "DAY");
def percentOf30Day = Round((today / volLast30DayAvg) * 100, 0);
def avg30Bars = (volume[1] + volume[2] + volume[3] + volume[4] + volume[5] + volume[6] + volume[7] + volume[8] + volume[9] + volume[10] + volume[11] + volume[12] + volume[13] + volume[14] + volume[15] + volume[16] + volume[17] + volume[18] + volume[19] + volume[20] + volume[21] + volume[22] + volume[23] + volume[24] + volume[25] + volume[26] + volume[27] + volume[28] + volume[29] + volume[30]) / 30;
def curVolume = volume;
def percentOf30Bar = Round((curVolume / avg30Bars) * 100, 0);
def SellVolPercent = Round((Selling / Volume) * 100, 0);
def BuyVolPercent = 100 - SellVolPercent;

# Labels

#AddLabel(Show30DayAvg, "Avg 30 Days: " + Round(volLast30DayAvg, 0), Color.LIGHT_GRAY);

#AddLabel(ShowTodayVolume, "Today: " + today, (if percentOf30Day >= UnusualVolumePercent then Color.GREEN else if percentOf30Day >= 100 then Color.ORANGE else Color.LIGHT_GRAY));

#AddLabel(ShowPercentOf30DayAvg, percentOf30Day + "%", (if percentOf30Day >= UnusualVolumePercent then Color.GREEN else if percentOf30Day >= 100 then Color.ORANGE else Color.WHITE) );

#AddLabel(Show30BarAvg, "Avg 30 Bars: " + Round(avg30Bars, 0), Color.LIGHT_GRAY);

#AddLabel(ShowCurrentBar, "Cur Bar: " + curVolume, (if percentOf30Bar >= UnusualVolumePercent then Color.GREEN else if PercentOf30Bar >= 100 then Color.ORANGE else Color.LIGHT_GRAY));

#AddLabel(ShowPercentOf30BarAvg, PercentOf30Bar + "%", (if PercentOf30Bar >= UnusualVolumePercent then Color.GREEN else if PercentOf30Bar >= 100 then Color.ORANGE else Color.WHITE) );

#AddLabel(ShowSellVolumePercent, "Cur Bar Sell %: " + SellVolPercent, (if SellVolPercent > 51 then Color.RED else if SellVolPercent < 49 then Color.GREEN else Color.ORANGE));

AddLabel(ShowBuyVolumePercent, "" + BuyVolPercent, (if BuyVolPercent < 49 then Color.WHITE else if BuyVolPercent > 51 then Color.BLACK else Color.BLACK));
AssignBackgroundColor(if BuyVolPercent < 49 then Color.RED else if BuyVolPercent >= 51 then Color.GREEN else Color.ORANGE);


input length = 50;

#plot Vol = volume;
#plot VolAvg = Average(volume, length);

#Vol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
#Vol.SetLineWeight(3);
#Vol.DefineColor("Up", Color.UPTICK);
#Vol.DefineColor("Down", Color.DOWNTICK);
#Vol.AssignValueColor(if close > close[1] then Vol.color("Up") else if close < close[1] then Vol.color("Down") else GetColor(1));
#VolAvg.SetDefaultColor(GetColor(8));


kmadnani
17 posts
msg #153158
Ignore kmadnani
7/16/2020 2:15:25 PM

Ok RelVol Filter already exists on SF. So we just need to add the > 95 buying bar filter.

show stocks where market cap is above 2000 and add column market cap

Fetcher[average volume(21) > 200000
close > 10
close >= close 1 day ago /*added per initial TOS post*/
not etf
relvol > 3;


set{TSIRank, daily TSI(3,9,1)}
set{avgvolspy,ind(spy,average volume(20))}
set{volspy1,ind(spy,volume)}
set{spyvol,volspy1/avgvolspy}

set{xvol,volume/average volume(20)}

set{relvol,xvol/spyvol}
add column relvol
add column RSI(15)
add column separator
add column TSIRank {rsToday}
add column TSIRank 1 week ago{TSI -1w}
add column TSIRank 2 week ago{TSI -2w}
add column TSIRank 3 week ago{TSI -3w}
add column TSIRank 4 week ago{TSI -4w}
add column TSIRank 5 week ago{TSI -5w}

set{rs, weekly ROC(10,1)}
set{difference, rs - ind(SPY, rs)}
set{null, 0}

ADD COLUMN SEPARATOR

add column difference {rel strgth}
SORT ON COLUMN 6 DESCENDING

do not draw rs
/*and add column sector*/
and add column industry
set{market_cap, shares outstanding * close}
and add column market_cap
add column daily ROC(2,1) {2day}
add column daily ROC(5,1) {5day}

set{momo,cema(momentum(16),5)}
add column momo
draw momo
plottype{momo,zerobar}

set{Pchange1,momentum(16)/momentum(16) 1 day ago}
set{Pchange,Pchange1 - 1}
add column pchange

draw Bollinger Band(20,2)
draw Keltner Band(20,2)

set{sqz1,count(momo > .01,1)}
set{sqz2,count(momo < 0,1)}
set{sqz3,count(Upper Bollinger Band(20,2) < Upper Keltner Band(20,2),1)}
set{sqz4,count(Lower Bollinger Band(20,2) > Lower Keltner Band(20,2),1)}
set{sqz5,sqz3 * sqz4}
set{sqz6,sqz1 + sqz2}
set{TTM_Squeeze,sqz5 * sqz6}

add column TTM_Squeeze

and add column dividend {dividend}
and add column dividend yield {yield%}
and add column since dividend {since_div}

set{volpct, volume divided by average volume(50)}
/* NORMALIZE accumulation distribution & price */

set{adval, INDPOSITION(accumulation distribution, 60) * 100}
set{closeval, INDPOSITION(close, 60) * 100}
/*DISPLAY THE COLUMNS */

/*add column volpct*/
add column adval
add column accumulation distribution {Acc/Dist}
add column PE Ratio
]






StockFetcher Forums · Filter Exchange · RVOL Scan with 95% Buying Bar<< >>Post Follow-up

*** Disclaimer *** StockFetcher.com does not endorse or suggest any of the securities which are returned in any of the searches or filters. They are provided purely for informational and research purposes. StockFetcher.com does not recommend particular securities. StockFetcher.com, Vestyl Software, L.L.C. and involved content providers shall not be liable for any errors or delays in the content, or for any actions taken based on the content.


Copyright 2022 - Vestyl Software L.L.C.Terms of Service | License | Questions or comments? Contact Us
EOD Data sources: DDFPlus & CSI Data Quotes delayed during active market hours. Delay times are at least 15 mins for NASDAQ, 20 mins for NYSE and Amex. Delayed intraday data provided by DDFPlus


This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.