//+------------------------------------------------------------------+ //| Wavelet.mq5 | //| Copyright 2000-2025, MetaQuotes Ltd. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2000-2025, MetaQuotes Ltd." #property link "https://www.mql5.com" #property version "1.00" #include #include #include #define CPU_DATA 1 #define GPU_DATA 2 #define SIZE_X 600 #define SIZE_Y 200 #resource "Kernels/wavelet.cl" as string cl_program //+------------------------------------------------------------------+ //| CWavelet | //+------------------------------------------------------------------+ class CWavelet { protected: int m_xsize; int m_ysize; int m_maxcolor; string m_res_name; string m_label_name; uchar m_palette[3*256]; //--- double m_data[]; double m_wavelet_data_CPU[]; double m_wavelet_data_GPU[]; uint m_bmp_buffer[]; COpenCL m_OpenCL; double Morlet(const double t); void ShowWaveletData(const double &m_wavelet_data[]); int GetPalColor(const int index); void Blend(const uint c1,const uint c2,const uint r1,const uint g1,const uint b1,const uint r2,const uint g2,const uint b2); bool WaveletCPU(const double &data[],const int datacount,const int x_size,const int y_size,const int i,const int j,const bool norm,double &result[]); public: //--- void Create(const string name,const int x0,const int y0,const int x_size,const int y_size); bool CalculateWavelet_CPU(const double &data[],uint &time); bool CalculateWavelet_GPU(double &data[],uint &time); void ShowWavelet(const int mode); }; //+------------------------------------------------------------------+ //| Morlet wavelet function | //+------------------------------------------------------------------+ double CWavelet::Morlet(const double t) { double v=t; double res=MathExp(-v*v*0.5)*MathCos(M_2_PI*v); return ((double)res); } //+------------------------------------------------------------------+ //| GetPalColor | //+------------------------------------------------------------------+ int CWavelet::GetPalColor(const int index) { int ind=index; if(ind<=0) ind=0; if(ind>255) ind=255; int idx=3*(ind); uchar r=m_palette[idx]; uchar g=m_palette[idx+1]; uchar b=m_palette[idx+2]; //--- return(b+256*g+65536*r); } //+------------------------------------------------------------------+ //| Gradient palette | //+------------------------------------------------------------------+ void CWavelet::Blend(const uint c1,const uint c2,const uint r1,const uint g1,const uint b1,const uint r2,const uint g2,const uint b2) { int n=int(c2-c1); for(int i=0; i<=n; i++) { if((c1+i+2)0) { for(int j=0; jmax_value) max_value=value; if(momentum_data[i]