Info
Cette question est clôturée. Rouvrir pour modifier ou répondre.
For else error and vector integration
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am trying to convert a (for if else) condition into a vector. I am having problems running the results after because I need to redefine the different Short and Long trades to be read as directionTrade i think. not sure what I am doing incorrectly.
I need to convert: -
if dist(k,i)>0
B_Short(k,i)=-1;
B_Long(k,p(i,1))=+1;
else
B_Short(k,p(i,1))=-1;
B_Long(k,i)=+1;
end
INTO......................
for i=1:length(idx)
if (dist(k,idx(i))>0)
myTrades{idxTrades,1}.directionTrade1=[-1 1];
else
myTrades{idxTrades,1}.directionTrade2=[ 1 -1];
Attempted added information Below. Not sure if correct...
directionTrade1=[B_Short(k,i) B_Long(k,p(i,1))];
directionTrade2=[B_Long(k,i) B_Short(k,p(i,1))];
This is where the problem arises.
% Calculation of the Total Buy_Signs Matrix
BsignsT(k,:)=B_Long(k,:)+B_Short(k,:);
Because it still reads B Long and B Short trades however I want to replace with the above vector else conditon. What do I need to change? and what do I need to change the name to for all recurrences of B Short and B Long in the remaining code for it to correctly read the newly changed vector and process the fucntion correctly..???
0 commentaires
Réponses (0)
Cette question est clôturée.
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!