stop the loop after first five values

2 vues (au cours des 30 derniers jours)
karan goyal
karan goyal le 7 Fév 2019
Modifié(e) : karan goyal le 7 Fév 2019
when a condition is satisfied the loop puts a string value called "buy" in the column but i want to stop that loop upto five "buy" only in the column and then move to the second loop after this is fulfilled.
THE CODE IS AS FOLLOWING:
buycash=0;
sellfut=0;
buylongspread=0;
buy=0;
for ii=1:r
if(ds3.LongAvailableSpread(ii)>=ds3.MeanLongAvailableSpread(ii)&&ds3.LongAvailableSpread(ii)>=40&&ds3.CashBestAskVol(ii)>=3000&&buy==0)
ds3.CashStatus(ii)="buy"; * I WANT UPTO FIVE BUY'S IN THE CASH STATUS
COLUMN WHEN THE ABOVE IF CONDITION IS FULFILLED
AND WHEN IT IS FULFILLED
I WANT TO MOVE TO THE BELOW IF CONDITION*
ds3.FutStatus(ii)="sell";
buylongspread=ds3.LongAvailableSpread(ii);
ds3.CASHPosition_Price(ii)=ds2.CashBestAsk(ii);
buycash=ds2.CashBestAsk(ii);
ds3.FUTPosition_Price(ii)=ds1.FUTBestBid(ii);
sellfut=ds1.FUTBestBid(ii);
buy=1;
end
if ((ds3.ShortAvailableSpread(ii)>=0 || ds3.ShortAvailableSpread(ii)>=40-buylongspread)&&(ds3.CashBestBidVol(ii)>=3000)&&(buy==1))
ds3.CashStatus(ii)="sell";
ds3.FutStatus(ii)="buy";
ds3.CASHPosition_Price(ii)=ds2.CashBestBid(ii);
ds3.FUTPosition_Price(ii)=ds1.FUTBestAsk(ii);
ds3.cashpnl(ii)=ds2.CashBestBid(ii)-buycash;
ds3.futpnl(ii)=sellfut-ds1.FUTBestAsk(ii);
buy=0;
end
end
  2 commentaires
madhan ravi
madhan ravi le 7 Fév 2019
karan goyal
karan goyal le 7 Fév 2019
EXPLAIN IN THE CODE PLEASE

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by