Borrar filtros
Borrar filtros

stop the loop after first five values

2 visualizaciones (últimos 30 días)
karan goyal
karan goyal el 7 de Feb. de 2019
Editada: karan goyal el 7 de Feb. de 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 comentarios
madhan ravi
madhan ravi el 7 de Feb. de 2019
karan goyal
karan goyal el 7 de Feb. de 2019
EXPLAIN IN THE CODE PLEASE

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Operators and Elementary Operations en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by