so i got the below working, but it keeps deleting the old level not the new one, how can I make it delete the new level instead? top and bottom are streams that calculate the same paramaters that the levels are drawn on.
function Authentic(j, FirstBar, LookBack, flag)
local i;
local count=0;
local result = true;
--local j = FirstBar;
--for i= j, FirstBar+500--[[math.max(first, FirstBar+1)]], -1 do
if flag then
--if source[i]< low2[j] then
if (bottom[j] < top[j-1] and bottom[j] > bottom[j-1]) then
result = false;
end
end
if not flag then
--if source[i] > high2[j]then
if (bottom[j] > top[j-1] and bottom[j] < bottom[j-1]) then
result = false;
end
end
--end
return result;
end