[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] Which is faster ?



PureBytes Links

Trading Reference Links


Michael,
 
The 1st example (having a break) is easier to code.
 
The 2nd example (without a break) is not as easy.
 
One has to initize and manipulate the extra (BreakLoopZ) variable for the purpose of breaking out of loop.  As I wrote before, one can be creative and code this, however having a break will make the code much simpler.
 
Allow me to add some hypothetical complexity to the hypothetical examples you've presented.  Imagine if one need to break out at multiple places within code within the loops that are nested.  When the break logic happens the code following it should not be executed.  Now then, surely one can write breakLoopA, breakLoopB, breakLoopC, ... variables and a whole series of 'ifs' to skip over the code that should be be executed following the break condition.  Imagine having to do it at multiple places in nested loops ...
 
Given this, will you like to have a simple 'break' statement, or will you rather define/manipulate/code multiple loopBreak variables and a series of 'ifs' ?
 
Regards,
- Salil V Gangal
"Michael.S.G." <OzFalcon@xxxxxxxxxx> wrote:
Salil,        Im not sure I follow your logic with:
.................  Forcing a break out of running for loop is easy, however, it's not same as having a 'break' statement.In the sense that it's not the same? For as much as I am aware - aBreak statement IS forcing the break out of the running loop.To me the two pieces of code are operationaly equal - Regardless of depth.1:for( LoopZ = 0; (LoopZ < 100); LoopZ++ )        {               <FONT
 face="Courier New, Courier" color=#008000 size=2>// do this & that        printf("%0.0f\n",LoopZ);        if (LoopZ==43) Break(LoopZ);        }2:BreakLoopZ = False;for<FONT
 face="Courier New, Courier" size=2>( LoopZ = 0; ((LoopZ < 100) &! BreakLoopZ); LoopZ++ )        {               // do this & that        printf("%0.0f\n"<FONT face="Courier New, Courier"
 size=2>,LoopZ);        if (LoopZ==43) BreakLoopZ = True;        }Or do you mean somehthing else?        KR         Michael.At 01:55 PM 16/05/2004, you wrote:
