Oh I figure out that "the first B after A" is exrem(B,A). Yeah, now it runs much much faster with the same results. Thanks TJ for the tips
b.rgds/itmwh ----- Original Message ----- From: toxutao To: [email protected] Sent: Wednesday, June 06, 2007 10:31 AM Subject: Re: [amibroker] Re: Question: How to make the code run faster ? Hi, Tj Sorry , but in the original thread, I meant to express "the first B after condition A". How to implement the precondition A here ? Thanks/ itmwh ----- Original Message ----- From: Tomasz Janeczko To: [email protected] Sent: Wednesday, June 06, 2007 9:03 AM Subject: Re: [amibroker] Re: Question: How to make the code run faster ? Cum(B) is the culprit. There are way better ways to find "first occurrence", like this single-liner: ExRem( B, 0 ); // returns 1 on FIRST occurrence of B. Best regards, Tomasz Janeczko amibroker.com ----- Original Message ----- From: "itmwh" <[EMAIL PROTECTED]> To: <[email protected]> Sent: Wednesday, June 06, 2007 2:23 AM Subject: [amibroker] Re: Question: How to make the code run faster ? > Hi, TJ > > I checked my AFL codes and found it costs 5-7 secondes and > virtually takes all past bars in the calculation of every bar. I > think it may be the fact that I use the function " cum()". I am > using this function because I want to express the idea of "first > incurrence of ....." > > A = .....; > B=......; > Bnum= Cum(B); > AsinceB= Bnum - ValueWhen(A,Bnum ); > firstAsinceB=AsinceB==1; > > I use above calculation 3 times in my indicators, and guess that's > why the speed is slowed down. Is there a way to get out ? > Thanks/ itmwh > > > > > > --- In [email protected], "Tomasz Janeczko" <[EMAIL PROTECTED]> > wrote: >> >> Hello, >> >> Post the FORMULA you are using and then you will be able to get > help. >> >> Best regards, >> Tomasz Janeczko >> amibroker.com >> ----- Original Message ----- >> From: "itmwh" <[EMAIL PROTECTED]> >> To: <[email protected]> >> Sent: Tuesday, June 05, 2007 2:09 PM >> Subject: [amibroker] Question: How to make the code run faster ? >> >> >> > Hi, when I open a 1-minute chart with certain custom indicator, > the CPU >> > usage always rocket to above 90%, making it very inconvenient to > move >> > the crosshair on the chart, and do other basic chartings on the > chart. >> > When I run the same indicator on 5-minute chart, the speed is > OK, CPU >> > is operating at below 20%, it seems more bars on a 1-minute > chart slow >> > down the program. I want to know is there a method to let the > program >> > operate faster ? Or is it possible to let AB only calculate the > value >> > of the indicators in the visible bars ? >> > >> > >> > >> > Please note that this group is for discussion between users only. >> > >> > To get support from AmiBroker please send an e-mail directly to >> > SUPPORT {at} amibroker.com >> > >> > For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG: >> > http://www.amibroker.com/devlog/ >> > >> > For other support material please check also: >> > http://www.amibroker.com/support.html >> > >> > Yahoo! Groups Links >> > >> > >> > >> > >> > >> > > > > > Please note that this group is for discussion between users only. > > To get support from AmiBroker please send an e-mail directly to > SUPPORT {at} amibroker.com > > For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG: > http://www.amibroker.com/devlog/ > > For other support material please check also: > http://www.amibroker.com/support.html > > Yahoo! Groups Links > > > > > ------------------------------------------------------------------------------ 我正在使用对个人用户设计的免费版SPAMfighter. 至今为止, 593 封垃圾邮件已被移走. 这则消息不会出现在付费的用户中. 现在就免费试用 SPAMfighter !
