Indicators: Root Mean Square

 

Root Mean Square:

Root Mean Square

Root Mean Square

Author: Mladen Rakic

 
Thank you for this optimization to avoid redundant calculations of a FOR for example

 double iRootMeanSquare( double value , int period, int r, int bars, int instanceNo= 0 )
{
   struct sWorkStruct
      {
         double valueXvalue;
         double valueXvalueSum;
      };
   static sWorkStruct m_work[];

I'll keep the idea in mind for my own codes.

Good job !!!


Not optimized
      for(int i=0; i<period; i++)
         std_dev+=MathPow(price[position-i]-ma_price[position],2.0);
      std_dev=MathSqrt(std_dev/period);
Why not choose a simple static double WorkS[] to only have the valueXvalueSum memory?

It seems that valueXvalue is not necessary
 
Gerard Willia G J B M Dinh Sy #:
Thank you for this optimization to avoid redundant calculations of a FOR for example

I'll keep the idea in mind for my own codes.

Good job !!!


Not optimized
Why not choose a simple static double WorkS[] to only have the valueXvalueSum memory?

It seems that valueXvalue is not necessary

Check the code again. It is necessary

 
Mladen Rakic # :
Check the code again. It is necessary

yes I saw