Mike, Thanks kindly for your comments.
What I'm working on here is batch automation of an already-defined series of manual steps involving multiple symbols, AFLs, etc. Re: scan/exploration/backtest, all the parts of the existing process that are implemented that way manually are working great at this point in the batch run. (So I just left all that out.) In the system though are some fairly complex AFLs that operate differently when applied either as Explorations or in Indicator mode. Part of the process involves operating these AFLs in indicator mode. While it would be possible (I expect) to write new, separate code to run as an Exploration, my current goal is to mimic the manual process (during batch) by operating the existing code in indicator mode. This avoids a re-write, and puts another useful "technique" into the ole toolbox. I have experimented with each of the specific approaches you've suggested. However, not having found any working examples of these approaches in the docs or on the net to get me onto the right foot, my experiments have not so far been successful. Hence my inquiry, in the hope that someone has been down this road before and knows the "trick" of how to do it! - Progster On 7/9/2010 4:56 PM, Mike wrote: > > Does it have to be a chart? If you can accomplish the same thing via a > scan/exploration/backtest you can use the LoadFormula function on the > Analysis object. Similarly, the Commentary object has a LoadFormula > function. > > I don't see a LoadFormula equivalent for charting. But perhaps you can > emulate it as per 3b by loading a predefined layout or template? > > The Application object has a LoadLayout function. You could perhaps > then grab the Application.ActiveDocument and set its Name property to > the desired ticker. > > Similarly, the Application has an ActiveWindow property. The Window > object has a LoadTemplate function and a Document property. Again, set > the Name property of the Document to change the symbol. > > Mike > > --- In [email protected] <mailto:amibroker%40yahoogroups.com>, > Progster <progs...@...> wrote: > > > > Hi. > > > > Using OLE/jscript, I would like to do the following: > > > > 1. Start AB > > 2. Choose a database > > > > In a loop across multiple symbols (symbol names known in advance): > > > > 3a. Open a chart and apply an AFL > > > > or > > > > 3b. Open a saved layout that has a given AFL applied > > > > 4. Quit AB > > > > > > I've done a good amount of both Googling and experimenting, but I > > haven't hit on the right sequence yet to accomplish this. > > > > It is only step 3 that I'm having a problem with. My problem is not > > executing the loop. That seems fine. > > > > However, nothing I have found or tried opens/loads a chart and > > applies/runs an AFL. > > > > Below is skeleton code that runs. > > > > If someone is able to be so kind as to fill in the missing bit, I'd > > really appreciate it. If there's more than one way to do it, > > alternative solutions are very welcome. > > > > Thanks. > > > > --- > > > > > > /* > > LoopDemo_01.js > > > > _01 201007089 Initial "empty" skeleton by Progster > > > > It is recommended to run this file in a command window, like so: > > > > >cscript LoopDemo_01.js > > > > Lines commented with // *** will need to be edited to reflect > > the local environment > > > > Goals: > > > > 1. Start AB > > 2. Choose a database > > > > In a loop across multiple symbols (symbol names known in advance): > > > > 3a. Open a chart and apply an AFL > > or > > 3b. Open a saved layout that has a given AFL applied > > > > 4. Quit AB > > > > > > */ > > > > function pausecomp(millis) > > { > > var date = new Date(); > > var curDate = null; > > > > do { curDate = new Date(); } > > while(curDate-date < millis); > > } > > > > // General paths and setup definitions > > Settings_Directory = "C:\\Amibroker_Formula_Root\\"; // *** > > SettingsFileName = "Futures_01.ABS"; // *** > > > > Layout_Directory = "C:\\AmiBroker_Data\\US-PremiumData\\Layouts\\" > > // *** > > LayoutFileName = "MyLayout.ALY"; // *** > > > > SettingsFile = Settings_Directory + SettingsFileName; > > WScript.Echo( "SettingsFile: " + SettingsFile ); > > > > LayoutFile = Layout_Directory + LayoutFileName; > > WScript.Echo( "LayoutFile: " + LayoutFile ); > > > > AFL_Directory = "C:\\Amibroker_Formula_Root\\Custom\\"; // *** > > > > // Create AmiBroker object > > AB = new ActiveXObject("Broker.Application"); > > > > // Load Database > > AB.LoadDatabase("C:\\Amibroker_Data\\US-PremiumData"); // *** > > > > // Test of changing symbols // *** > > var symbols = new Array(4); > > symbols[0] = "$SPX" ; > > symbols[1] = "GOOG" ; > > symbols[2] = "AAPL" ; > > symbols[3] = "SPY" ; > > // symbols[] = "" ; > > > > for (idx = 0; idx <= 3; idx++) > > { > > next_symbol = symbols[idx]; > > WScript.Echo( "Working on: " + next_symbol); > > > > // Aim is to load a chart here, and load code (which will run > > and generate the desired result) > > > > ChartFileName = "My_Chart_File.afl"; // *** > > ChartFile = AFL_Directory + ChartFileName; > > WScript.Echo(ChartFile); > > > > pausecomp( 1000 ) ; > > } > > > > AB.SaveDatabase(); > > AB.RefreshAll(); > > > > pausecomp( 1000 ) ; > > > > WScript.Echo("Closing AmiBroker"); > > AB.Quit(); > > > > WScript.Echo("Pipeline is Done."); > > > > ------------------------------------ **** IMPORTANT PLEASE READ **** This group is for the discussion between users only. This is *NOT* technical support channel. TO GET TECHNICAL SUPPORT send an e-mail directly to SUPPORT {at} amibroker.com TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at http://www.amibroker.com/feedback/ (submissions sent via other channels won't be considered) For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG: http://www.amibroker.com/devlog/ Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/amibroker/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/amibroker/join (Yahoo! ID required) <*> To change settings via email: [email protected] [email protected] <*> To unsubscribe from this group, send an email to: [email protected] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
