Williams AD Indicator with Moving Average Crossover for ThinkorSwim

R

RyanC

New member
thinkorswim does have a "WilliamsAD" study but it is missing the simple moving average and does not show crossovers.


Code:
declare lower;

input length = 20;

plot ad = AccumDistBuyPr();
plot smoothed = SimpleMovingAvg(ad, length=length);

smoothed.AssignValueColor(Color.WHITE);

ad.DefineColor("Up", Color.GREEN);
ad.DefineColor("Down", Color.RED);
ad.AssignValueColor(if ad > smoothed then ad.color("Up") else ad.color("Down"));
 
markos

markos

Well-known member
VIP
Warehouse
Try this, hopefully you can customize it. Generally, if TOS takes something out, it is because the Citizen CMT's asked for it that way when it was built. Sometimes it can be an error that gets thrown because of the original programming.
Did you check Williams books or papers to see if he had a preference? I'm just asking as I don't know.
This is an old version from what I can tell. Let us know what's going on. Thanks!
Code:
#
# thinkorswim, inc. (c) 2007
#

declare lower;

input length = 57;
input displace = 0;

def clMax = Max(close[1], high);
def clMin = Min(close[1], low);

def result = TotalSum(if close > close[1] then close - clMin else if close < close[1] then close - clMax else 0);

def ad_ma = Average(data = result[-displace], length = length);

plot WAD = result;
WAD.SetDefaultColor(GetColor(1));
WAD.HideBubble();

plot ADMA = ad_ma;
ADMA.SetDefaultColor(CreateColor(153,153,0));
ADMA.HideBubble();
Some notes from ThinkScript Lounge August 1, 2018:
14:30 Mobius: Scan for WilliamsAd is

AccumDistBuyPR() crosses above 0

14:30 Mobius: or below 0 or > 0 or < 0 whatever floats your boat
14:31 Mobius: if you use crosses it'd be best for it to be a dynamic watchlist scan
14:32 KC_Mama: Thank you everyone! I think I can do it now.
14:33 Mobius: lol it was just provided for you what's to do
14:34 KC_Mama: LOL!
14:34 Mobius: WillimsAD is the same code as AccumDistBuyPr() in TOS The WilliamsAD just references that code
14:36 Nube: Drats, now I gotta check to see if we can pass arguments to AccumDistBuyPr()
14:37 Nube: But also nice to know.
14:37 Mobius: What won't make sense to you is that when you get a signal from the scanner it's looking at the TotalSum of bars in a fixed range that may of may not match your charts range.
 
Last edited:
R

RyanC

New member
No, I could not find it in thinkorswim so I added the missing SMA to it with crossover colors. 57 might be the default value in books.
 
H

horserider

Well-known member
VIP
Warehouse
Markos gave you the code. It is also in ToS named "AccumDistBuyPr "
 

Top