ChrisMoody

Example of Basic Indicator, & How to Code Advanced Features!!!

FX:XAUUSD   Gold / U.S. Dollar
2445 40 23
Description of Williams Accumulation Distribution

Williams AD is a running sum of positive accumulation values (buying pressure)
and negative distribution values (selling pressure),
as determined by price's location within a given day's true range.

To calculate the Williams' Accumulation/Distribution indicator, determine:

True Range High (TRH) = Yesterday's close or today's high whichever is greater
True Range Low (TRL) = Yesterday's close or today's low whichever is less

The day's accumulation/distribution is then calculated
by comparing today's closing price to yesterday's closing price.

If today's close is greater than yesterday's close: Today's A/D = today's close - TRL
If today's close is less than yesterday's close: Today's A/D = today's close - TRH
If today's close is the same as yesterday's close then the A/D is zero.

The Williams' Accumulation/Distribution indicator is a cumulative total of the daily values:

Williams A/D = Today's A/D + Yesterday's Williams A/D

Williams states it's worth             selling if the price makes a new high
and the indicator fails to follow suit. As well,
it's better to purchase if prices fall to a new bottom
yet the A/D indicator fails to reach a new low.

CODES BELOW
Code for Basic Williams AD

//Created by user ChrisMoody with the help of Alex from Tech Support
//Williams Accumulation Distribution
study(title = "Williams AD", shorttitle="WAD", precision=0)

trl = min(close, low)
trh = max(close, high)
ad = close > close ? close - trl : close < close ? close - trh : 0

plot(cum(ad), title="Williams AD", linewidth=3, color=orange)
Reply
Code for Williams AD with Simple Moving Average

//Created by user ChrisMoody with the help of Alex from Tech Support
//Williams AD + SMA of Williams AD
study(title = "Williams AD + SMA", shorttitle="WAD + SMA", precision=0)

len = input(57, minval=1, title="SMA Length")
trl = min(close, low)
trh = max(close, high)
ad = close > close ? close - trl : close < close ? close - trh : 0


plot(cum(ad), title="Williams AD", style=line, linewidth=3, color=orange)
plot(sma(cum(ad), len), title="SMA",style=line, linewidth=4, color=white)
Reply
Code for Williams AD with Simple Moving Average And Fill

//Created by user ChrisMoody with the help of Alex from Tech Support
//Williams AD + SMA of Williams AD + Fill
study(title = "Williams AD + SMA + Fill", shorttitle="WAD-SMA-Fill", precision=0)

len = input(57, minval=1, title="SMA Length")
trl = min(close, low)
trh = max(close, high)
ad = close > close ? close - trl : close < close ? close - trh : 0

p1 = plot(cum(ad), title="Williams AD", style=line, linewidth=4, color=orange)
p2 = plot(sma(cum(ad), len), title="SMA",style=line, linewidth=4, color=white)

