% DAILY DOWNTURN -> YOU NEED TO ADAPT FOR COMPUTING THE HIGHEST DOWNTURN % read the file % reading the file line by line % getting the downturn % - get highest high(a) so far % - get the downturn using this value YEAR = 1; MONTH = 2; DAY = 3; OPEN = 4; HIGH = 5; LOW = 6; CLOSE = 7; VOLUME = 8; data = load('djia.txt'); %% start = 1; finish = length(data); highestHighSoFar = 0; hightestRow = 0; % we use this for obtaining max downturn highestDownturn = 0; %We want the previous high price compared to today's low price for i = start:finish % data line by line % downturn = low(b)/ high(a); % to get biggest downturn, I need the maximum high(a) highOnRowI = data( i, HIGH ); if highOnRowI > highestHighSoFar highestHighSoFar = highOnRowI; highestRow = i; end biggestDownturnToRowI = (data(i, LOW) / highestHighSoFar)*100; % to get the highest downturn I should replace the following lines with % the finding of highest downturn. Thus, I will print the highest downturn after for loop fprintf('The high price on %d/%d/%d was %0.2f\n', ... data(highestRow, MONTH), data(highestRow, DAY), ... data(highestRow, YEAR), highestHighSoFar ); fprintf('The low price on %d/%d/%d was %0.2f\n', ... data(i, MONTH), data(i, DAY), ... data(i, YEAR), data(i,LOW) ); fprintf('That is %0.2f of the previous high\n\n\n', biggestDownturnToRowI ); end