PureBytes Links
Trading Reference Links
|
Thank you TJ :-) you saved the day once more !
Great
stuff.
If someone is wondering why I wanted this program... You can
design trading systems and use performance metric arrays as powerful
Indicators. It is somewhat similar to trading the equity curve. Price
arrays can have qualities that can make your trading systems fail but that are
undetectable with traditional indicators.
However, you can design small trading systems that target
specific price characteristics, like patterns, trends, volatility, cycles, etc.
Using the code below gives you statistical information about these
characteristics in a form that can be plotted, and be used in other
trading systems.
Thanks everyone for your help! have a great
trading day! herman
// Demo trading system Short = Cover =
0; Buy = Cross( MACD(), Signal() ); Sell = Cross( Signal(), MACD()
); // Using the CBT to retrieve/save metrics if( Status("action") ==
actionBacktest ) StaticVarSetText( "Symbol", Name() ); SetOption(
"UseCustomBacktestProc", True ); if ( Status( "action" ) == actionPortfolio
) { bo = GetBacktesterObject(); bo.PreProcess(); MyHistStat1 =
Null; for ( bar = 0; bar < BarCount; bar++
) { bo.ProcessTradeSignals( bar ); stats = bo.GetPerformanceStats( 0
); MyHistStat1[ bar ] = stats.GetValue( "UlcerIndex" ); // any metric can be
retrieved } bo.PostProcess(); AddToComposite( MyHistStat1, "~~~UI_" +
StaticVarGetText( "Symbol" ), "X", atcFlagEnableInPortfolio | atcFlagDefaults
); } PlotForeign( "~~~UI_"+Name(), "UlcerIndex Historical", colorRed,
styleLine );
-----Original Message----- From:
amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx]On
Behalf Of Tomasz Janeczko Sent: July 25, 2008 5:49 AM To:
amibroker@xxxxxxxxxxxxxxx Subject: [SPAM]Re: [SPAM]Re: [amibroker] How to
save Metrics in Composites for Individual BTs
Herman,
You
forgot the CORRECTION I mentioned:
StaticVarSetText( "Symbol", Name() );
must NOT be called unconditionally, but THIS
way:
===================================================================== if(
Status("action") == actionBacktest ) StaticVarSetText( "Symbol", Name()
); ==============================================================
Best
regards, Tomasz Janeczko amibroker.com ----- Original Message
----- From: Herman To: amibroker@xxxxxxxxxxxxxxx Sent: Friday, July 25,
2008 11:36 AM Subject: RE: [SPAM]Re: [amibroker] How to save Metrics in
Composites for Individual BTs
Still NO GO. I am loading the code
in the AA, select a watchlist, run an Individual backtest, and Refresh the
WorkSpace. I get the BT report with individual results. I get two Composites in
my Composites Group. One is named ~~~EQUITY, the other ~~~UI_~~~EQUITY. The
first makes sense but the second indicates that the StaticVar does not return
the ticker name.
>> It appears that in this code the function
Name() returns "~~~EQUITY" and does not return the name for the ticker being
tested, it behaves as if the ~~~EQUITY composite is the ticker being
tested. Can anyone confirm this?
Thanks again! Herman
//
Demo trading system Short = Cover = 0; Buy = Cross( MACD(), Signal()
); Sell = Cross( Signal(), MACD() ); // Using the CBT to retrieve/save
metrics StaticVarSetText( "Symbol", Name() ); SetOption(
"UseCustomBacktestProc", True ); if ( Status( "action" ) == actionPortfolio
) { bo = GetBacktesterObject(); bo.PreProcess(); MyHistStat1 =
Null; for ( bar = 0; bar < BarCount; bar++
) { bo.ProcessTradeSignals( bar ); stats = bo.GetPerformanceStats( 0
); MyHistStat1[ bar ] = stats.GetValue( "UlcerIndex" ); // any metric can be
retrieved } bo.PostProcess(); AddToComposite( MyHistStat1, "~~~UI_" +
StaticVarGetText( "Symbol" ), "X", atcFlagEnableInPortfolio | atcFlagDefaults
); } PlotForeign( "~~~UI_"+Name(), "UlcerIndex Historical", colorRed,
styleLine );
-----Original Message----- From:
amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx]On
Behalf Of Tomasz Janeczko Sent: July 25, 2008 4:08 AM To:
amibroker@xxxxxxxxxxxxxxx Subject: [SPAM]Re: [amibroker] How to save Metrics
in Composites for Individual BTs
It will work OK. Individual
backtest *is* portfolio backtest but just portfolio consisting of one symbol at
a time.
Note that one should select "Individual Backtest" (not "OLD"
backtest) from AA->Backtest drop down.
One correction
though StaticVarSetText( "Symbol", Name() );
should be called only
when NOT in portfolio mode
so
if( Status("action") ==
actionBacktest ) StaticVarSetText( "Symbol", Name() );
// Demo trading
system Short = Cover = 0; Buy = Cross( MACD(), Signal() ); Sell =
Cross( Signal(), MACD() );
// Using the CBT to retrieve/save
metrics SetOption( "UseCustomBacktestProc", True ); if ( Status( "action"
) == actionPortfolio ) { bo =
GetBacktesterObject(); bo.PreProcess(); MyHistStat1 = Null; for ( bar =
0; bar < BarCount; bar++ ) { bo.ProcessTradeSignals( bar ); stats =
bo.GetPerformanceStats( 0 ); MyHistStat1[ bar ] = stats.GetValue(
"UlcerIndex" ); // any metric can be
retrieved } bo.PostProcess(); AddToComposite( MyHistStat1, "~~~UI_" +
StaticVarGetText( "Symbol" ) + "_HISTORICAL", "X", atcFlagEnableInPortfolio |
atcFlagDefaults ); }
----- Original Message ----- From: Paul
Ho To: amibroker@xxxxxxxxxxxxxxx Sent: Friday, July 25, 2008 4:45
AM Subject: RE: [amibroker] How to save Metrics in Composites for Individual
BTs
First of all. You use Status{"action") == actionPortfolio,
individual backtest wont go through there.
From:
amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On
Behalf Of Herman Sent: Friday, 25 July 2008 9:31 AM To:
amibroker@xxxxxxxxxxxxxxx Subject: Re: [amibroker] How to save Metrics in
Composites for Individual BTs
Thank you Tomasz, but this code still
does not work. I changed the StaticVar to the Text type.
Can you help
some more ... ? or does anyone else see the
problem?
TIA, Herman
StaticVarSetText( "Symbol", Name()
); // Demo trading system Short = Cover = 0; Buy = Cross( MACD(),
Signal() ); Sell = Cross( Signal(), MACD() );
// Using the CBT to
retrieve/save metrics SetOption( "UseCustomBacktestProc", True ); if (
Status( "action" ) == actionPortfolio ) { bo =
GetBacktesterObject(); bo.PreProcess(); MyHistStat1 = Null; for ( bar =
0; bar < BarCount; bar++ ) { bo.ProcessTradeSignals( bar ); stats =
bo.GetPerformanceStats( 0 ); MyHistStat1[ bar ] = stats.GetValue(
"UlcerIndex" ); // any metric can be
retrieved } bo.PostProcess(); AddToComposite( MyHistStat1, "~~~UI_" +
StaticVarGetText( "Symbol" ) + "_HISTORICAL", "X", atcFlagEnableInPortfolio |
atcFlagDefaults ); } PlotForeign( "~~~UI_HISTORICAL", "UlcerIndex
Historical", colorRed, styleLine );
-----Original Message----- From:
amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx]On
Behalf Of Tomasz Janeczko Sent: July 24, 2008 3:00 PM To:
amibroker@xxxxxxxxxxxxxxx Subject: [SPAM]Re: [amibroker] How to save Metrics
in Composites for Individual BTs
The same code. The only distinction
is that you need to run INDIVIDUAL backtest and use Static variable to save
name
StaticVarSet Text ("Symbol", Name() ); // Demo trading
system Short = Cover = 0; Buy=Cross( MACD(), Signal() ); Sell=Cross(
Signal(), MACD() );
// Using the CBT to retrieve/save
metrics SetOption("UseCustomBacktestProc", True ); if( Status("action") ==
actionPortfolio ) { bo = GetBacktesterObject();
bo.PreProcess(); MyHistStat1 = Null;
for(bar=0; bar <
BarCount; bar++) { bo.ProcessTradeSignals( bar
); stats = bo.GetPerformanceStats( 0 );
MyHistStat1[ bar ] = stats.GetValue("UlcerIndex"); // any metric can be
retrieved }
bo.PostProcess(); AddToComposite(
MyHistStat1, "~~~UI_" + StaticVarGet Text ("Symbol") + "_HISTORICAL", "X",
atcFlagEnableInPortfolio | atcFlagDefaults
); }
PlotForeign("~~~UI_HISTORICAL", "UlcerIndex Historical",
colorRed, styleLine );
__._,_.___
Please note that this group is for discussion between users only.
To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
For other support material please check also:
http://www.amibroker.com/support.html
__,_._,___
|