Fast Fourier Transform

 

I wish to use the CFastFourierTransform::FFTR1D function present in Mt5 docker Math/Alglib/fasttransforms. However on successfully applying the transform I am getting zero output as the result of fourier transform. Any ideas on how to correctly call the function CFastFourierTransform::FFTR1D.


//+------------------------------------------------------------------+
//|                                                     FFT_Test.mq5 |
//|                                  Copyright 2021, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#include <Math/Alglib/fasttransforms.mqh> 
#property copyright "Copyright 2021, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_plots   1
//--- plot smoothen
#property indicator_label1  "smoothen"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrRed
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- input parameters
input int      period=20;
//--- indicator buffers
double     smoothenBuffer[],tempBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,smoothenBuffer,INDICATOR_DATA);
   SetIndexBuffer(1,tempBuffer,INDICATOR_CALCULATIONS);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const int begin,
                const double &price[])
  {
//---
    if(rates_total<2)
      {
       return 0;
      }
    MqlRates array[];
    int copied=CopyRates(Symbol(),0,0,rates_total,array);
    for(int i=0;i<rates_total;i++)
      {
       tempBuffer[i]=array[i].close;
      }
    Print(tempBuffer[rates_total-1]);
    double ar[];
    complex out[];
    ArrayCopy(ar,tempBuffer,0,0,rates_total);
   CFastFourierTransform::FFTR1D(ar,rates_total,out);
   ArrayCopy(smoothenBuffer,out,0,0,rates_total);
   Print(smoothenBuffer[rates_total-1]);
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+