i am trying to contruct this indicator since i see it isn't available. i was wondering if you could help, or at least give me some clues to get started. The formula can be found here at the bottom of this webpage:
Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Williams Accumulation Distribution
Collapse
X
-
Hi there,
I gave this a shot, here's what I ended up with. Seems to be correct from what I can tell. You can just plug this code into an empty indicator template.
Add an array double[] williamsADs to your class variables somewhere and make your OnBarUpdate look like this:
Code:protected override void OnBarUpdate() { if(CurrentBar < 2) return; double trueRangeHigh, trueRangeLow; double priceMove, AD, williamsAD; priceMove = 0d; // calculate true range high and low trueRangeHigh = (High[0] > Close[1] ? High[0] : Close[1]); trueRangeLow = (Low[0] < Close[1] ? Low[0] : Close[1]); // compare closing price to yesterdays if(Close[0] > Close[1]) priceMove = Close[0] - trueRangeLow; else if(Close[0] < Close[1]) priceMove = Close[0] - trueRangeHigh; else if(Close[0] == Close[1]) priceMove = 0d; AD = priceMove * Volume[0]; williamsAD = AD + williamsADs[CurrentBar-1]; williamsADs[CurrentBar] = williamsAD; Plot0.Set(williamsAD); Print(String.Format("CurrentBar = {0}, williamsAD = {1}, williamsADs = {2}", CurrentBar, williamsAD, williamsADs[CurrentBar-1])); }
Last edited by Dexter; 02-26-2011, 02:12 AM.
-
Thank you! It looks pretty good but i can't verify for sure yet.
I'm not quite sure what you mean by "adding an array double williamsADs"
The only thing i came up with was: double williamsADs = 1;
But this is giving me a bunch of error messages & i don't really have any reason for putting the 1 in there b/c i dont think this indicator has any variables to plug in....
Thanks
Comment
-
Not to take away from what is being discussed, isnt this the ADL indicator included in the NT7 distribution? NOT the same exact code, just the basics. OR I am on wrong track and apologize in advance
"The Accumulation/Distribution (AD) study attempts to quantify the amount of volume flowing into or out of an instrument by identifying the position of the close of the period in relation to that periods high/low range."
Comment
-
Yeah, I just took a look at it and it appears to be very similiar, only lacking the running addition of previous day.
look at this one liner
AD.Set((CurrentBar == 0 ? 0 : AD[1]) + (High[0] != Low[0] ? (((Close[0] - Low[0]) - (High[0] - Close[0])) / (High[0] - Low[0])) * Volume[0] : 0));
Comment
-
here is everything together, you should be able to copy paste it:
Code:double[] williamsADs = new double[256]; protected override void OnBarUpdate() { if(CurrentBar < 2) return; double trueRangeHigh, trueRangeLow; double priceMove, AD, williamsAD; priceMove = 0d; // calculate true range high and low trueRangeHigh = (High[0] > Close[1] ? High[0] : Close[1]); trueRangeLow = (Low[0] < Close[1] ? Low[0] : Close[1]); // compare closing price to yesterdays if(Close[0] > Close[1]) priceMove = Close[0] - trueRangeLow; else if(Close[0] < Close[1]) priceMove = Close[0] - trueRangeHigh; else if(Close[0] == Close[1]) priceMove = 0d; AD = priceMove * Volume[0]; williamsAD = AD + williamsADs[CurrentBar-1]; williamsADs[CurrentBar] = williamsAD; Plot0.Set(williamsAD); }
Comment
-
can you post all the collasped lines below that too? lines 83 & 84 on my page are what is where that error needs to be corrected. Here is what i have just below what you just posted...
#region Properties
[Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
public DataSeries WillAD
{
get { return Values[0]; }
}
[Description("")]
[GridCategory("Parameters")]
public double WilliamsADs
{
LINE 83 get { return williamsADs; }
LINE 84 set { williamsADs = Math.Max(1, value); }
}
#endregion
}
}
Comment
-
256 is how many elements the array used to store previous days AD hold, since the formula takes a running total of current day AD + yesterdays this was a simple way to store all the days ADs. Arrays are a type of data structure which contain several variables of the same type, in this case doubles of market data. You create them in C# using the [] brackets
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Skifree, Today, 03:41 AM
|
1 response
4 views
0 likes
|
Last Post
by Skifree
Today, 03:42 AM
|
||
Started by usazencort, Today, 01:16 AM
|
0 responses
1 view
0 likes
|
Last Post
by usazencort
Today, 01:16 AM
|
||
Started by kaywai, 09-01-2023, 08:44 PM
|
5 responses
603 views
0 likes
|
Last Post Today, 12:32 AM | ||
Started by xiinteractive, 04-09-2024, 08:08 AM
|
6 responses
23 views
0 likes
|
Last Post Today, 12:31 AM | ||
Started by Pattontje, Yesterday, 02:10 PM
|
2 responses
23 views
0 likes
|
Last Post
by Pattontje
Yesterday, 11:49 PM
|
Comment