Easy Slideshows in AmiBroker

AFL and other code for AmiBroker
User avatar
progster
Posts: 948
Joined: Thu Jul 26, 2007 7:20 pm
Contact:

Easy Slideshows in AmiBroker

Postby progster » Sat Feb 09, 2008 2:40 pm

Based on a post to the AB Yahoo List, by Herman, 2/8/2008
This version adds comments, minor edits, and removes plotting to assist in use as an include file.


Here is some code that can be used to turn your charts into a slideshow which steps thru the symbols in a Watchlist at a pace of your choosing.

Code: Select all


//  --------------------------------------------------
//   Watchlist Slideshow Code Block
//   This file is a variation of code posted by Herman   20080209
//  http://finance.groups.yahoo.com/group/amibroker/message/105520
//  This version contains comments and minor edits by Progster

//   Parameters for speed, watchlist choice, and watchlist size
RefreshRate      = Param("Chart Update Rate",0,0,10,1);      //   default rate of 0 seconds, slideshow OFF
WLNum            = Param("WatchList Number",1,0,64,1);         //   default to WL #1 (the 2nd, since they start at 0)
MaxTickerNum     = Param("Max. Ticker Number",29,1,100,1);      //   default to 30 tickers (0 - 29)

Ticker = Name() ;

if (RefreshRate > 0){

   //   Set up automatic refresh and filter so that non-timer events don't advance the slideshow
   RequestTimedRefresh( RefreshRate );
   TimerTick        = Status("RedrawAction");      //   1 if refresh triggered via RequestTimedRefresh()
   
   List             = CategoryGetSymbols( categoryWatchlist, WLNum );   // retrieve watchlist symbols
   TickerNum        = StaticVarGet("TickerNumber");                  //   recall last TickerNumber
   
   if( IsNull( TickerNum ) ) StaticVarSet("TickerNumber", 0);      //   fail-save to TickerNumber = 0
   
   //   On timed refresh, increment (and save) the TickerNum
   if( TimerTick )
   {
         TickerNum = StaticVarGet("TickerNumber");
         if( TickerNum <= MaxTickerNum ) StaticVarSet("TickerNumber",++TickerNum);
         else StaticVarSet("TickerNumber", 0);
   }
   
   //   Pick the current TickerNum symbol from the list and set the chart to it
   Ticker = StrExtract( List, Tickernum);
   SetForeign(Ticker);

   //   Simple title
   // Title = "\n#"+NumToStr( TickerNum,1.0,False) +" "+Ticker;

   // More elaborate title
   _N(MyTitle = Ticker + StrFormat(" - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));
   _N(MyTitle = StrFormat("Slideshow ") + MyTitle) ;
   _N(Title = MyTitle) ;
   StaticVarSet("TitleDone", 1) ;      //   flag other code that this code has done the title

}   //   end of:   timer refresh processing
else if (RefreshRate == 0){
   StaticVarSet("TitleDone", 0) ;      //   undo the flag so other code does not think this code has done the title
}

//   end of:   Watchlist Slideshow Code Block
//  --------------------------------------------------

To use this code, you can either:

1. Paste it as a block at the top of other charting code
2. Save it in your AFL Include directory and #include it above other charting code

The result will be 3 parameters that you can use to play a slideshow, rotating thru a specified number of symbols from a specified Watchlist.

SlideshowParams.png

If you set the Chart Update Rate to 0, the slideshow is OFF.
Otherwise, you get a slideshow that steps thru the Watchlist (chosen by number) at the selected rate-per-second.
The slideshow loops once it reaches 'Max Ticker Number'.

Here is a video (sound and motion) demonstrating an AmiBroker slideshow and how to use the above code to produce it, either by pasting it at the top of other code files, or by placing it in a standalone include file.


Enjoy!
You do not have the required permissions to view the files attached to this post.

trash
Posts: 30
Joined: Fri Mar 30, 2012 9:15 pm
Contact:

Re: Easy Slideshows in AmiBroker

Postby trash » Sun Jan 04, 2015 8:03 pm

Alternative version to choose category and some other stuff.
http://pastie.org/private/qab0nixlyksagui0u5mm3a

original thread
https://groups.yahoo.com/neo/groups/ami ... ges/187066


Return to “AmiBroker Code”

Who is online

Users browsing this forum: No registered users and 1 guest