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

[amibroker] Re: Need to 'break'



PureBytes Links

Trading Reference Links

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: 
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: 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.



------------------------ 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@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 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/