As I stated in my last . This could also be done in the CBI as well since both Equity and the Trade List are available there at the High Level .
Whether one chooses to look at it in that manner or via OLE/Automation where . oAA.Backtest(0) oAA.Export(filename) . would create ~~~Equity and put the Trade List in a file which could then be read back to build arrays based on trade entry / exit / win / loss etc by BarIndex() ... Either of these methodologies results in similar initial arrays that can be used to calculate whatever performance metrics one is interested in over whatever timeframe. My usage of stuff like this in IO was limited, for the moment at least, to the metrics that can be generated via Equity() alone i.e. CAR, MDD's, UPI, UI FlatEquity etc . initially more because of laziness then anything else . and also because I couldn't come up with a good reason to have the other trade oriented metrics in the OOS period as a determining factor of whether or not it was time to reoptimize . I'm sure at some point either I or some user will and then I'll add the rest . _____ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Al Venosa` Sent: Sunday, July 27, 2008 8:12 PM To: [email protected] Subject: Re: [amibroker] Re: How to save Metrics in Composites for Individual BTs Pardon the hyperbole on the use of the word "bonanza," but at least you saw it as stuff rather than fluff. :-)) Your new IO feature sounds pretty cool, Fred. I'll be interested in seeing it once it is finished. One of the features of the suggestion I wrote was to use the putative function as a type of positionscoring technique for selecting tickers for a given system or for selecting a system among several. Will your IO implementation be able to do this sort of thing? Al V. On 7/27/08, Fred Tonetti <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> net> wrote: Bonanza ? . Maybe . Although features like this are more stuff than fluff which unfortunately isn't for the most part what typically attracts newbies . I actually have something like what you suggest half implemented for a new feature I did in IO v3.0 which was to allow the WF period length to be predicated on performance metric related conditions occurring in the OOS. >From your original description it would appear this is the same sort of thing you are looking to do possibly with some additional twists to it. _____ From: [EMAIL PROTECTED] <mailto:[email protected]> ps.com [mailto:[EMAIL PROTECTED] <mailto:[email protected]> ps.com] On Behalf Of Al Venosa` Sent: Sunday, July 27, 2008 7:02 PM To: [EMAIL PROTECTED] <mailto:[email protected]> ps.com Subject: Re: [amibroker] Re: How to save Metrics in Composites for Individual BTs Thanks, Fred, but I haven't a clue how to do OLE/Automation, and I wonder how many AB users out there really do. That's why I was calling for a simple, non-painful, easy-to-use AFL function that would do this for the non-techie/programmer, and if it existed, AB would be the only trading software out there that would be able to do this. I bet It would be a profit bonanza for TJ. Al V. On 7/27/08, Fred Tonetti <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> net> wrote: I agree that this would be nice to have as directly as you have laid out . However, while somewhat painful, one can with Equity() and a list of trades calculate all the performance metrics as of any given bar or if you prefer as arrays of values . This could be fully automated with OLE/Automation _____ From: [EMAIL PROTECTED] <mailto:[email protected]> ps.com [mailto:[EMAIL PROTECTED] <mailto:[email protected]> ps.com] On Behalf Of Al Venosa Sent: Sunday, July 27, 2008 11:29 AM To: [EMAIL PROTECTED] <mailto:[email protected]> ps.com Subject: [amibroker] Re: How to save Metrics in Composites for Individual BTs Having read this interesting thread begun last week, I'd like to continue it with a follow-on question/comment that I think, if TJ were to implement it, would make Amibroker infinitely more useful to the actual trader. It would be awesome if we could have simple-to-use AFL functions that read AFL backtest metrics directly. Adding a lookback period would make them immensely more useful as indicators. What I am suggesting is to have a function like: getEquityMetric ( MetricName,LookBackPeriod); The example code provided by TJ gives us only the cumulative value of each metric. What I'm suggesting is to go beyond this one cumulative output number and create metric arrays with a specified lookback period. Then, when we plot these metrics in an indicator, we can visually look for correlations with price charts. For example, one could plot winning trades/month and see if they change with trend. Or one could look at AverageWin or UPI and see how that changes with trend. These are all correlations that are best analyzed visually (in an Indicator) but can ONLY be analyzed if we have access to these metrics for variable lookback periods. Another use for these functions would be as a positionscore in a trading system. What better way is there to select tickers/systems to trade than the actual performance of those tickers or systems? The procedure may require a preliminary scan/exploration to create metric- composites that can be read by the trading system and used as a positionscore. Critical here is that the metric can be read for any specified lookback period, i.e. 10 bars, 100 bars, etc. So the function must have a period argument, which is the most important factor. We already have equity(). Why not expand this with the other backtest metrics? Undoubtedly, all this can be implemented using the custom backtester, but this solution probably excludes >95% of all AmiBroker users. TJ, would this be possible to implement? Al Venosa --- In [EMAIL PROTECTED] <mailto:amibroker%40yahoogroups.com> ps.com, "Herman" <[EMAIL PROTECTED]> wrote: > > 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: [EMAIL PROTECTED] <mailto:amibroker%40yahoogroups.com> ps.com [mailto:[EMAIL PROTECTED] <mailto:amibroker%40yahoogroups.com> ps.com]On Behalf > Of Tomasz Janeczko > Sent: July 25, 2008 5:49 AM > To: [EMAIL PROTECTED] <mailto:amibroker%40yahoogroups.com> ps.com > 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: [EMAIL PROTECTED] <mailto:amibroker%40yahoogroups.com> ps.com > 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: [EMAIL PROTECTED] <mailto:amibroker%40yahoogroups.com> ps.com [mailto:[EMAIL PROTECTED] <mailto:amibroker%40yahoogroups.com> ps.com]On Behalf > Of Tomasz Janeczko > Sent: July 25, 2008 4:08 AM > To: [EMAIL PROTECTED] <mailto:amibroker%40yahoogroups.com> ps.com > 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: [EMAIL PROTECTED] <mailto:amibroker%40yahoogroups.com> ps.com > 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: [EMAIL PROTECTED] <mailto:amibroker%40yahoogroups.com> ps.com [mailto:[EMAIL PROTECTED] <mailto:amibroker%40yahoogroups.com> ps.com] On Behalf > Of Herman > Sent: Friday, 25 July 2008 9:31 AM > To: [EMAIL PROTECTED] <mailto:amibroker%40yahoogroups.com> ps.com > 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: [EMAIL PROTECTED] <mailto:amibroker%40yahoogroups.com> ps.com [mailto:[EMAIL PROTECTED] <mailto:amibroker%40yahoogroups.com> ps.com]On Behalf > Of Tomasz Janeczko > Sent: July 24, 2008 3:00 PM > To: [EMAIL PROTECTED] <mailto:amibroker%40yahoogroups.com> ps.com > 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 ); > _____ I am using the free version of SPAMfighter for private users. It has removed 512 spam emails to date. Paying users do not have this message in their emails. Try SPAMfighter <http://www.spamfighter.com/len> for free now! _____ I am using the free version of SPAMfighter for private users. It has removed 512 spam emails to date. Paying users do not have this message in their emails. Try SPAMfighter <http://www.spamfighter.com/len> for free now! _____ I am using the free version of SPAMfighter for private users. It has removed 512 spam emails to date. Paying users do not have this message in their emails. Try SPAMfighter <http://www.spamfighter.com/len> for free now!
