Posted By: Andrea66
Spectral Analysys Hour Filter - 12/22/16 18:28
Dear All,
I'm a newbie and my target is to modify the following script in order to filter the series : eg: collect data only for hour 7 and then analyse the relevant spectrum.
// Spectral Analysis ///////////////////
//#define FILTER
function run()
{
BarPeriod = 60;
StartDate = 20150401;
EndDate = StartDate + 0100; // 1 month
LookBack = 4*200;
asset("EUR/USD");
vars Price = series(price());
#ifdef FILTER
plot("Filtered",BandPass(Price,24,0.1),NEW,BLACK);
set(PLOTNOW+PLOTLONG);
#else
int Cycle;
for(Cycle = 10; Cycle < 200; Cycle += 1)
plotBar("Spectrum",Cycle,Cycle,Spectrum(Price,Cycl e,4*Cycle),
BARS+AVG+LBL2,BLUE);
#endif
PlotHeight1 = 320;
}
I tried replacing "vars Price = series(price());" with :
"if (hour==7 ) vars Price = series(price());"
but it doesn't work and I receive the following messages :
011 Bandpass called with invalid parameter
011 Bandpass called with invalid parameter
011 Function MAX called with invalid parameter
Could you please help me implementing the correct filter.
I'm a newbie and my target is to modify the following script in order to filter the series : eg: collect data only for hour 7 and then analyse the relevant spectrum.
// Spectral Analysis ///////////////////
//#define FILTER
function run()
{
BarPeriod = 60;
StartDate = 20150401;
EndDate = StartDate + 0100; // 1 month
LookBack = 4*200;
asset("EUR/USD");
vars Price = series(price());
#ifdef FILTER
plot("Filtered",BandPass(Price,24,0.1),NEW,BLACK);
set(PLOTNOW+PLOTLONG);
#else
int Cycle;
for(Cycle = 10; Cycle < 200; Cycle += 1)
plotBar("Spectrum",Cycle,Cycle,Spectrum(Price,Cycl e,4*Cycle),
BARS+AVG+LBL2,BLUE);
#endif
PlotHeight1 = 320;
}
I tried replacing "vars Price = series(price());" with :
"if (hour==7 ) vars Price = series(price());"
but it doesn't work and I receive the following messages :
011 Bandpass called with invalid parameter
011 Bandpass called with invalid parameter
011 Function MAX called with invalid parameter
Could you please help me implementing the correct filter.