// Downloaded From https://www.WiseStockTrader.com
SetBarsRequired( sbrAll ); 


function EBSW( Duration) 
{
//HighPass filter cyclic components whose periods are shorter than Duration input
PI = 3.1415926;
alpha1 = (1 - sin (2*PI / Duration)) / cos(2*PI /Duration);
//Smooth with a Super Smoother Filter from equation 3-3
a1 = exp(-1.414*PI / 10);
b1 = 2*a1*cos(1.414*PI / 10);
c2 = b1;
c3 = -a1*a1;
c1 = 1 - c2 - c3;
HP = Close; 
    Filt = HP; 
    Wave = Filt; 
    Pwr = Filt;
for( i = 3 ; i < BarCount; i++ ) 
    { 
       HP[ i ]=.5*(1 + alpha1)*(Close[i] - Close[i-1]) + alpha1*HP[i-1];

Filt[i] = c1*(HP[i] + HP[i-1]) / 2 + c2*Filt[i-1] + c3*Filt[i-2];
}
//3 Bar average of Wave amplitude and power
Wave = (Filt + Ref(Filt,-1) + Ref(Filt,-2)) / 3;
Pwr = (Filt^2 + Ref(Filt,-1)^2 + Ref(Filt,-2)^2) / 3;
//Normalize the Average Wave to Square Root of the Average Power
Wave = Wave / sqrt(Pwr);
return wave;
}
Plot(EBSW(Param("Duration",20,1,200,1,0)),"EBSW"+ _PARAM_VALUES(),colorBlue);//Plot( array, Name, color/barcolor, style = styleLine, minvalue = {empty}, maxvalue = {empty}, XShift = 0, Zorder = 0 ) 
/*
//HighPass filter cyclic components whose periods are
shorter than Duration input
alpha1 = (1 - Sine (360 / Duration)) / Cosine(360 /
Duration);
HP = .5*(1 + alpha1)*(Close - Close[1]) + alpha1*HP[1];
//Smooth with a Super Smoother Filter from equation 3-3
a1 = expvalue(-1.414*3.14159 / 10);
b1 = 2*a1*Cosine(1.414*180 / 10);
c2 = b1;
c3 = -a1*a1;
c1 = 1 - c2 - c3;
Filt = c1*(HP + HP[1]) / 2 + c2*Filt[1] + c3*Filt[2];
//3 Bar average of Wave amplitude and power
Wave = (Filt + Filt[1] + Filt[2]) / 3;
Pwr = (Filt*Filt + Filt[1]*Filt[1] + Filt[2]*Filt[2]) / 3;
//Normalize the Average Wave to Square Root of the Average
Power
Wave = Wave / SquareRoot(Pwr);
Plot1(Wave);