Ideas Scripts Chart Stock Screener Forex Signal Finder Economic Calendar How It Works Chart Features House Rules Moderators For the WEB Widgets Stock Charting Library Feature Request FAQ Help & Wiki Twitter

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

FX:XAUUSD   Gold / U.S. Dollar
2445 40
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

//Created by user ChrisMoody with the help of Alex from Tech Support
//Williams Accumulation Distribution

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

Code for Williams AD with Simple Moving Average

//Created by user ChrisMoody with the help of Alex from Tech Support

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

Code for Williams AD with Simple Moving Average And Fill

//Created by user ChrisMoody with the help of Alex from Tech Support

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

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

fill(p1, p2, color=silver, transp=40, title="Fill”)
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

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

spanColor = wad>=ma ? lime : red

p2 = plot(ma, title="SMA",style=circles, linewidth=3, color=spanColor)

fill(p1, p2, color=silver, transp=40, title="Fill")
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

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
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.
ChrisMoody
Thank Chris, It worked :). Now I have this indicator thansk to you.

Appreciate that
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?
LudmilaHanania
Thanks Chris, I did figure it out.
LudmilaHanania
Comment removed
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
Divune
I had same problem with two emas, and now work fine without reason, but now i have same problem here lol.
iamthekey
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
Divune
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
ChrisMoody
Thanks for support.
Divune
try the fix above and let me know if that works...make sure you see the 2nd post below...
great stuff, thanks. the power of simplicity in williams's approach is what's it's all about.
isomorph
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.
ChrisMoody
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.
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....
ChrisMoody
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.
Cool ~
alex.a
Thanks....
Sweet!!!!!!!!!!
BizkitBR
Thank You....Just wrote a few more codes I'll publish on Monday
Great work Chris ! Thanks for sharing
Algokid
Thanks for the comment Algokid
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
For clarity, can you enter once more the right scripts please. There is some confusion now what works and what not.
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

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

spanColor = wad>=ma ? lime : red

p2 = plot(ma, title="SMA",style=circles, linewidth=3, color=spanColor)

fill(p1, p2, color=silver, transp=40, title="Fill")
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.
ChrisMoody
Super!!
Thank You....
ChrisMoody
Tks Chris! Very interesting!
TimDj
Thanks for the comment TimDJ...I appreciate it
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!
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
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
jjland
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.
New Link To Indicator in PineScript Library

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