//+------------------------------------------------------------------+
//| #_i_SpecktrAnalis.mq4 |
//| Copyright © 2006, klot. |
//| klot@mail.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, klot."
#property link "klot@mail.ru"
//----
#define pi 3.14159265358979323846
//----
#import "#_lib_FFT.ex4"
void fastcosinetransform(double& a[], int tnn, bool inversefct);
#import
//----
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Red
//---- buffers
double SpecktrBuffer[];
//----
extern double n = 7; // Äëèíà ðÿäà
extern int SS = 20; // Êîýôôèöèåíò ñãëàæèâàíèÿ
//----
int M, tnn1;
//----
double aa[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0, DRAW_LINE, 0, 2);
SetIndexBuffer(0, SpecktrBuffer);
//---
tnn1 = MathPow(2, n);
M = ArrayResize(aa, tnn1 + 1);
if(SS > M)
SS = M;
SetIndexDrawBegin(0, Bars - M);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars = IndicatorCounted();
double sig;
for(int i = M - 1; i >= 0; i--)
{
aa[i] = Close[i];
}
fastcosinetransform(aa, tnn1, false);
//---
int N = ArraySize(aa);
//---
for(i = 1; i <= N - 1; i++)
{
if(i >= SS)
aa[i] = 0;
}
//---
fastcosinetransform(aa, tnn1, true);
//---
for(i = 0; i <= N - 1; i++)
{
SpecktrBuffer[i] = aa[i];
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments