Hello,
First of all, AA can only be controlled from OUTSIDE of AmiBroker.
-----------------------------------------------------------------------------------------
Such code should never be run from the AA because it will create endlessly
nested loop
(AA triggering AA triggering AA triggering AA ad infinituum)
It should also not be called from indicator because it will create endless loop
too
(indicator->Backtest->triggers refresh->indicator->refresh.
As to errors you are getting:
1. AFL does not allow *setting* COM properties with parameters (it can only
read them).
2. should be AA.RangeN (not AA.Analysis.RangeN).
Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message -----
From: Herman
To: AmiBroker User Group
Sent: Saturday, May 17, 2008 1:00 PM
Subject: [amibroker] Can someone fix this OLE code?
Can someone help me fix the code below so that when triggered in an
Indicator, it:
1) Backtest all tickers in watchlist WLN?
2) Use range of BRS bars
3) Output ONLY the one line BT Report?
Many thanks!!!!
herman
if ( ParamTrigger( "Run Com BT", "BT" ) )
{
WLN = 0; // the watchlist to backtest
BRS = 100; // Number bars to test
AB = CreateObject( "Broker.Application" );
AA = AB.Analysis;
AA.LoadFormula( "C:\\Program
Files\\AmiBroker\\Formulas\\Systems\\Example.afl" );
AA.ClearFilters();
AA.Filter( 0, "watchlist" ) = WLN; // This gives syntax error...
AA.ApplyTo = 1;
AA.RangeMode = 1;
AA.Analysis.RangeN = BRS; // This gives syntax error...
AA.Backtest();
AA.Report( "" );
}