Title: Re[2]: [amibroker] How to pass variables from AFL to embedded JScript?
Thanks,
I tried that but couldn't get it to work...
Could you (or anyone who knows) please explain how to insert a Trace in the following test code that only prints my Opt params when the OOS Backtest is performed?
See my test code and log below. I am looking for Only one unique state that shows me the OOS test nut don't see any.
A thousand thanks for any help with this!
herman
D = Optimize( "D", 1, 0, 1, 1 );
SetCustomBacktestProc( "" );
if ( Status( "action" ) == actionPortfolio )
{
bo = GetBacktesterObject();
bo.Backtest();
st = bo.GetPerformanceStats( 0 );
expectancy = st.GetValue( "WinnersAvgProfit" ) * st.GetValue( "WinnersPercent" ) / 100 +
st.GetValue( "LosersAvgLoss" ) * st.GetValue( "LosersPercent" ) / 100;
bo.AddCustomMetric( "Expectancy ($)", expectancy );
for ( n = 1; n <= 18; n++ )
{
if ( Status( "ActionEx" ) == n )
_TRACE( Name()+", D: "+D+", actionPortfolio: " + n );
}
}
Buy = Ref( C, 1 ) > C ;
Sell = Ref( Buy, D );
BuyPrice = SellPrice = Close;
Short = Sell;
Cover = Buy;
for ( n = 1; n <= 18; n++ )
{
if ( Status( "ActionEx" ) == n )
_TRACE( Name()+", D: "+D+", BackTester: " + n );
}
AAPL, D: 1, BackTester: 13 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.30
BIIB, D: 0, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.32
CELG, D: 0, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.34
ERTS, D: 0, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.34
FSLR, D: 0, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.34
GENZ, D: 0, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.35
JNPR, D: 0, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.35
LRCX, D: 0, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.35
SRCL, D: 0, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.37
WYNN, D: 0, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.37
~~~EQUITY, D: 0, actionPortfolio: 15 Formulas\Custom\Unnamed 88.afl 17 65 06:14:04.37
~~~EQUITY, D: 0, BackTester: 15 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.37
BIIB, D: 1, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.38
CELG, D: 1, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.38
ERTS, D: 1, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.38
FSLR, D: 1, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.38
GENZ, D: 1, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.38
JNPR, D: 1, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.38
LRCX, D: 1, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.40
SRCL, D: 1, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.40
WYNN, D: 1, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.40
~~~EQUITY, D: 1, actionPortfolio: 15 Formulas\Custom\Unnamed 88.afl 17 65 06:14:04.40
~~~EQUITY, D: 1, BackTester: 15 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.40
BIIB, D: 1, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.45
CELG, D: 1, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.45
ERTS, D: 1, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.45
FSLR, D: 1, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.45
GENZ, D: 1, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.46
JNPR, D: 1, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.46
LRCX, D: 1, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.46
SRCL, D: 1, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.46
WYNN, D: 1, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.48
~~~EQUITY, D: 1, actionPortfolio: 15 Formulas\Custom\Unnamed 88.afl 17 65 06:14:04.48
~~~EQUITY, D: 1, BackTester: 15 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.48
AAPL, D: 1, BackTester: 13 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.48
BIIB, D: 0, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.49
CELG, D: 0, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.51
ERTS, D: 0, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.51
FSLR, D: 0, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.51
GENZ, D: 0, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.51
JNPR, D: 0, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.52
LRCX, D: 0, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.52
SRCL, D: 0, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.52
WYNN, D: 0, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.52
~~~EQUITY, D: 0, actionPortfolio: 15 Formulas\Custom\Unnamed 88.afl 17 65 06:14:04.54
~~~EQUITY, D: 0, BackTester: 15 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.54
BIIB, D: 1, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.54
CELG, D: 1, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.54
ERTS, D: 1, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.54
FSLR, D: 1, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.55
GENZ, D: 1, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.55
JNPR, D: 1, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.55
LRCX, D: 1, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.55
SRCL, D: 1, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.55
WYNN, D: 1, BackTester: 14 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.57
~~~EQUITY, D: 1, actionPortfolio: 15 Formulas\Custom\Unnamed 88.afl 17 65 06:14:04.57
~~~EQUITY, D: 1, BackTester: 15 Formulas\Custom\Unnamed 88.afl 30 57 06:14:04.57
Tuesday, May 12, 2009, 5:06:07 AM, you wrote:
>
|
Status("ActionEx")
http://www.amibroker.com/guide/afl/afl_view.php?status
During backtest actionex is set ot actionBacktest,
during optimization actionex is set to one of actionExOptimize...
Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message -----
From: Herman
To: ozzyapeman
Sent: Tuesday, May 12, 2009 10:06 AM
Subject: Re: [amibroker] How to pass variables from AFL to embedded JScript?
ozzyapeman,
You seem to have solved some problems I have been struggling with...can you tell me:
How do you detect that that the WF engine is starting the Backtest phase?
How do you detect that it has completed the Backtest phase?
I want certain code to execute, and log some data, at those points only.
Many tanks,
herman
Monday, May 11, 2009, 9:03:33 PM, you wrote:
>
|
Hello, hoping someone can help out here. During a Walk-Forward test, I am trying to pass From and To dates from the WF engine into an embedded JScript. I essentially want to do a "sub-optimization" as part of the backtest portion of the WF test. However, it seems that I cannot pass variables from the AFL to the JScript.
Is there any way to pass the From and To dates into the JScript? Below is what I have. It generates an 'undefined source' error for these lines:
AA.RangeFromDate = FromDateStr;
AA.RangeToDate = ToDateStr;
Here is the AFL with embedded JScript:
FromDateNum = Status( "rangefromdate" );
ToDateNum = Status( "rangetodate" );
FromDate = DateTimeConvert( 2, FromDateNum );
ToDate = DateTimeConvert( 2, ToDateNum );
FromDateStr = DateTimeToStr( FromDate );
ToDateStr = DateTimeToStr( ToDate );
EnableScript( "jscript" );
<%
Formula = "F:\\SomeFormula.afl";
Database = "F:\\AB Databases\\MyIB";
Settings = "F:\\Some Settings.ABS";
AB = new ActiveXObject( "Broker.Application" );
AA = AB.Analysis;
AB.LoadDatabase( Database );
AB.ActiveDocument.Name = "EURUSD";
AA.LoadFormula( Formula );
AA.LoadSettings( Settings);
AA.ApplyTo = 1;
AA.RangeMode = 3;
AA.RangeFromDate = FromDateStr; // * ERROR *
AA.RangeToDate = ToDateStr;
AA.Optimize( 0 );
AA.Export ( "F:\\TestReport1.html" );
%>
|
|
__._,_.___
**** 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/
__,_._,___
|