Double Sine Weighted MA code?

 

Is there a way to make this a Double Sine Weighted MA?


double workSineWMA[][_maWorkBufferx1];
#define Pi 3.14159265358979323846264338327950288
double iSineWMA(double price, int period, int r, int instanceNo=0)
{
   if (period<1) return(price);
   if (ArrayRange(workSineWMA,0)!= totalBars) ArrayResize(workSineWMA,totalBars);
   
   //
   //
   //
   //
   //
   
   workSineWMA[r][instanceNo] = price;
      double sum  = 0;
      double sumw = 0;
  
      for(int k=0; k<period && (r-k)>=0; k++)
      { 
         double weight = MathSin(Pi*(k+1.0)/(period+1.0));
                sumw  += weight;
                sum   += weight*workSineWMA[r-k][instanceNo]; 
      }
      return(sum/sumw);
}
 

Maybe this is the way to go.

for (i = limit; i < rates_total; i++)
{
    Line1_Buffer[i] = iSineWMA(close[i], MA_period, i, rates_total, 0);
    Line2_Buffer[i] = iSineWMA(Line1_Buffer[i], MA_period, i, rates_total, 1);
}

.............
//+------------------------------------------------------------------+
#define _maWorkBufferx1 2
#define Pi 3.14159265358979323846264338327950288
double workSineWMA[][_maWorkBufferx1];
//+------------------------------------------------------------------+
double iSineWMA(double price, int period, int r, int totalBars, int instanceNo = 0)
{
    ...........
}
//+------------------------------------------------------------------+
 

I can't get that to work. I think these are 2 different approaches in coding. Thanks, though.

I will look for code for Double Weighted Moving Average and then try to add the Sine in to that.

 
Nicholas C Weber #:

I can't get that to work. I think these are 2 different approaches in coding. Thanks, though.

I will look for code for Double Weighted Moving Average and then try to add the Sine in to that.

I am not sure if the method is correct, but I have confirmed that it works fine.

If it doesn't work, then you are wrong.

 
Nagisa Unada #:

I am not sure if the method is correct, but I have confirmed that it works fine.

If it doesn't work, then you are wrong.

Yeah, I probably am. I'm still a beginner.

Reason: