Miscellaneous
0
Views
0
Downloads
0
Favorites
FFTfiltr
//+------------------------------------------------------------------+
//| IFFT.mq4 |
//| Copyright © 2006, Michal Rutka |
//| http://www.mqlservice.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Michal Rutka"
#property link "http://www.mqlservice.com"
#include <sampledll.mqh>
#define MAX_N 10080
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 DarkOliveGreen
#property indicator_width1 2
//---- input parameters
extern int points=720;//24;
extern int tones=1;
extern double f=1.0;
extern int shift=0;
extern int min_tone=1;
double arr[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
string short_name;
//---- indicator lines
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,arr);
//---- name for DataWindow and indicator subwindow label
short_name="FFT("+points+", "+tones+", "+shift+")";
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);
//----
//SetIndexDrawBegin(0, points);
//----
return(0);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
//int points=BarsPerWindow();
//Print(BarsPerWindow());
if(points>MAX_N)
{
Print("Too many FFT ponts");
return(-1);
}
if(Bars<points)
{
Print("Less Bars than FFT points");
return(-1);
}
int counted_bars=IndicatorCounted();
if(counted_bars < 0)
{
Print("IndicatorCounted(): ",counted_bars);
return(-1);
}
if(counted_bars > 0) counted_bars--;
int limit=Bars-counted_bars-points;
limit=0;
while(limit>=0)
{
//for(int i=0;i<points;i++)
// arr[i] = Open[i-limit];
//----
double prices[MAX_N],oprices[MAX_N];
for(int i=0;i<points;i++)
prices[i] = Open[i+limit+shift];
//ArrayCopySeries(prices, MODE_OPEN);
int ton=FFTfiltr(prices,oprices,points,tones,f,min_tone);
if(ton>=0)
// Print("prices[0]: ", oprices[0], " Open[0]: ", Open[0]);
//FFT(prices, points);
//arr[0]=0.0;
for(i=0;i<points;i++)
arr[i+limit+shift] = oprices[i];
else
Print("FFT failed");
string short_name="FFT("+points+", "+tones+", "+shift+", "+ton+")";
//IndicatorShortName(short_name);
//Print(short_name);
Comment("Highest energy ton is ", ton);
limit--;
}
for(i=shift-1;i>=0;i--)
arr[i] = arr[i+points];
//----
return(0);
}
//+------------------------------------------------------------------+
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---