private double StandardDeviation(ArrayList array, double avg) { int x = 0; double sd = 0; while (x < array.Count) { sd += (((double)array[x] - avg) * ((double)array[x] - avg)); x++; } if (sd > 0) sd = System.Math.Sqrt(sd / (array.Count)); return sd; }
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
Using DataSeries as input to a function
Collapse
X
-
Using DataSeries as input to a function
I extracted this calc of Standard Deviation from iVWAP. The 1st parameter is an array. I have tried to change it to IDataSeries to pass it a DataSeries instead but my indicator comes up blank. Is there a way to pass it a DataSeries rather than have to copy the data to an array first? (I changed the .Count to CurrentBar-1 in my test)
Code:Tags: None
-
Originally posted by NinjaTrader_Brett View PostHello,
Thanks for your forum post.
This is how SMA method does it, cant think of any reason it shouldn't work for you.
public SMA SMA(Data.IDataSeries input, int period)
{
}
Let me know if I can be of further assistance.
It doesn't work. I just went back to using an array.
Comment
-
Hello,
I discussed this with Bertrand and looks like you need to create a separate indicator to house this. As they all provide iDataSeries interface by default. This needs to be whithen the confines of a separate indicator to allow you to do this. So you would have an indicator that just operates as a function/method if you wanted to further persue this.
Let me know if I can be of further assistance.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by GussJ, 03-04-2020, 03:11 PM
|
11 responses
3,227 views
0 likes
|
Last Post Today, 08:07 PM | ||
Started by andrewtrades, Today, 04:57 PM
|
1 response
13 views
0 likes
|
Last Post Today, 05:02 PM | ||
Started by chbruno, Today, 04:10 PM
|
0 responses
7 views
0 likes
|
Last Post
by chbruno
Today, 04:10 PM
|
||
Started by josh18955, 03-25-2023, 11:16 AM
|
6 responses
440 views
0 likes
|
Last Post
by Delerium
Today, 03:42 PM
|
||
Started by FAQtrader, Today, 03:35 PM
|
0 responses
12 views
0 likes
|
Last Post
by FAQtrader
Today, 03:35 PM
|
Comment