fill(p1, p2, color=silver, transp=40, title="Fill”)
Reply
ChrisMoody PRO ChrisMoody
Indicator shown in 4th pane that changes colors based on if the Williams AD is Above or Below the SMA.
The first line of code to copy is the line below this on that starts with //Created by

//Created by user ChrisMoody with the help of Alex from Tech Support
//Williams AD + SMA of Williams AD + Change Colors based on Williams AD above or below SMA
//Williams AD = Solid Line, SMA = Circles

study(title = "Williams AD + SMA + Change Colors", shorttitle="WAD-SMA-ChangeColors", precision=0)

len = input(57, minval=1, title="SMA Length")
trl = min(close, low)
trh = max(close, high)
ad = close > close ? close - trl : close < close ? close - trh : 0
wad = cum(ad)
ma = sma(cum(ad), len)

spanColor = wad>=ma ? lime : red

p1 = plot(wad, title="Williams AD", style=line, linewidth=4, color=spanColor)
p2 = plot(ma, title="SMA",style=circles, linewidth=3, color=spanColor)

fill(p1, p2, color=silver, transp=40, title="Fill")
Reply
ChrisMoody PRO ChrisMoody
Guys I've posted this indicator 10 times on different computers with different browsers and it is automatically taking lines out.

// Instructions....Below the line that says ad = close > close etc add in these 3 lines below that

wad = cum(ad)
ma = sma(cum(ad), len)

spanColor = wad>=ma ? lime : red

//Don't copy this line....those 3 lines go after the ad = close line and before the p1 = plot line
Reply
ChrisMoody PRO ChrisMoody
Hey Guys there is a major issue with the code I posted. When I enter it in it looks perfect but when it save it somehow it is taking out lines or symbols.

SOLUTION:

Go up to the chart and click on the STAR at the Top Left of the chart right under the Thumbs Up .
Then Go to one of your charts and on the top left of the screen you will see your picture or the blue icon.
Click on your picture or the blue icon and select Ideas Following (When you clicked on the Star you followed the Charts idea)
Once you select Ideas Following then click on the chart that looks exactly like the one at the top of this screen.
Once the Chart pulls up at the top right of the chart is a little transparent box with a arrow pointing to the right.
Click on that Arrow and then on the bottom left you will see a Box that says MAKE IT MINE
After you do that the Chart will come up and you can click on the "Brackets" to open the source code and click SAVE and it will be your indicator.
The indicator will be located under Custom Scripts in your Indicators Tab.

You can do this with any Chart you ever find with a Indicator you want.
Reply
Divune ChrisMoody
Thank Chris, It worked :). Now I have this indicator thansk to you.

Appreciate that
Reply
LudmilaHanania ChrisMoody
Thanks Chris, I followed all till where you said - you can click on the "Brackets" to open the source code, can you please explain what do you mean by Brackets?
Reply
LudmilaHanania LudmilaHanania
Thanks Chris, I did figure it out.
Reply
ChrisMoody PRO LudmilaHanania
Great...Glad it worked out
Reply
Comment removed
Divune ChrisMoody
Hi Chris,
Great stuff, If i take the last code section (with the color change ) I receive the following error alert when trying to save, can you assist?
line 8:35 no viable alternative at input 'close'

Thanks
Reply
I had same problem with two emas, and now work fine without reason, but now i have same problem here lol.
Reply
Sorry...there was an error...I tried to copy the code again and it still pasted wrong...give me a minute and I will type in the right code line by line
Reply
Sorry...there was an error...I tried to copy the code again and it still pasted wrong...give me a minute and I will type in the right code line by line
Reply
iamthekey ChrisMoody
Thanks for support.
Reply
try the fix above and let me know if that works...make sure you see the 2nd post below...
Reply
great stuff, thanks. the power of simplicity in williams's approach is what's it's all about.
Reply
Yes...Every Trader I know that makes 7 figures a year has systems that are so simple new traders wouldn't believe it. For some reason most new traders think their system needs to be complex.
Reply
You're absolutely right. Took me a while but I do see that to be true now, simplicity is it. Also have to say, Thanks for all the codes. As a developer I can't wait to see how advanced the Script Editor will get.
Reply
ChrisMoody PRO optionsnewbie
I assure you....Great things are coming....

I'll be happy when we can change the color fill based on criteria....I prefer that to the Moving averages changing...
Also coming soon is Paint Bars....so we can change the color of candles based on certain criteria.....I have some great codes for that....
Reply
Wow, I was just going to ask about the ability to change the color of the candles based on criteria. This is great! I can't wait.
Reply
Cool ~
Reply
Thanks....
Reply
Sweet!!!!!!!!!!
Reply
Thank You....Just wrote a few more codes I'll publish on Monday
Reply
Great work Chris ! Thanks for sharing
Reply
Thanks for the comment Algokid
Reply
Chris,

For some reason i cant get the WAD + SMA to work..i tried copy and paste but no luck...i really like this indicator and want to use it...any help i would appreciate
Reply
For clarity, can you enter once more the right scripts please. There is some confusion now what works and what not.
Reply
Error:
line 10:35 no viable alternative at input 'close'

