필터 지우기
필터 지우기

stop the loop after first five values

조회 수: 2 (최근 30일)
karan goyal
karan goyal 2019년 2월 7일
편집: karan goyal 2019년 2월 7일
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
madhan ravi
madhan ravi 2019년 2월 7일
karan goyal
karan goyal 2019년 2월 7일
EXPLAIN IN THE CODE PLEASE

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by