Michael,Sure.  I know others follow the posts and learn.  (Count me into those who learn.)  Forcing a break out of running for loop is easy, however, it's not same as having a 'break' statement.Imagine if the control is 2-3 levels deep into the for loops.  Having break 1; break 2; break ... etc. to break out of each level is a nice thing to have.  One of course can be creative and think of logic to break out of all the levels, however given a choice of having a 'break' statement and not having one, which one would you choose ?Regards,- Salil V Gangal--- In amibroker@xxxxxxxxxxxxxxx, "Michael.S.G." <OzFalcon@xxxx> wrote:> Salil,> Possibly just "Filter Out" any post by Dingo may help.> (aka Pal in Amibroker-ts> a36b0c5.jpg> )> > But seriously - Irrelevant of your qualms with dingo -> His
 post was to the point & provided a solution to the> question at hand. With no insinuation of previous issues.>     You may not realise it - But others follow posts and learn> from solutions that arise from them.>   To suggest that some form of 'Censorship' be expressed by> other users - At someones personal whimsy - On a Public> forum - Is questionable at it's best.> > Remember - This is a Public forum - Where every member> has every right to post to any other member of the forum.> Even if said person request's otherwise.> > Perpetuating the issue - Is not in the best interests of anyone.> >          <MSG>> > > At 01:31 PM 16/05/2004, you wrote:> >Michael,> >> >I guess it's much easier for Dingo to not reply to me.> >>
 >Regards,> >- Salil V Gangal> >> >--- In amibroker@xxxxxxxxxxxxxxx, "Michael.S.G." <OzFalcon@xxxx>> >wrote:> > > Salil,> > >          If you do not wish to have replies from Dingo on this> >mailing list> > > - Then please remove yourself from list. Easy Eh?> > >> > > Why you persist in such petty issues is beyond me.> > >> > >          <MSG>> > >> > > At 12:57 PM 16/05/2004, you wrote:> > > >Your assertion about 'no need of break' is completely pointless.> >C,> > > >C++, Java, Perl, ... all have mechanisms to 'break' out of running> > > >loops.> > > >> > > >BTW  ... did you forget your pill again ? *smile*  As
 I wrote> > > >earlier, I do not - *NOT* - need any replies from you to me.  Get> > > >it ?  Can you follow my instructions and not reply to me ?> > > >> > > >> > > >--- In amibroker@xxxxxxxxxxxxxxx, "dingo" <dingo@xxxx> wrote:> > > > > You don't need a break - if you follow my instructions.  Its> >clear> > > >that you> > > > > didn't know how to do it.> > > > >> > > > > d> > > > >> > > > >> > > > >   _____> > > > >> > > > > From: Salil V Gangal [mailto:salil_gangal@x...]> > > > > Sent: Saturday, May 15, 2004 10:47 PM> > > > > To: amibroker@xxxxxxxxxxxxxxx> > > > >
 Subject: [amibroker] Re: Need to 'break'> > > > >> > > > >> > > > > Hello,> > > > >> > > > > Well ... I thought I was quite clear about your replies to me.> >No ?> > > > >> > > > > I know what exactly I need to do to manipulate a break, however> > > >it's> > > > > not the same as a statement 'break'.> > > > >> > > > > - Salil V Gangal> > > > >> > > > > --- In amibroker@xxxxxxxxxxxxxxx, "dingo" <dingo@xxxx> wrote:> > > > > > Then all you need to do is set colorindex to a value that will> > > > > result in the> > > > > > for loop ending:> > > > > >> > > > > >         if
 ( color == inColor ) {> > > > > >             colorNumber = StrToNum(StrExtract(colorToNumber,> > > > > colorIndex+1));> > > > > >       colorIndex = 16;> > > > > >         }> > > > > >> > > > > > d> > > > > > ________________________________> > > > > >> > > > > >       From: Salil V Gangal [mailto:salil_gangal@x...]> > > > > >       Sent: Saturday, May 15, 2004 10:28 PM> > > > > >       To: amibroker@xxxxxxxxxxxxxxx> > > > >
 >       Subject: [amibroker] Need to 'break'> > > > > >> > > > > >> > > > > >       Herman,> > > > > >> > > > > >       The code below could use a statement to 'break' out of a> > > > > running for> > > > > >> > > > > >       loop.  After the match for inColor is found, there's no> > > >need> > > > > to> > > > > >       continue with the remaining iterations of for loop.> > > > > >> > > > > >       Regards,> > > > > >       - Salil V Gangal> > > > >
 >> > > > > >> > > > > >       --- In amibroker@xxxxxxxxxxxxxxx, Salil V Gangal> > > > > <salil_gangal@xxxx>> > > > > >> > > > > >       wrote:> > > > > >       > Herman,> > > > > >       >> > > > > >       > Glad you found my code useful.  I played some more ...> > > > > >       >> > > > > >       > In the code below one needs to simply indicate what> > > >ticker> > > > > he/she> > > > > >       wants to plot and in what color in a ticker,
 color pair> > > >such> > > > > >> > > >as "MSFT,red,JNJ,green,C,yellow,WMT,pink,IP,violet,CAT,blue",> > > > > and> > > > > >       update the AmiBroker's color codes in the function> > > > > getColorNumber.> > > > > >       >> > > > > >       >> > > > > >       >> > > > > >       > // Chart display similar to FT> > > > > >       >> > > > > >       > Title = "";> > > > > >       >> > > > > >       >
 barvisible = Status("barvisible");> > > > > >       >> > > > > >       > firstBarVisible = barvisible AND NOT Ref(> >barvisible, -> > > >1 );> > > > > >       >> > > > > >       > procedure plotScaled ( ticker, color)> > > > > >       >> > > > > >       > {> > > > > >       >> > > > > >       >     array = Foreign(ticker,"C");> > > > > >       >> > > > > >       >    
 scaledArray = 100*(array / ValueWhen> > > > > (firstBarVisible,array ) -> > > > > >       1);> > > > > >       >> > > > > >       >     Plot(scaledArray ,"", color ,> >styleLine|styleThick);> > > > > >       >> > > > > >       >     Title = Title + EncodeColor(color) + ticker + " ";> > > > > >       >> > > > > >       > }> > > > > >       >> > > > > >       > function getColorNumber( inColor )> > > > >
 >       >> > > > > >       > {> > > > > >       >> > > > > >       >     colorToNumber> > > > > >       => > > > >> > > >> > > "red,29,green,27,yellow,42,pink,40,violet,38,blue,32,white,55,black,> > > > > >       16";> > > > > >       >> > > > > >       >     colorNumber = 47;> > > > > >       >> > > > > >       >     for( colorIndex = 0;> > >
 > > >       >> > > > > >       >         (color = StrExtract(colorToNumber,> >colorIndex)) !> > > > > = "";> > > > > >       >> > > > > >       >     colorIndex = colorIndex + 2> > > > > >       >> > > > > >       >     ) {> > > > > >       >> > > > > >       >         if ( color == inColor ) {> > > > > >       >> > > > >
 >       >             colorNumber = StrToNum(StrExtract> > > > > (colorToNumber,> > > > > >       colorIndex+1));> > > > > >       >> > > > > >       >         }> > > > > >       >> > > > > >       >     }> > > > > >       >> > > > > >       >     return colorNumber;> > > > > >       >> > > > > >       >
 }> > > > > >       >> > > > > >       >> > > > > >       >> > > > > >       > tickerColorList> > > > > >> >= "MSFT,red,JNJ,green,C,yellow,WMT,pink,IP,violet,CAT,blue";> > > > > >       >> > > > > >       > for( tickerIndex=0; (ticker=StrExtract> >(tickerColorList,> > > > > >       tickerIndex))!= ""; tickerIndex = tickerIndex + 2) {> > > > > >       >> > > > > >       >     plotScaled ( ticker,> > > > > >
 getColorNumber(StrExtract(tickerColorList,> > > > > >       tickerIndex+1)));> > > > > >       >> > > > > >       > }> > > > > >       > Regards,> > > > > >       > - Salil V Gangal> > > > > >       >> > > > > >       >> > > > > >       > Herman van den Bergen <psytek@xxxx> wrote:> > > > > >       > Thanks for your code Salil, nice to play with :-)> >here is> > > >a> > > > > slight> > > > > >> > > > >
 >       modification of your code to plot normalized charts for> >a> > > > > small> > > > > >       watchlist:> > > > > >       >> > > > > >       > // Chart display similar to FT> > > > > >       > barvisible = Status("barvisible");> > > > > >       > firstBarVisible = barvisible AND NOT Ref(> >barvisible, -> > > >1 );> > > > > >       > global ChartColor;> > > > > >       >> > > > > >       > function PlotNormalizedTicker( Ticker)> > > > >
 >       >     {> > > > > >       >     array2=Foreign(ticker,"C");> > > > > >       >     scaledArray2=100*(array2/ValueWhen> > > > > (firstBarVisible,array2)-1);> > > > > >       >     Plot(scaledArray2,"\n"+Ticker,ChartColor++,4);> > > > > >       >     }> > > > > >       >> > > > > >       > list = GetCategorySymbols( categoryWatchlist, 6);> > > > > >       > ChartColor=1;> > > > > >       > for(
 n=0; (Ticker=StrExtract( List, n))!= ""; n++)> > > > > >       PlotNormalizedTicker( Ticker);> > > > > >       >> > > > > >       > herman> > > > > >       >> > > > > >       > -----Original Message-----> > > > > >       > From: Salil V Gangal [mailto:salil_gangal@x...]> > > > > >       > Sent: Saturday, May 15, 2004 7:41 PM> > > > > >       > To: amibroker@xxxxxxxxxxxxxxx> > > > > >       > Subject: Re: [amibroker] Performance Charts> >
 > > > >       >> > > > > >       >> > > > > >       > Sam,> > > > > >       >> > > > > >       > Perhaps following will help. This code is for> >AmiBroker's> > > > > IB.> > > > > > Copy-> > > > > >       n-paste the code block of 2nd ticker multiple times per> > > >your> > > > > needs> > > > > > to> > > > > >       put additional tickers.  Also, use tickers you need in> > > >place> > > > > >       of "MSFT", "YHOO".> > >
 > > >       >> > > > > >       > // Chart display similar to FT> > > > > >       >> > > > > >       >> > > > > >       > barvisible = Status("barvisible");> > > > > >       >> > > > > >       > firstBarVisible = barvisible AND NOT Ref(> >barvisible, -> > > >1 );> > > > > >       >> > > > > >       >> > > > > >       >> > > > > >       > // code block for 1st ticker>
 > > > > >       >> > > > > >       >> > > > > >       > ticker = "MSFT";> > > > > >       >> > > > > >       > array1=Foreign(ticker,"C");> > > > > >       >> > > > > >       > scaledArray1=100*(array1/ValueWhen> > > >(firstBarVisible,array1)-> > > > > 1);> > > > > >       >> > > > > >       > Plot(scaledArray1,"",colorBlue,4);> > > > > >       >> > > > > >      
 > Title = EncodeColor(colorBlue) + ticker + " ";> > > > > >       >> > > > > >       >> > > > > >       >> > > > > >       > // code block for 2nd ticker> > > > > >       >> > > > > >       > ticker = "YHOO";> > > > > >       >> > > > > >       > array2=Foreign(ticker,"C");> > > > > >       >> > > > > >       > scaledArray2=100*(array2/ValueWhen> > > >(firstBarVisible,array2)-> > > > > 1);> >
 > > > >       >> > > > > >       > Plot(scaledArray2,"",colorRed,4);> > > > > >       >> > > > > >       > Title = Title + EncodeColor(colorRed) + ticker + " ";> > > > > >       >> > > > > >       >> > > > > >       > Regards,> > > > > >       > - Salil V Gangal> > > > > >       >> > > > > >       >> > > > > >       > --- Sam Levy <slevy1220@xxxx> wrote:> > > > >
 >       > > Has anyone used Amibroker to construct "performance> > > > > charts"> > > > > >       similar> > > > > >       > > to those available at the following link?> > > > > >       > >> > > > > >       > > http://stockcharts.com/charts/performance/> > > > > >       > >> > > > > >       > > If so, would appreciate a suggestion on how to> > > >construct> > > > > afl> > > > > >       code.> > > > >
 >       > > Thanks> > > > > >       > >> > > > > >       > >> > > > > >       >> > > > > >       >> > > > > >       >> > > > > >       >> > > > > >       > ---------------------------------> > > > > >       > Do you Yahoo!?> > > > > >       > SBC Yahoo! - Internet access at a great low price.> > > > > >       >> > > > > >       > Send BUG
 REPORTS to bugs@xxxx> > > > > >       > Send SUGGESTIONS to suggest@xxxx> > > > > >       > -----------------------------------------> > > > > >       > Post AmiQuote-related messages ONLY to:> > > > > amiquote@xxxxxxxxxxxxxxx> > > > > >       > (Web page:> > > >http://groups.yahoo.com/group/amiquote/messages/)> > > > > >       > --------------------------------------------> > > > > >       > Check group FAQ at:> > > > > >> ><A href=""
 eudora="autourl">http://groups.yahoo.com/group/amibroker/files/groupfaq.html> > > > > >       >> > > > > >       >> > > > > >       >> > > > > >       >> > > > > >       > Send BUG REPORTS to bugs@xxxx> > > > > >       > Send SUGGESTIONS to suggest@xxxx> > > > > >       > -----------------------------------------> > > > > >       > Post AmiQuote-related messages ONLY to:> > > > > amiquote@xxxxxxxxxxxxxxx> > > > > >       > (Web page:> > > ><A
 href="" eudora="autourl">http://groups.yahoo.com/group/amiquote/messages/)> > > > > >       > --------------------------------------------> > > > > >       > Check group FAQ at:> > > > > >> >http://groups.yahoo.com/group/amibroker/files/groupfaq.html> > > > > >       >> > > > > >       >> > > > > >       > Yahoo! Groups SponsorADVERTISEMENT> > > > > >       >> > > > > >       >> > > > >
 >       > ---------------------------------> > > > > >       > Yahoo! Groups Links> > > > > >       >> > > > > >       >    To visit your group on the web, go to:> > > > > >       > http://groups.yahoo.com/group/amibroker/> > > > > >       >> > > > > >       >    To unsubscribe from this group, send an email to:> > > > > >       > amibroker-unsubscribe@xxxxxxxxxxxxxxx> > > > > >       >> > > >
 > >       >    Your use of Yahoo! Groups is subject to the Yahoo!> > > >Terms> > > > > of> > > > > >       Service.> > > > > >       >> > > > > >       >> > > > > >       >> > > > > >       > ---------------------------------> > > > > >       > Do you Yahoo!?> > > > > >       > SBC Yahoo! - Internet access at a great low price.> > > > > >> > > > > >> > > > > >> > > > > >       Send BUG REPORTS to
 bugs@xxxx> > > > > >       Send SUGGESTIONS to suggest@xxxx> > > > > >       -----------------------------------------> > > > > >       Post AmiQuote-related messages ONLY to:> > > > > amiquote@xxxxxxxxxxxxxxx> > > > > >       (Web page:> >http://groups.yahoo.com/group/amiquote/messages/)> > > > > >       --------------------------------------------> > > > > >       Check group FAQ at:> > > > > > <A href=""
 eudora="autourl">http://groups.yahoo.com/group/amibroker/files/groupfaq.html> > > > > >> > > > > >> > > > > >> > > > > >       Yahoo! Groups Sponsor> > > > > >             ADVERTISEMENT> > > > > >       click here> > > > > >> > > > >> > >> > ><http://rd.yahoo.com/SIG=129aooqtt/M=285832.4851039.5997748.1269404/D> >=> groups> > > > >> > > >> > > /S=1705632198:HM/EXP=1084760885/A=2105440/R=0/SIG=14dpdlr1u/*http://> > > > > <A
 href="" eudora="autourl">www.hous> > > > > > eholdfinance.com/ln/TrackingServlet?> > > > > cmd_MediaCode=&fc=APS&mkt=000&mc=01PSYAY> > > > > > A004001B220000U0300L0010000000000&dest=HOME_PAGE>> > > > > >> > > > > > <http://us.adserver.yahoo.com/l?>> > > > M=285832.4851039.5997748.1269404/D=groups/S=> > > > > > :HM/A=2105440/rand=900332338>> > > > > >> > > > > >       ________________________________> > > > > >> > > > > >       Yahoo! Groups Links> > > > > >> > > > > >> > > > > >      
 *      To visit your group on the web, go to:> > > > > >             http://groups.yahoo.com/group/amibroker/> > > > > >> > > > > >       *      To unsubscribe from this group, send an email to:> > > > > >             amibroker-unsubscribe@xxxxxxxxxxxxxxx> > > > > > <mailto:amibroker-unsubscribe@xxxxxxxxxxxxxxx?> >subject=Unsubscribe>> > > > > >> > > > > >       *      Your use of Yahoo! Groups is subject to
 the> >Yahoo!> > > > > Terms of> > > > > > Service <http://docs.yahoo.com/info/terms/> .> > > > >> > > > >> > > > >> > > > > Send BUG REPORTS to bugs@xxxx> > > > > Send SUGGESTIONS to suggest@xxxx> > > > > -----------------------------------------> > > > > Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx> > > > > (Web page: http://groups.yahoo.com/group/amiquote/messages/)> > > > > --------------------------------------------> > > > > Check group FAQ at:> > > > > <A href=""
 eudora="autourl">http://groups.yahoo.com/group/amibroker/files/groupfaq.html> > > > >> > > > >> > > > >> > > > > Yahoo! Groups Sponsor> > > > >> > > > > ADVERTISEMENT> > > > >> > > > >> > >> > ><http://rd.yahoo.com/SIG=129338khj/M=285832.4851039.5997748.1269404/D> >=>> > >groups> /S=1705632198:HM/EXP=1084762050/A=2142721/R=0/SIG=14di1pg12/*> >http://> > > >www.hous> > > > > eholdfinance.com/ln/TrackingServlet?> > > >cmd_MediaCode=&fc=APS&mkt=000&mc=01PSYAY> > > > >
 A004001B220000U0300L0020000000000&dest=HOME_PAGE> click here> > > > >> > > > > > > <http://us.adserver.yahoo.com/l?> >M=285832.4851039.5997748.1269404/D=grou > > ps/S=>> > > >:HM/A=2142721/rand=421750390>> > > > >> > > > >> > > > >   _____> > > > >> > > > > Yahoo! Groups Links> > > > >> > > > >> > > > > *     To visit your group on the web, go to:> > > > > http://groups.yahoo.com/group/amibroker/> > > > >> > > > >> > > > > *     To unsubscribe from this group, send an email
 to:> > > > > amibroker-unsubscribe@xxxxxxxxxxxxxxx> > > > > <mailto:amibroker-unsubscribe@xxxxxxxxxxxxxxx?> >subject=Unsubscribe>> > > > >> > > > >> > > > > *     Your use of Yahoo! Groups is subject to the Yahoo! Terms> >of> > > >Service> > > > > <http://docs.yahoo.com/info/terms/> .> > > >> > > >> > > >> > > >> > > >Send BUG REPORTS to bugs@xxxx> > > >Send SUGGESTIONS to suggest@xxxx> > > >-----------------------------------------> > > >Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx> > > >(Web
 page: http://groups.yahoo.com/group/amiquote/messages/)> > > >--------------------------------------------> > > >Check group FAQ at:> > > >http://groups.yahoo.com/group/amibroker/files/groupfaq.html> > > >Yahoo! Groups Links> > > >> > > >> > > >> > > >> >> >> >> >> >Send BUG REPORTS to bugs@xxxx> >Send SUGGESTIONS to suggest@xxxx> >-----------------------------------------> >Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx> >(Web page: http://groups.yahoo.com/group/amiquote/messages/)> >--------------------------------------------> >Check group FAQ at: >
 >http://groups.yahoo.com/group/amibroker/files/groupfaq.html> >Yahoo! Groups Links> >> >> >> >------------------------ Yahoo! Groups Sponsor ---------------------~-->Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.Now with Pop-Up Blocker. Get it for free!http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/GHeqlB/TM---------------------------------------------------------------------~->Send BUG REPORTS to bugs@xxxxxxxxxxxxxSend SUGGESTIONS to suggest@xxxxxxxxxxxxx-----------------------------------------Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check group
 FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html Yahoo! Groups Links<*> To visit your group on the web, go to:     http://groups.yahoo.com/group/amibroker/<*> To unsubscribe from this group, send an email to:     amibroker-unsubscribe@xxxxxxxxxxxxxxx<*> Your use of Yahoo! Groups is subject to:     http://docs.yahoo.com/info/terms/ Send BUG REPORTS to bugs@xxxxxxxxxxxxxSend SUGGESTIONS to suggest@xxxxxxxxxxxxx-----------------------------------------Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: <A
 href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
		Do you Yahoo!?SBC Yahoo! - Internet access at a great low price.


Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html








Yahoo! Groups Sponsor


  ADVERTISEMENT 












Yahoo! Groups Links
To visit your group on the web, go to:http://groups.yahoo.com/group/amibroker/ 
To unsubscribe from this group, send an email to:amibroker-unsubscribe@xxxxxxxxxxxxxxx 
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.