[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: How to save Metrics in Composites for Individual BTs



PureBytes Links

Trading Reference Links

FTR a correction:

> Eq == 1 * growth factor (1,1,1.10,1.10,1.067,1.05)//sadly I think 
> looping is required to produce an Eq curve???

the standardised Eq curve (factor) for this series is actually:

1,1,1.10,1.10,1.067,1.1203

Sorry about that.

brian_z




--- In amibroker@xxxxxxxxxxxxxxx, "brian_z111" <brian_z111@xxx> wrote:
>
> Hello Mike,
> 
> I introduced the forum to the concept of 'Root Cause Evaluation' 
(RCE)
> sometime in the recent past.
> 
> Given that it is only a formative (juvenile) idea at this stage, 
that 
> I have only discussed it, in the forum, in a cursory and piecemeal 
> fashion and that people take time (repetition required) to 
> acknowledge, let alone consider, new ideas it is no surprize that 
> most members aren't getting it.
> 
> 
> The basic premise is that the possible spread of future equity 
> outcomes, and hence metrics, can be estimated from the trade 
series% 
> and the time in trade.
> 
> The trade series%, along with it's metrics, are the profile of the 
> system (any system) whereas many of the things you mention 
(position 
> size/shrinking etc) are related to Portfolio Management.
> 
> Irrespective of what is done at the Portfolio Management level the 
> trade profile does not, and can not, change (if you use Portfolio 
> feedback to change your system rules then you have changed systems, 
> full stop).
> 
> Since there are a myriad of possible Portfolio Management (PM) 
rules, 
> IMO, it can cause a good deal of confusion by integrating System 
> Profile (SP) and PM in one step (which is what backtesters, buy 
user 
> demand, do).
> 
> It can help clarify trading a lot if we sometimes just focus on the 
> root causes.
> 
> Also, if we are going to use SP, in tandem with PM, as an inline 
> indicator then we might need to consider how to go about that in 
> efficient ways (above and beyond what is available in 'canned' 
> backtesters).
> 
> 
> Example of the premise:
> 
> SystemA == predefined buy, sell, price rules etc;
> Trade 1 == buy at 100, sell at 110, buy/sell == 1.1 (growthfactor), 
> number of bars in trade;//10% win
> bars out of trade;
> Trade 2 = buy at 123.71, sell at 120;//approx 3% loss
> bars in trade;
> etc;
> 
> We can not change a System A rule without changing the system (for 
> any reason) therefore the only (mathematically) possible data we 
can 
> acquire about the system is the tradeseries% and the bars in/bars 
out 
> for the trade (the values will vary from underlying to underlying 
but 
> not the available datapoints). 
> 
> Since the trade rules are fixed, the trade series is also fixed for 
a 
> fixed underlying (symbol) and time period.
> 
> Logically all metrics can only be derived from these root, or core, 
> metrics. 
> 
> Equity, or Portfolio, outcomes can vary depending on how much we 
> stake on the system (but the system does not, and can not change 
for 
> any given underlying series).
> 
> (Note that we can't control the underlying, only our system rules 
and 
> our staking).
> 
> 
> 
> 
> 
> Example of Equity/PM outcome:
> 
> From the above example the trade series is 1.10.0.97 (closed trades 
> only).
> 
> It could have bars out of trade in between - that doesn't affect 
the  
> Eq/PM outcome, only the % return relative to time (unless we take 
> into consideration interest paid on idle money, margin etc which, 
> once again is PM).
> 
> So a hypothetical trade%series is 1,1,1.10,1,0.97,1.05 (as growth 
> factor).
> 
> If we consider Eq as unit 1 (standardised) the outcome is:
> 
> Eq == 1 * growth factor (1,1,1.10,1.10,1.067,1.05)//sadly I think 
> looping is required to produce an Eq curve???
> 
> If we use fixed capital staking (say 100 InitialEq) we have:
> 
> Eq == 100,100,110,110,106.70,112.03
> 
> Note that the relativity of the staked Eq series, to the 
standardised 
> Eq series, doesn't change, so for the purpose of comparing system 
> performance, on the fly (using RCE) we can do without the equity 
> allocation and just use the standardized array if we choose to.
> 
> 
> 
> If we mix and match our staking then we get different Eq/PM 
outcomes:
> 
> Staking == 100,no change,no change,add 100 to the stake,no 
change,no 
> change
> Eq == 100,100,110,210,203.70,213.88
> 
> We end up in a much different Eq/PM place but the system itself 
> hasn't changed (it is no better, or worse, than it was before).
> 
> 
> I believe that the premises of Root Cause Evaluation are sound.
> 
> What I haven't done, in this thread, is:
> 
> a) provide the code to produce the tradeseries% array
> b) allow for open, or concurrent, trades
> c) provide the code to record bars in/out of trade
> d) prove that all possible metrics can be derived from the core 
> metrics
> 
> 
> 
> In the context of Al/Hermans thread:
> 
> - I am (they are) talking about inline performance metrics and not 
a 
> backtester (they are different things)
> - they didn't ask for an inline Portfolio Manager, only inline 
> relative performance of a system (on the fly)
> - they haven't told us 100% of what they want to do and why 
> (understandably)
> - since they are looking for a metric indicator there is no need to 
> measure bars in/out of trade ( we can see that unfold, bar by bar 
in 
> the indicator). If they want that I assume it can be done but that 
is 
> personal choice
> - the code needn't become too unwieldy because it would be a 
template 
> that they would apply on a metric by metric basis (presumably they 
> only want to watch one or two metrics at a time and not all of them)
> - it is not my idea, it is theirs. I am offering them some of my 
> seminal ideas on RCA and it is up to them if and how they apply it
> 
> 
> 
> Setting aside the proofs for the argument that all metrics can be 
> derived from the root inputs and restricting the discussion to the 
> code required for the tradeseries%.
> 
> 
> IMO the closed trade series, as % will do the job they want to do 
> (providing they understand the mindset of RCA).
> 
> I believe we can produce trade series arrays, given the system 
rules.
> 
> What I haven't done is produce an array trade series where we 
record 
> a second signal that occurs, for any symbol in our watchlist, while 
> we already have an open signal for that symbol but I expect that 
can 
> be done as well.
> 
> On top of that I haven't allowed for open trade values.
> 
> 
> IMO the slight error that these 'errors' introduce into their 
metric 
> won't have a significant affect on what they are doing but if they 
> want to count all signals, and account for open trades they can 
> (there is a trade off there because it will slow down their 
> indicator).
> 
> As I said before, the only real 'missing link' is how to get StDev, 
> for a trade series, on the fly (although so far Herman and Al 
haven't 
> said they are interested in that - the idea to track trade series 
SD 
> is mine).
> 
> I assume that iff I want to get the closed trade series array I can 
> just go back to Freds code and use/copy/modify that, OR get 
something 
> else that is already around OR make up my own OR ask the forum for 
> help OR ask support for help.
> 
> I am confident it can be done, in fact I am inclined to think I 
could 
> do it myself and that is saying something.
> 
> Are you suggesting it can't?
> 
> 
> 
> 
> Hope that opens up some new lines of thinking.
> 
> I appreciate I haven't done everything, that I possibly can, to 
> explain the concepts/practise but personal choice comes into 
> application anyway and there are countless variations on the 
> applications.
> 
> 
> 
> BTW 
> 
> I like your work.
> 
> Cheers,
> 
> Brian_z
> 
> 
> 
> 
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "Mike" <sfclimbers@> wrote:
> >
> > Brian,
> > 
> > I believe that the crux of the issue is the part that you only 
> > mentioned in passing:
> > 
> > > "It doesn't allow for the instances where a new buy signal is 
> > generated on an individual equity when we are already in a trade, 
> OR 
> > scaling in or out BUT it is only at the basic conceptual stage - 
> > perhaps it lends itself to more sophisticated calcs if required."
> > 
> > If I understand your post correctly, your premise hinges on the 
> > ability to recognize trades using the following lines:
> > 
> > > arrayAAA = if(no sell,1,trade%);   //runs on symbol AAA
> > > arrayBBB = if(no sell,1,trade%);//run on symbol BBB
> > 
> > Yet, the values to put in these arrays are the very values that 
> > cannot be determined in the absence of a fullblown portfolio 
> > backtest; One which takes into consideration such factors as 
> account 
> > balance, maximum number of positions, position scoring, position 
> size 
> > shrinking, redundent signals, scaling, custom signal cancelations 
> in 
> > CBT code, etc.
> > 
> > This is why the distinction is being made between "doable" 
> individual 
> > symbol metrics vs. vastly more complex portfolio metrics.
> > 
> > Mike
> > 
> > --- In amibroker@xxxxxxxxxxxxxxx, "brian_z111" <brian_z111@> 
wrote:
> > >
> > > Anyone?
> > > 
> > > Notwithstanding that Tomasz could do this stuff for us (if and 
> when 
> > > he comes back from his lovely holiday) it is fun to look at the 
> > > concepts involved and figure how we can do it ourselves, with 
> what 
> > we 
> > > have already.
> > > 
> > > I haven't read the various code solutions closely but I have 
been 
> > > following along at a distance (all the way back to Fred's 
earlier 
> > > PerformanceMetric code).
> > > Although I havent had a need for it I assumed that this stuff 
> could 
> > > be done with array programming OR maybe a loop or two (on the 
> fly - 
> > > no need to run the backtester).
> > > 
> > > My proposition is that all metrics can be derived from the 
trade 
> > > series (as %) and the time in trade i.e. the core metrics.
> > > 
> > > So if the trade series % is stored in an array then the array 
can 
> > be 
> > > used to produce the eq curve OR the metrics, on the fly, as 
> > required.
> > > 
> > > (I can't remember if this is what Fred did before - it was 
pretty 
> > > close to it - anyway - I think this is a slightly different 
> concept 
> > > applied to the same problem).
> > > 
> > > 
> > > 
> > > Simplified Example (in pidgin pseudocode):
> > > 
> > > - this basic example only gives the closed trade metrics
> > > 
> > > - for ease of discussion I am mentally referencing EOD data bar 
> by 
> > bar
> > > 
> > > - two symbols in a watchlist AAA, BBB
> > > 
> > > 
> > > 
> > > buy = whatever;
> > > sell = whatever;
> > > 
> > > sellvalue = etc;//code required
> > > 
> > > trade% = sellvalue/buyvalue;//needs to be expressed as 
> growthfactor 
> > > i.e. 3% win == 1.03, 3%loss == 0.97 etc
> > > 
> > > arrayAAA = if(no sell,1,trade%);   //runs on symbol AAA
> > > arrayBBB = if(no sell,1,trade%);//run on symbol BBB
> > > 
> > > 
> > > We would end up with two arrays:
> > > 
> > > arrayAAA == 1,1,1.10,1,1,1 etc//exited trade with 10% win on 
bar 3
> > > arrayAAA == 1,1,1.07,1,1,1 etc//exited trade with 7% win on bar 
3
> > > 
> > > 
> > > 
> > > the above arrays can easily be used to produce other arrays 
with 
> > W/L 
> > > ratios etc, including for any lookback (as per Tomasz's example 
> b).
> > > 
> > > To produce an eq curve (individual OR portfolio):
> > > 
> > > combined trade% is the product of arrayAAA and arrayBBB
> > > 
> > > arrayAAA == 1,1,1.10,1,1,1
> > > arrayAAA == 1,1,1.07,1,1,1
> > > combinedtrade%== 1,1,1.177,1,1,1//bar by bar product of above 
two 
> > > arrays
> > > 
> > > EquityCurveArray = Initial Equity * combinedtrade%;
> > > 
> > > example:
> > > 
> > > InitialEquity = 100;
> > > 
> > > 100 * 1 *1 * 1.177 * 1 * 1 * 1 == 
> > > EquityCurveArray == 100,100, 117.70,117.70,117.70,117.70 etc
> > > 
> > > which is the same even if the two trades exit on separate bars.
> > > 
> > > 100 *1.10 * 1.07 = 117.70;
> > > 
> > > Note that the value of 1 is used to denote 'no trade' so it 
> doesn't 
> > > affect equity.
> > > 
> > > All of the metrics required, on the fly, can be calculated 
using 
> > > lookback periods for the combinedtrade% array (it is like an 
> array 
> > > that is the carrier of the trade series) AND/OR calculating 
> equity 
> > on 
> > > the fly AND the code already posted OR some new relatively 
simple 
> > > array code.
> > > 
> > > The only thing we can't do is get a standard dev of the trade 
> > series 
> > > because we can't write them into an array without all of the no 
> > > trades (like a static variable except a static array).
> > > 
> > > If StDev of the trade series were could we calcuate every 
single 
> > > metric directly without the need for the eq curve?
> > > 
> > > I think so but I haven't checked to be certain about it 
> (certainly 
> > > every worthwhile one because a lot of them are old rubbish).
> > > 
> > > Time in trade is only needed if we want to work out percentage 
> > gains 
> > > relative to time?
> > > 
> > > It doesn't allow for the instances where a new buy signal is 
> > > generated on an individual equity when we are already in a 
trade, 
> > OR 
> > > scaling in or out BUT it is only at the basic conceptual stage -
 
