I know how to use LLV(volume,5) which finds the lowest volume over the past 5 periods. However how do i find the lowest volume over the past 5 periods that's not zero?
I can only think of the following ugly way which is not scalable ie if i change 5 to 50 then code gets dumb i guess a for loop would be possible in this case?
Nice one, although I was thinking the same thing, only trying to use Previous Bar Volume when current bar is 0.
So either code would run into a problem, if all recent 5 bars are 0, then they'll be filled with Highest Vol which would then be an issue or a different Vol in my case.
so mod'ing your code,
sum5Vol = Sum( V, 5) > 0;
/// Modified original code by Anderson Wilson
HVolume = Highest(V);
CorectVolume = iif(Volume <= 0 AND sum5Vol, HVolume, V);
lowVOL = LLV(CorectVolume, 5);
Filter=true;
AddColumn(lowVOL,"lowin5");
we try to ensure there is atleast one bar with +ve Vol else return 0.
I think travick is on the right track.
Logic. Fill a volume array such that all the 0 volume is replaced by HVolume. Then find the smallest within 5 bars. The only issue with this is if there's an array with all zeros ie 0,0,0,0 as indicated highest volume is being returned but this can be filtered out by if sum(V,5)==0 and return lowVol = 0 when thiis is true.
Not sure if the following will compile will try later:
sum5Vol = Sum( V, 5) > 0;
if (sum5Vol){
/// Modified original code by Anderson Wilson
HVolume = Highest(V);
CorectVolume = iif(Volume <= 0 AND sum5Vol, HVolume, V);
lowVOL = LLV(CorectVolume, 5);
} else {
lowVOL=0;
}
Filter=true;
AddColumn(lowVOL,"lowin5");
Herm then the code should work with all 0s then and return 0 i believe. Thank for the tip I'm very bad with what will compile and what won't Arrays confuse me... Gotta keep coding to gain experience i guess.