
General Development General NinjaScript development questions. 

Thread Tools  Display Modes 
06122018, 01:10 AM  #1 
Junior Member
Join Date: Oct 2014
Posts: 29
Thanks: 9
Thanked 1 time in 1 post

Standard Deviations with different Average
Hello,
I have developed custom Standard Deviation based on different average like the: 1. Geometrical average 2. Harmonic average 3. Quadratic average As shown in the attached pic, i would like to understand why, for the same Period: 1. The Regular Stdev is almost equal to the Harmonic StdDev 2. The Geom Stdev is almost equal to the Quadratic StdDev It's more like a maths problem but i would be interested to have a feedback... Thanks
Last edited by cbadr; 06122018 at 01:12 AM.


06122018, 04:31 AM  #2  
Senior Member
Join Date: Feb 2008
Location: omegasigmaindicators.com
Posts: 7,235
Thanks: 56
Thanked 3,012 times in 2,437 posts

Quote:



06122018, 05:28 AM  #3 
Junior Member
Join Date: Oct 2014
Posts: 29
Thanks: 9
Thanked 1 time in 1 post

Thanks for the answer.
Here the code i used for the Geometrical Average: But after investigations on google, i realized i couldn't used the same Std calculation once the Mean is calculated. I'll have to update the formula accordingly. Any thoughts on this? Code:
protected override void OnBarUpdate() { if (CurrentBar < 1) { Value.Set(0); sumSeries.Set(Input[0]); } else { sumSeries.Set(Input[0] * sumSeries[1] * (CurrentBar >= Period ? 1/Input[Period]: 1)); double avg = Math.Pow(sumSeries[0],1/Math.Min(CurrentBar + 1, Period)); double sum = 0; for (int barsBack = Math.Min(CurrentBar, Period  1); barsBack >= 0; barsBack) sum += (Input[barsBack]  avg) * (Input[barsBack]  avg); Value.Set(Math.Sqrt(sum / Math.Min(CurrentBar + 1, Period))); } } 

06122018, 09:39 AM  #4  
Senior Member
Join Date: Feb 2008
Location: omegasigmaindicators.com
Posts: 7,235
Thanks: 56
Thanked 3,012 times in 2,437 posts

Quote:



06122018, 10:02 AM  #5 
Junior Member
Join Date: Oct 2014
Posts: 29
Thanks: 9
Thanked 1 time in 1 post

The issue is about understanding the result of the StdDev from a Geometric VS Harmonic VS Squared Mean.
From wikipedia i found that the formula to get the Geometric Std is mention there: https://en.wikipedia.org/wiki/Geomet...dard_deviation Thats a first thing i have to update on the script. Then really i am wondering if the Std formala is the same for the other Mean? 

06122018, 08:47 PM  #6  
Senior Member
Join Date: Feb 2008
Location: omegasigmaindicators.com
Posts: 7,235
Thanks: 56
Thanked 3,012 times in 2,437 posts

Quote:
Why do you think that a geometric mean may be more appropriate for what you are trying to do, if I may ask. 


Tags 
average, math, standard deviation 
Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
standard ichi kumu indicator for Ninja Trader 8.0.5.2 64bit (Standard)  behnam  Indicator Development  14  08042018 06:31 PM 
RSI  lookback bar # deviations  pretender  General Development  3  10062015 10:15 AM 
Volume Deviations  morphtrade  Platform Technical Support  0  10072009 09:18 AM 
Regression Channel (Support for Deviations < 1)  amedhussaini  Indicator Development  3  08302009 06:52 PM 
Addition of Standard Deviations to VOLMA  murfinp  Indicator Development  2  08112009 03:39 PM 