[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bad Data Filtering



PureBytes Links

Trading Reference Links

MB recently posted this code for filtering bad data. I created an indicator,
but it does not plot any data.  Am I missing something very obvious in
getting it to work or the proper setup/use?
 
TIA

Input : vbars(10),shockfac(3),endshock(1.00) ; 
vars :
vlty(0),norm(0),avgTr(0),ix(0),iy(0),na(0),vmax(100),trend(0),save(0); 
                   arrays : rng[100](0) ; 

                   {average true range during selected market periods} 
                   if currentbar <= vbars then begin 
                   {initilization} 
                   if na <= vmax then begin 
                   na = na + 1 ; 
                   rng[na] = @truehigh - @truelow ; 
                   end ; 
                   end 
                   else if currentbar = vbars + 1 then begin 
                   {sort range and find initial median value} 
                   for ix = 1 to na - 1 begin 
                   for iy = 2 to na begin 
                   if rng[ix] < rng[iy ] then begin 
                   save = rng[ix] ; 
                   rng[ix ]= rng[iy] ; 
                   rng[iy] = save ; 
                   end ; 
                   end ; 
                   end ; 
                   avgTr = rng[@intportion(na/2)] ; 
                   end 
                   else if currentbar > vbars + 1 then begin 
                   {normal processing} 
                   {current volatility uses all bars} 
                   vlty = @truehigh - @truelow ; 
                   {test for price shock levels} 
                   if vlty/avgTR > shockfac then begin 
                   if vlty>shockfac then 
                   norm = avgTR ; 

                   if vlty>=0 and vlty<=1 then plot1(vlty,">shock1"); 
                   if vlty>=1 and vlty<=2 then plot2(vlty,">shock2"); 
                   if vlty>=3 and vlty<=4 then plot3(vlty,">shock3"); 
                   if vlty>=4 and vlty<=5 then plot4(vlty,">shock4"); 

                   end ;end;