No BSD License  

Highlights from
Constant Volume Bars

Constant Volume Bars

by

 

03 Apr 2009 (Updated )

Constant Volume Bars

CVB.m
% Generate Constant Volume Bars

Volume = 2000;  % Enter the # of securities required to close the bar
data = EuroDollar1m; % Enter name of data. Data should be [0,H,L,C,V] format

counter = 0;
z = 1; y = 1;

% Main Loop
for x=1:length(data)
    counter = counter + data(x,5); % Volume Counter
    if counter >= Volume
        CVBars(y,1) = data(z,1); % Open of CVB
        CVBars(y,2) = max(data(z:x,2)); % High of CVB
        CVBars(y,3) = min(data(z:x,3)); % Low of CVB
        CVBars(y,4) = data(x,4); % Close of CVB
        
        z = x;
        y = y + 1;
        counter = 0;
    end
    
end

% Calculate MA for charting
wavg = movavg(CVBars(:,4),50,50,2);
wavg = wavg(50:end,:);

% Candle Bar format
candle(CVBars(:,2),CVBars(:,3),CVBars(:,4),CVBars(:,1), 'red');
hold on
plot(wavg);
hold off

Contact us