Filter löschen
Filter löschen

stop the loop after first five values

2 Ansichten (letzte 30 Tage)
karan goyal
karan goyal am 7 Feb. 2019
Bearbeitet: karan goyal am 7 Feb. 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 Kommentare
madhan ravi
madhan ravi am 7 Feb. 2019
karan goyal
karan goyal am 7 Feb. 2019
EXPLAIN IN THE CODE PLEASE

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Operators and Elementary Operations finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by