with

//Created by user ChrisMoody with the help of Alex from Tech Support
//Williams AD + SMA of Williams AD + Change Colors based on Williams AD above or below SMA
//Williams AD = Solid Line, SMA = Circles

study(title = "Williams AD + SMA + Change Colors", shorttitle="WAD-SMA-ChangeColors", precision=0)

len = input(57, minval=1, title="SMA Length")
trl = min(close, low)
trh = max(close, high)
ad = close > close ? close - trl : close =ma ? lime : red

wad = cum(ad)
ma = sma(cum(ad), len)

spanColor = wad>=ma ? lime : red

p1 = plot(wad, title="Williams AD", style=line, linewidth=4, color=spanColor)
p2 = plot(ma, title="SMA",style=circles, linewidth=3, color=spanColor)

fill(p1, p2, color=silver, transp=40, title="Fill")
Reply
ChrisMoody PRO tradingsam
Hey Guys there is a major issue with the code I posted. When I enter it in it looks perfect but when it save it somehow it is taking out lines or symbols.

SOLUTION:

Go up to the chart and click on the STAR at the Top Left of the chart right under the Thumbs Up .
Then Go to one of your charts and on the top left of the screen you will see your picture or the blue icon.
Click on your picture or the blue icon and select Ideas Following (When you clicked on the Star you followed the Charts idea)
Once you select Ideas Following then click on the chart that looks exactly like the one at the top of this screen.
Once the Chart pulls up at the top right of the chart is a little transparent box with a arrow pointing to the right.
Click on that Arrow and then on the bottom left you will see a Box that says MAKE IT MINE
After you do that the Chart will come up and you can click on the "Brackets" to open the source code and click SAVE and it will be - your indicator.
The indicator will be located under Custom Scripts in your Indicators Tab.
Reply
tradingsam ChrisMoody
Super!!
Reply
ChrisMoody PRO tradingsam
Thank You....
Reply
TimDj ChrisMoody
Tks Chris! Very interesting!
Reply
Thanks for the comment TimDJ...I appreciate it
Reply
KirillMironov ChrisMoody
Hi Chris I have a big request to throw the correct code of the indicator WAD+SMA colored to my mail kirko23@mail.ru very important! and it doesn't install properly!
Reply
ChrisMoody PRO KirillMironov
Try this...I posted the correct code but there was a glitch and some of the code was deleted...If you follow these instructions you will easily be able to get any code anyone posts on a chart. Once you get it installed reply to this and I will delete your comment so everyone can't see your email.

On the chart above on the top right corner there is a box with a white arrow.
Click that and choose make it mine.
Then click on the curly brackets to reveal the code.
Select all
Copy
Open a new blank chart
Open the Script editor
Select New
Delete the existing code in there
Paste the code you copied from my chart
Save
Then open the indicators tab...
Go to Custom Scripts
The indicator will be in there
Click on it and it will be applied to your chart....

Let me know if you get it to work
Reply
jjland PRO ChrisMoody
Hi...new here but found Williams AD + SMA solution I've been searching for. Are problems pasting resolved? I couldn't find the box with white arrow mentioned above to copy code.

I'd like to try this before going Pro.

Thanks
Reply
This is a OLD post before we came out with the PineScript Library. I will repost the Indicator there..and let you know when I do.
Reply
New Link To Indicator in PineScript Library

CM_Williams AD+SMA_V1_Public

Reply
Ideas Scripts Chart
United States
United Kingdom
India
España
France
Italia
Polska
Brasil
Россия
Türkiye
Indonesia
日本
한국
Home Stock Screener Forex Signal Finder Economic Calendar How It Works Chart Features House Rules Moderators For the WEB Widgets Stock Charting Library Priority Support Feature Request Blog & News FAQ Help & Wiki Twitter
Private Messages Chat Ideas Published Followers Following Priority Support Public Profile Profile Settings Account and Billing Sign Out