Thanks!
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
StdDev Question
Collapse
X
-
StdDev Question
I am creating a series that contains positive and negative values. They are usually pretty balanced between + and - numbers but in all cases I get a positive number as a result when calling StdDev() on the series. Now perhaps a value of e.g. 7.3 for a 1.0 standard deviation would encompass all numbers between 7.3 and -7.3. Or would the result be different if I would omit all positive numbers? I guess I could just try but was hoping you guys would shed some light on this as well.
Thanks!Tags: None
-
Originally posted by molecool View PostI am creating a series that contains positive and negative values. They are usually pretty balanced between + and - numbers but in all cases I get a positive number as a result when calling StdDev() on the series. Now perhaps a value of e.g. 7.3 for a 1.0 standard deviation would encompass all numbers between 7.3 and -7.3. Or would the result be different if I would omit all positive numbers? I guess I could just try but was hoping you guys would shed some light on this as well.
Thanks!
Standard Deviation is a measure of the absolute deviation from the mean of the sample, and so, the larger the dispersion of values, the larger the Standard Deviation. If you eliminate all negative values, it is still possible to have the same value for the standard deviation. That would happen for example if you added the value of the smallest negative number to all values. It would shift the mean, and keep the value of the standard deviation.
However, your question is implying the removal of the positive values. That will almost certainly contract the value of the standard deviation, as your values will be less dispersed.
-
I'm not sure the StDev function produces what I need.
As I understand it (and that's not saying much), the StDev function will return the standard deviation of a dataset. NT documentation says this is the syntax:
Code:StdDev(High, 20)[0]
Code:StdDev(CCI, 20)[0]
Last edited by hawks67; 06-25-2015, 08:08 AM.
Comment
-
Originally posted by hawks67 View PostI'm not sure the StDev function produces what I need.
As I understand it (and that's not saying much), the StDev function will return the standard deviation of a dataset. NT documentation says this is the syntax:
Code:StdDev(High, 20)[0]
Code:StdDev(CCI, 20)[0]
Th error in your compilation should tell you what is wrong with your statement. What are the parameters for your CCI?
Comment
-
Hello hawks67,
Thank you for your inquiry.
When calling the CCI indicator, there are two overloads that you can possibly use:
Code:// Overload 1 CCI(int period) // Overload 2 CCI(IDataSeries input, int period)
Code:// Choice 1 StdDev(CCI(int period), int period) // Choice 2 StdDev(CCI(IDataSeries input, int period), int period)
Code:StdDev(CCI(x), 20)
Please, let us know if we may be of further assistance!Zachary G.NinjaTrader Customer Service
Comment
-
I spoke too soon.
When I try to assign the StDev value using the example given:
Code:double tempvalue = StdDev(CCI(14), 20);
So I tried this after checking the help pages:
Code:double tempvalue = StdDev(CCI(14), 20)[0];
I just know this is obvious, but I'm missing it. I want to plot a few lines in a custom indicator that map out the standard deviation of a few data sets, CCI among them. Once I get the CCI down, I'll be able to handle the others.
Thanks.
Comment
-
No, I can't, because it no longer generates the error. I swear the code was clean, but obviously I was doing something wrong.
But even now that I can get that part to work, I'm still stuck as I try to carry that syntax over to my custom indicator.
It has two DataSeries in it, Upper and Middle. (I cannibalized/spliced different code into the bollinger indicator plots, but while it works, I have no real idea how when it comes to the structure and syntax.) Upper and Middle reference a second custom indicator ("custind"). I want to take the average of those two values, and then plot the StdDev of that average over the past ten bars.
Since this doesn't work:
Code:double tempvalue = StdDev(((custind(2, 14).Upper + custind(2, 14).Middle)/2), 10)[0];
I've created a DataSeries variable:
Code:private DataSeries myDataSeries;
Code:myDataSeries = new DataSeries(this);
Code:(custind(2, 14).Upper + custind(2, 14).Middle) / 2
Comment
-
Hello hawks67,
The StdDev() overload you are wanting to use accepts an IDataSeries and an int.
Because the DataSeries class holds a series of doubles, you would want to try something like this. What this will do is calculate those values for the current bar on each indicator and divide it by two to give you your average:
Code:myDataSeries.Set((custind(2, 14).Upper + custind(2, 14).Middle) / 2)
Code:StdDev(myDataSeries, 10)[0];
Zachary G.NinjaTrader Customer Service
Comment
-
Originally posted by hawks67 View PostNo, I can't, because it no longer generates the error. I swear the code was clean, but obviously I was doing something wrong.
But even now that I can get that part to work, I'm still stuck as I try to carry that syntax over to my custom indicator.
It has two DataSeries in it, Upper and Middle. (I cannibalized/spliced different code into the bollinger indicator plots, but while it works, I have no real idea how when it comes to the structure and syntax.) Upper and Middle reference a second custom indicator ("custind"). I want to take the average of those two values, and then plot the StdDev of that average over the past ten bars.
Since this doesn't work:
Code:double tempvalue = StdDev(((custind(2, 14).Upper + custind(2, 14).Middle)/2), 10)[0];
I've created a DataSeries variable:
Code:private DataSeries myDataSeries;
Code:myDataSeries = new DataSeries(this);
Code:(custind(2, 14).Upper + custind(2, 14).Middle) / 2
Code:double tempvalue = StdDev(myDataSeries, 10)[0];
Last edited by koganam; 06-25-2015, 03:02 PM.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by strategist007, Today, 07:51 PM
|
0 responses
3 views
0 likes
|
Last Post Today, 07:51 PM | ||
Started by StockTrader88, 03-06-2021, 08:58 AM
|
44 responses
3,969 views
3 likes
|
Last Post
by jhudas88
Today, 06:59 PM
|
||
Started by rbeckmann05, Today, 06:48 PM
|
0 responses
5 views
0 likes
|
Last Post
by rbeckmann05
Today, 06:48 PM
|
||
Started by rhyminkevin, Today, 04:58 PM
|
4 responses
58 views
0 likes
|
Last Post
by dp8282
Today, 06:13 PM
|
||
Started by iceman2018, Today, 05:07 PM
|
0 responses
6 views
0 likes
|
Last Post
by iceman2018
Today, 05:07 PM
|
Comment