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

Re: Bad Data Filtering



PureBytes Links

Trading Reference Links

Hello  DP,

Sunday, March 26, 2000, 5:56:28 AM, you wrote:

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

i apologize below is a better one - rather than patch to old one.

==============================================================

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
norm = avgTR ;
plot1(norm,"norm");
plot2(vlty,"vlty+");
end ;end ;