Hi there I have the following loop, is there a way to vectorize it?
for i=1:10000for j=i:10000s = zeros(size(P));[lead,lag] = movavg(P,i,j,'e');s(lead>lag) = 1;s(lag>lead) = -1;r = [0; s(1:end-1).*diff(P)-abs(diff(s))*cost];sh(i,j) = scaling*sharpe(r,0);endend
Best Answer