hi,
I'm trying to create a signal of 1 and -1 with a for loop but getting an error of "Subscript indices must either be real positive integers or logicals." My code is like this
for i=1:length(data) if (MACD(i-1)>0) && (MACD(i)<0) s(i,:)=-1; % Sell (short)
end if (MACD(i-1)<0) && (MACD(i)>0) s(i,:)=1; % buy (long)
endend
Could you tell me where is the mistake please.
Best Answer