> > > perhaps it lends itself to more sophisticated calcs if required.
> > > 
> > > 
> > > 
> > > BTW 
> > > 
> > > I don't think AB or Tomasz is dumb - only that the trading 
> > community 
> > > in general, IMO, is bizarrely obsessive about eq curve 
> > > analysis/metrics.
> > > 
> > > 
> > > brian_z
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > --- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <groups@> 
> > > wrote:
> > > >
> > > > Hello,
> > > > 
> > > > Yes, there are generally 3 different metrics "areas" in terms 
> of 
> > > computational complexity:
> > > > 
> > > > a) metrics derived directly from Equity (CAR, Drawdowns, UPI, 
> > > Sharpe, Std error, etc) 
> > > > - they can be easily calculated directly from Equity data 
> > > (~~~EQUITY) as shown in the 
> > > > code that Fred posted below.
> > > > There is no computational difference between calculating them 
> on 
> > > portfolio or individual
> > > > symbol basis.
> > > > 
> > > > b) metrics NOT derived from equity (number of winners, 
> > winner/loser 
> > > ratio, expectancy, etc)
> > > > - these metrics needs actual backtest to be performed to get 
> the 
> > > TRADE LIST and 
> > > > perform calculations based on trade list.
> > > > Performing backtest on SINGLE security is done by Equity() 
> > function 
> > > and 
> > > > single-security metric "indicators" are possible with the same
> > > > computational complexity as Equity() function has. 
> > With "possible" 
> > > I mean that I could implement that
> > > > if there is enough demand.
> > > > 
> > > > c) same as b) BUT for Portfolio-level backtest. Again you 
need 
> a 
> > > trade list to calculate them.
> > > > No matter which approach is used, full-blown portfolio 
backtest 
> > for 
> > > specified "lookback period"
> > > > is required. It is too complex to be done on-the-fly in real 
> > time. 
> > > Hence proposed solution of using
> > > > CBI to generate stats and then refer to them using Foreign() 
> > > function.
> > > > 
> > > > 
> > > > Best regards,
> > > > Tomasz Janeczko
> > > > amibroker.com
> > > >   ----- Original Message ----- 
> > > >   From: Fred Tonetti 
> > > >   To: amibroker@xxxxxxxxxxxxxxx 
> > > >   Sent: Tuesday, July 29, 2008 6:16 AM
> > > >   Subject: RE: [amibroker] Re: How to save Metrics in 
> Composites 
> > > for Individual BTs
> > > > 
> > > > 
> > > >   . and if you are wanting the performance metrics as arrays 
> over 
> > > some shorter length then the backtest period and you aren't 
> wanting 
> > > to do it in the CBI the while you're waiting for it to be 
> available 
> > > as a built in AFL function you can fill in the rest of this . 
> Both 
> > TJ 
> > > in an earlier post and the DOC have the formulas for the rest 
of 
> > the 
> > > performance metrics .
> > > > 
> > > >   MACDx   = MACD(12, 26);
> > > > 
> > > >   MACDsig = Signal(12, 26, 9);
> > > > 
> > > >    
> > > > 
> > > >   Plot (MACDx,   "MACD", colorRed);
> > > > 
> > > >   Plot (MACDsig, "Sig",  colorWhite);
> > > > 
> > > >    
> > > > 
> > > >   Buy  = Cross(MACDx, MACDsig);
> > > > 
> > > >   Sell = Cross(MACDsig, MACDx);
> > > > 
> > > >    
> > > > 
> > > >   function getMetric(Metric, Length)
> > > > 
> > > >   {
> > > > 
> > > >          Metric = StrToUpper(Metric);
> > > > 
> > > >          BIR    = IIf(Status("BarInRange") > 0, 1, Null);
> > > > 
> > > >          CurEq  = Foreign("~~~EQUITY", "C", 1);
> > > > 
> > > >          MaxEq  = HHV(CurEq, Length);
> > > > 
> > > >          CurDD  = IIf(CurEq < MaxEq, 100 * (MaxEq - CurEq) / 
> > MaxEq, 
> > > 0);
> > > > 
> > > >          MaxDD  = HHV(CurDD, Length);
> > > > 
> > > >          SqrDD  = CurDD ^ 2;
> > > > 
> > > >          SumDD  = Sum(SqrDD, Length);
> > > > 
> > > >          UI     = sqrt(SumDD / Length);
> > > > 
> > > >          if (Metric == "CDD")
> > > > 
> > > >                 Value = CurDD;
> > > > 
> > > >          else if (Metric == "MDD")
> > > > 
> > > >                 Value = MaxDD;
> > > > 
> > > >          else if (Metric == "UI")
> > > > 
> > > >                 Value = UI;
> > > > 
> > > >          else
> > > > 
> > > >                 Value = Null;
> > > > 
> > > >          return Value;
> > > > 
> > > >   }
> > > > 
> > > >    
> > > > 
> > > >   Plot(getMetric("UI", 20), "UI", colorYellow, 
> > styleLeftAxisScale);
> > > > 
> > > >    
> > > > 
> > > >    
> > > > 
> > > > 
> > > > --------------------------------------------------------------
--
> --
> > --
> > > ----------
> > > > 
> > > >   From: amibroker@xxxxxxxxxxxxxxx 
> > > [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of Paul Ho
> > > >   Sent: Monday, July 28, 2008 11:59 PM
> > > >   To: amibroker@xxxxxxxxxxxxxxx
> > > >   Subject: RE: [amibroker] Re: How to save Metrics in 
> Composites 
> > > for Individual BTs
> > > > 
> > > >    
> > > > 
> > > >   Herman
> > > >   I really can't see the difficulty to achieve any of these, 
> see 
> > my 
> > > reply
> > > >   below. 
> > > > 
> > > >   ________________________________
> > > > 
> > > >   From: amibroker@xxxxxxxxxxxxxxx 
> > [mailto:amibroker@xxxxxxxxxxxxxxx]
> > > >   On Behalf Of Herman
> > > >   Sent: Tuesday, 29 July 2008 11:32 AM
> > > >   To: amibroker@xxxxxxxxxxxxxxx
> > > >   Subject: RE: [amibroker] Re: How to save Metrics in 
> Composites 
> > for
> > > >   Individual BTs
> > > > 
> > > > 
> > > > 
> > > >   Hello Fred,
> > > > 
> > > >   Putting technical problems and limitations aside it is 
clear 
> to 
> > me
> > > >   that having access to period-based performance metrics is 
> > > critical in
> > > >   trading. 
> > > > 
> > > >   [I don't see a lot of technical difficulty. See my previous 
> > post 
> > > on ONE way
> > > >   to do this. There probably a few other ways to do it I can 
> > think 
> > > of.]
> > > > 
> > > >   Since the Equity curve is based on system performance it 
> makes 
> > > common sense
> > > >   that performance metrics will lead on the Equity. Most 
> > > performance metrics
> > > >   can't be extracted from the equity curve; they are lost at 
> that
> > > >   summary-stage. For example, DrawDown is the result of 
> advanced 
> > > system
> > > >   failure; it might very well have been possible to detect 
the 
> > > upcoming
> > > >   failure (DD) by looking at some very basic metrics. Simply 
> > > looking at the
> > > >   number of winning trades or profit/trade, might have 
alerted 
> > us. 
> > > Using more
> > > >   sophisticated metrics, like a period based UPI Indicator, 
we 
> > > might have seen
> > > >   a very clear and gradual system failure. All this is 
> especialy 
> > > true for
> > > >   faster trading systems where metrics become very smooth 
> > > indicators.
> > > > 
> > > >   To look at metrics for the entire duration of the backtest 
> may 
> > > come
> > > >   in handy during development however during real trading it 
is 
> > > useless. It is
> > > >   simply due to a reluctance to break with tradition (a 
problem 
> > for 
> > > most
> > > >   traders) that we don't have period-based performance 
> indicators 
> > > today. They
> > > >   are long overdue. Sure, they they are 'doable' in 
AmiBroker, 
> > but 
> > > how many
> > > >   users would be able to write such code? In my opinion not 
> more 
> > > that 1%. To
> > > >   develop systems efficiently we need basic afl tools; no one 
> > wants 
> > > to spend
> > > >   two months learning OLE only to find out that it doesn't 
fill 
> > the
> > > >   requirement or is to complicated for the user. Same for the 
> > CBT, 
> > > who wants
> > > >   to spend two months learning it just to test and idea that 
> may 
> > or 
> > > may not
> > > >   work? Time is precious...we want to trade, not become 
> > professional
> > > >   programmers.
> > > > 
> > > >   [firstly it doesn't take 2 months, probably wont even be 2 
> > weeks. 
> > > Secondly
> > > >   it doesn't have to involve OLE as far as I can gather, 
though 
> > OLE 
> > > is clearly
> > > >   useful in other area that I am finding out for myself. 
> Thirdly, 
> > > trading is a
> > > >   lifetime persue, not a five minute flash in the pan. While 
> only 
> > > Tomasz will
> > > >   know fully, I suspect, do what you say as a "simple" 
function 
> > > outside CBT
> > > >   would involve storing heaps of unnecessary data, Who is 
then 
> > > paying for the
> > > >   penalty of that?. Inside CBT its relatively simple to 
create. 
> > But 
> > > you will
> > > >   still need to learn CBT. By the way, Is there any other 
> > software 
> > > out there
> > > >   that can do this sort of things. And in AB it is readily 
> > > available, with
> > > >   just a few lines. What is the problem?]
> > > > 
> > > > 
> > > >   A few common applications for metric indicators are:
> > > > 
> > > >   1) When trading a number of different systems one wants to 
> know
> > > >   early when a system starts to fail. How else can one make a 
> > > timely switch?
> > > >   Just like you may want to trade funds with a rotational 
> system 
> > > you want to
> > > >   rotate the trading systems themselves.
> > > >   2) It is very common for trading systems to fade in and out 
of
> > > >   performance. To detect when a trading system fails and to 
> > switch 
> > > to another
> > > >   system requires, again, monitoring system performance 
> metrics. 
> > > imo, There is
> > > >   just no other way around it.
> > > >   3) And of course we want to know when a ticker loses its 
> > character
> > > >   and stops working. Here again performance metrics might be 
> the 
> > > best way to
> > > >   detect ticker failure. 
> > > > 
> > > >   A function like getPerformanceMetric ( MetricName, 
> > LookBackPeriod)
> > > >   would find wide application. Most people think right away 
of 
> > > portfolio
> > > >   trading however performance metrics should be calculated 
for 
> > > individual
> > > >   stocks, they will lose their meaning if derived from 
> portfolio 
> > > results.
> > > > 
> > > >   I am not saying that it is easy to design such indicators, 
> > perhaps
> > > >   it is extremely difficult. But that doesn't remove the need 
> for 
> > > them.
> > > > 
> > > >   Just my two cents worth :-)
> > > >   Best regards,
> > > >   herman
> > > > 
> > > >   [a lot of what you have asked for can be readily derived 
from 
> > the 
> > > equity
> > > >   curve, without even going through CBT, while the rest is a 
> just 
> > a 
> > > few lines
> > > >   in CBT, plus a function or two outside. Recently I helped 
> > > somebody code the
> > > >   UI for individual stocks, 5 lines of AFL, that's all. I 
just 
> > > wonder if this
> > > >   is a mountain, or a mole hill]
> > > > 
> > > >   -----Original Message-----
> > > >   From: amibroker@xxxxxxxxxxxxxxx
> > > >   [mailto:amibroker@xxxxxxxxxxxxxxx]On Behalf Of Fred Tonetti
> > > >   Sent: July 28, 2008 12:44 PM
> > > >   To: amibroker@xxxxxxxxxxxxxxx
> > > >   Subject: [SPAM]RE: [amibroker] Re: How to save Metrics in
> > > >   Composites for Individual BTs
> > > > 
> > > > 
> > > > 
> > > >   Al,
> > > > 
> > > >   What you are looking for in AB is I believe
> > > >   a little more difficult then or at least as time consuming 
as 
> > you 
> > > think it
> > > >   is .
> > > > 
> > > >   Share ? . Code ?
> > > > 
> > > >   LOL . I thought I did in that post . 
> > > > 
> > > >   Ok . Kidding aside . Assuming that 
> > > > 
> > > >   - AB is running 
> > > > 
> > > >   - AA has the AFL you want to run ( This doesn't
> > > >   mean the formula editor as the FE and AA aren't coupled )
> > > > 
> > > >   - AA Settings for ApplyTo / Range etc are as you
> > > >   want then
> > > > 
> > > >   This VBS code would run a BackTest and
> > > >   export the Trade List to a File
> > > > 
> > > >   Dim oAB
> > > > 
> > > >   Dim oAA
> > > > 
> > > >   Set oAB = CreateObject("Broker.Application")
> > > > 
> > > >   Set oAA = oAB.Analysis
> > > > 
> > > >   oAA.Backtest(0)
> > > > 
> > > >   oAA.Export("Dummy.csv") 
> > > > 
> > > >   The code above should be saved in a .vbs
> > > >   filetype ( name of your choosing ) and then simply double 
> > > clicking it will
> > > >   produce the file.
> > > > 
> > > >   This could easily be changed to running an
> > > >   optimize which will produce all the performance metrics in 
> the 
> > AA 
> > > results
> > > >   which could then be exported by changing . 
> > > > 
> > > >   oAA.Backtest(0)
> > > > 
> > > >   to .
> > > > 
> > > >   oAA.Optimize(0)
> > > > 
> > > >   Ideally the optimize above would be a one
> > > >   step optimize if you will just to produce the performance 
> > metrics 
> > > related to
> > > >   the backtest .
> > > > 
> > > >   With a little more work i.e. a loop to set
> > > >   the beginning and ending dates one could get performance 
> > metrics 
> > > externally
> > > >   for whatever lookback length one wanted one after the 
other .
> > > > 
> > > > 
> > > >   ________________________________
> > > > 
> > > >   From: amibroker@xxxxxxxxxxxxxxx
> > > >   [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of Al Venosa`
> > > >   Sent: Monday, July 28, 2008 12:17 PM
> > > >   To: amibroker@xxxxxxxxxxxxxxx
> > > >   Subject: Re: [amibroker] Re: How to save Metrics in
> > > >   Composites for Individual BTs
> > > > 
> > > >   Dear TJ and Fred: 
> > > > 
> > > >   Thank you for these suggestions. However, what I am asking
> > > >   for is a simple AFL function in which we can specify the 
> > lookback 
> > > period for
> > > >   the metric in question, nothing more. To observe the 
> > difference, 
> > > you can
> > > >   simply substitute an MA() for the required function, as 
shown 
> > > below. When
> > > >   you view the graph, you will see, I think, what I am 
talking 
> > > about. 
> > > > 
> > > >   Plot(C,"",1,128); 
> > > >   Plot(MA(C,50),"FixedLookBack",colorRed,1); // the requested
> > > >   solution 
> > > >   Plot(MA(C,BarIndex()),"ExistingNow",colorBlue,1); // TJ's
> > > >   and Fred's solution. 
> > > > 
> > > >   I believe what TJ has suggested, if I am interpreting it
> > > >   correctly, is that I would be running a backtest for each 
bar 
> > in 
> > > a loop,
> > > >   which would be complex and very slow. Maybe I'm asking the 
> same 
> > > thing. If
> > > >   so, tell me, and I'll desist. An alternative solution is to 
> use 
> > > the Walk
> > > >   Forward Individual Backtester to implement a system that 
uses 
> > > performance
> > > >   metrics as position score. 
> > > > 
> > > >   BTW, Fred, are you willing to share the complete working
> > > >   code for your 2-line export?
> > > > 
> > > >   Thank you. 
> > > > 
> > > >   Al V.
> > > > 
> > > >   On 7/28/08, Tomasz Janeczko
> > > >   <groups@ <mailto:groups@> > wrote:
> > > > 
> > > >   Hello,
> > > > 
> > > >   It is doable with custom backtester and not
> > > >   so complicated.
> > > > 
> > > >   As described in detail here:
> > > > 
> > > >   http://www.amibroker.com/guide/a_custommetrics.html
> > > >   <http://www.amibroker.com/guide/a_custommetrics.html> 
> > > > 
> > > >   You have direct access to ANY backtest
> > > >   performance metric using 
> > > > 
> > > >   GetPerformanceStats() function of backtester object.
> > > > 
> > > >   There is no obstacle in calling it every bar
> > > >   and storing the result in the array if you wish.
> > > > 
> > > >   Let say you want UPI as array.
> > > > 
> > > >   // your trading system here 
> > > >   Buy = ...
> > > > 
> > > >   Sell = ...
> > > > 
> > > >   SetCustomBacktestProc(""); 
> > > > 
> > > >   /* Now custom-backtest procedure follows */ 
> > > > 
> > > >   if( Status("action") == actionPortfolio ) 
> > > >   { 
> > > >   UPI = 0; 
> > > >   bo = GetBacktesterObject(); 
> > > > 
> > > >   bo.PreProcess(); 
> > > > 
> > > >   for( bar = 0; bar < BarCount; bar++ ) 
> > > >   { 
> > > >   bo.ProcessTradeSignals( bar ); 
> > > > 
> > > >   st = bo.GetPerformanceStats(0); // get stats for all
> > > >   trades 
> > > > 
> > > >   UPI[ bar ] = st.GetValue("UlcerPerformanceIndex"); 
> > > >   } 
> > > > 
> > > >   bo.PostProcess(); 
> > > > 
> > > >   AddToComposite( UPI, "~~~UPI", "X", atcFlagDefaults |
> > > >   atcFlagEnableInPortfolio ); 
> > > >   } 
> > > > 
> > > >   Now ~~~UPI ticker will contain bar-by-bar
> > > >   values of Ulcer Performance Index.
> > > > 
> > > >   As for "specifying lookback period" it is
> > > >   doable by creating Xth composites (and X backtests) each 
> > > containing values
> > > >   for specified
> > > > 
> > > >   lookback period.
> > > > 
> > > >   As for Equity() - this is SINGLE security
> > > >   (OLD) backtest. It has no comparision to portfolio level 
> > backtest 
> > > that
> > > > 
> > > >   must go through entire portfolio. The complexity of
> > > >   portfolio backtest is Nth times the single security backtest
> > > > 
> > > >   where N is number of symbols in portfolio. Therefore it is
> > > >   not feasible to be calculated on-the-fly in real time like
> > > > 
> > > >   single-security backtest (i.e. Equity()).
> > > > 
> > > > 
> > > >   Best regards,
> > > >   Tomasz Janeczko
> > > >   amibroker.com
> > > > 
> > > >   ----- Original Message ----- 
> > > > 
> > > >   From: Al Venosa` <mailto:avcinci@> 
> > > > 
> > > >   To: amibroker@xxxxxxxxxxxxxxx
> > > >   <mailto:amibroker@xxxxxxxxxxxxxxx> 
> > > > 
> > > >   Sent: Monday, July 28, 2008
> > > >   1:02 AM
> > > > 
> > > >   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
> > > >   <ftonetti@ <mailto:ftonetti@> > 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:
> > > >   amibroker@xxxxxxxxxxxxxxx <mailto:amibroker@xxxxxxxxxxxxxxx>
> > > >   [mailto:amibroker@xxxxxxxxxxxxxxx 
> > > <mailto:amibroker@xxxxxxxxxxxxxxx> ] On
> > > >   Behalf Of Al Venosa
> > > >   Sent: Sunday, July 27, 2008 11:29 AM
> > > >   To: amibroker@xxxxxxxxxxxxxxx
> > > >   <mailto:amibroker@xxxxxxxxxxxxxxx> 
> > > >   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 amibroker@xxxxxxxxxxxxxxx
> > > >   <mailto:amibroker%40yahoogroups.com> , "Herman" <psytek@> 
> 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: amibroker@xxxxxxxxxxxxxxx
> > > >   <mailto:amibroker%40yahoogroups.com> 
> > > [mailto:amibroker@xxxxxxxxxxxxxxx
> > > >   <mailto:amibroker%40yahoogroups.com> ]On 
> > > >   Behalf
> > > >   > Of Tomasz Janeczko
> > > >   > Sent: July 25, 2008 5:49 AM
> > > >   > To: amibroker@xxxxxxxxxxxxxxx
> > > >   <mailto:amibroker%40yahoogroups.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: amibroker@xxxxxxxxxxxxxxx
> > > >   <mailto:amibroker%40yahoogroups.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: amibroker@xxxxxxxxxxxxxxx
> > > >   <mailto:amibroker%40yahoogroups.com> 
> > > [mailto:amibroker@xxxxxxxxxxxxxxx
> > > >   <mailto:amibroker%40yahoogroups.com> ]On 
> > > >   Behalf
> > > >   > Of Tomasz Janeczko
> > > >   > Sent: July 25, 2008 4:08 AM
> > > >   > To: amibroker@xxxxxxxxxxxxxxx
> > > >   <mailto:amibroker%40yahoogroups.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: amibroker@xxxxxxxxxxxxxxx
> > > >   <mailto:amibroker%40yahoogroups.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: amibroker@xxxxxxxxxxxxxxx
> > > >   <mailto:amibroker%40yahoogroups.com> 
> > > [mailto:amibroker@xxxxxxxxxxxxxxx
> > > >   <mailto:amibroker%40yahoogroups.com> ] 
> > > >   On Behalf
> > > >   > Of Herman
> > > >   > Sent: Friday, 25 July 2008 9:31 AM
> > > >   > To: amibroker@xxxxxxxxxxxxxxx
> > > >   <mailto:amibroker%40yahoogroups.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: amibroker@xxxxxxxxxxxxxxx
> > > >   <mailto:amibroker%40yahoogroups.com> 
> > > [mailto:amibroker@xxxxxxxxxxxxxxx
> > > >   <mailto:amibroker%40yahoogroups.com> ]On 
> > > >   Behalf
> > > >   > Of Tomasz Janeczko
> > > >   > Sent: July 24, 2008 3:00 PM
> > > >   > To: amibroker@xxxxxxxxxxxxxxx
> > > >   <mailto:amibroker%40yahoogroups.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 513 spam emails to date.
> > > >   Paying users do not have this message in their emails.
> > > >   Try SPAMfighter for free now!
> > > >
> > >
> >
>



------------------------------------

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
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:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/