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

[amibroker] Re: Inline Backtester Metrics



PureBytes Links

Trading Reference Links

Fred,

A couple more.

For multiple securities the Portfolio GF is the product of the 
individual symbol GF's - it is like a matrix that adds up in both the 
vertical and horizontal directions, so I am good for Portfolio Eq 
(that was the missing piece from our first round of discussions).

I haven't worked through all of the implications of that, especially 
for the other metrics.

Don't you like that idea for Portfolio Eq?



Re complexity of code:

Not having a go at you, or Tomasz, but when I push the backtester 
button how many lines of code do you think 'we' are running then?

So, it is OK for Tomasz to do it where we can't see it but you don't 
like it if I expose the innards?

Also this idea that it can't be done! 

How did Tomasz do it?

Does he ship Tinkerbell dust with his copies of AB?

AB can't do more than start with the buy/sell price and bars in/bars 
out can it? I am trying to think of some other possible required raw 
inputs for a BT but I can't (outside of MM which I am not doing yet).

brian_z



--- In amibroker@xxxxxxxxxxxxxxx, "brian_z111" <brian_z111@xxx> wrote:
>
> > Approaches like this might be sufficient for extremely simple 
> systems
> > trading single securities in or out . no scaling . no position 
> sizing . no
> > multiple securities . no position scoring .
> 
> I am not sure what Herman & Al are up to (don't expect them to tell 
> me all OR that they even have fixed needs).
> 
> It might do a job for them.
> 
> I am using a modular approach, and keeping it basic, because user 
> needs could take it in a lot of directions so anyone interested 
will 
> probably have to add their own bells and whistles, unless we touch 
> somewhere.
> 
> I am really doing it for myself though and I wanted to start with 
the 
> most basic scenario, then build on it from there, so I have a 
stepped 
> degree of difficulty.
> 
> I am not interested in scaling (at least I wasn't until Jan said he 
> uses it), Psize or Pscore (or open position equity which you didn't 
> mention) at the moment.
> 
> I wasn't out to solve for multiple securities but I think I have 
that 
> covered anyway (Herman wants that though).
> 
> I am interested in all signals so I am starting to play with that - 
> not sure what I am letting myself in for there.
> 
> > The problem is as you add any of these complexities the AFL to 
> >support them
> > becomes needlessly complex .
> 
> Yes, I might not go much further.
> 
> A little bit of experience of the complexities of programming won't 
> hurt me.
> 
> I am actually comfortable with the metrics like W/L, PayOff Ratio 
and 
> I  can get them pretty easy for the trade series I have already.
> 
> Plus I said before that we couldn't get the SD of an inline trade 
> series but now that I am into it I think I see a way that I can. 
> 
> > Again . Why reinvent the wheel . This is why there is a 
backtester .
> 
> Core reasons:
> 
> I have it in my head that there will be a time penalty if I run the 
> BT.
> 
> It doesn't seem such an elegant solution to me.
> 
> I just like it more (not really a reason since we can't explain our 
> likes and dislikes.
> 
> 
> Indirect reasons (not in order):
> 
> - it might help Herman and he does a lot for others and also has 
been 
> good with me
> - I have a stubborn side and once I get my teeth into something?
> - I am not so motivated to write code at the moment but I seem to 
be 
> enjoying this one
> - my RCE 'theorom' aren't going to be a lot more useful to me if 
> I 'write them up' but it has a certan elegance so it is worthy of 
> completion
> - my RCE theories aren't complete so this helps me sort it in my 
head 
> (I have to take it apart and consider each step logically - if I 
can 
> code it I must understand it)
> - we have different personal styles/trading styles. I like to get a 
> lot of chart time and trade in the charts without props (sometimes 
I 
> can't use the optimum broker available, which is IB for US 
> foreigners, for various reasons, so it is good for me to be able to 
> trade in a Java platform without props.  For that reason I need to 
> comfortable at working in line (a Java platform with no 
customisation 
> is the real trading world for me).
> - it is helping me understand the backtester more
> - I am playing around with the idea of an inline MM indicator and I 
> might try to throw one in at the end of the code
> 
> No guarantee I will go beyond trying concurrent multiple trades 
> anyway.
> 
> > for (i = 1; i < BarCount; i++)
> > {
> > EF[i] = EF[i-1] * TradeSeries[i];
> > }
> >  
> > This can be done without a loop using logs, addition and 
antilogs .
> 
> That's great.
> Thanks.
> I really wanted not to have to use a loop.
> I wish I had thought of that.
> 
> I have used log before - funny how sometimes you can't connect the 
> dots until someone shows you how (experience).
> 
> brian_z
> 
> --- In amibroker@xxxxxxxxxxxxxxx, Fred Tonetti <ftonetti@> wrote:
> >
> > Approaches like this might be sufficient for extremely simple 
> systems
> > trading single securities in or out . no scaling . no position 
> sizing . no
> > multiple securities . no position scoring .
> > 
> >  
> > 
> > The problem is as you add any of these complexities the AFL to 
> support them
> > becomes needlessly complex .
> > 
> >  
> > 
> > Again . Why reinvent the wheel . This is why there is a 
backtester .
> > 
> >  
> > 
> > . And as far as . 
> > 
> >  
> > 
> > for (i = 1; i < BarCount; i++)
> > {
> > EF[i] = EF[i-1] * TradeSeries[i];
> > }
> > 
> > 
> > 
> > This can be done without a loop using logs, addition and 
antilogs .
> > 
> >  
> > 
> >   _____  
> > 
> > From: amibroker@xxxxxxxxxxxxxxx 
[mailto:amibroker@xxxxxxxxxxxxxxx] 
> On Behalf
> > Of brian_z111
> > Sent: Friday, August 01, 2008 6:49 AM
> > To: amibroker@xxxxxxxxxxxxxxx
> > Subject: [amibroker] Re: Inline Backtester Metrics
> > 
> >  
> > 
> > Herman and Al,
> > 
> > I took the scissors to my first effort.
> > 
> > It isn't an inline backtester, rather an inline RootCauseMetrics 
> > indicator (possibly it could be used for calculating the common 
> > Performance Metrics 'on the fly', including with lookback 
periods). 
> > 
> > This is the basic starting module.
> > 
> > It should be possible to modify it to allow for concurrent 
signals, 
> > open trade interest, although it gets a bit harder from here for 
me 
> > (maybe not for others).
> > 
> > I have checked it over a few charts and so far it stands up O.K
> > I haven't used in the line of fire though.
> > 
> > Any potential in it for you guys?
> > 
> > FTR
> > 
> > This is a continuation of discussion at topic:
> > 
> > "How To Save Metrics In Composite For Indidual BT's"
> > 
> > A little background discussion about the idea behind the code is 
at
> > 
> > message # 127383 and # 127420 in the above thread.
> > 
> > //P_InLineMetrics
> > 
> > //Monday is used as the example because it is an unambiguous Buy
> > //Typically most markets have Mon or Fri public holidays so it 
> allows 
> > for checking code response to duplicate buys and sells (signal 
> errors)
> > //BarIndex() is added as a buy condition to workaround the 
> > propogating of {empty} values that can arise in the first few bars
> > //A latch is used so that only one trade can be entered at a time 
> and 
> > every Sell must have a corresponding Buy
> > //Plots the trade series, as GrowthFactor, which is equivalent to 
%
> > //No trades are accounted for and recorded as GF 1
> > //The code doesn't identify break even trades i.e. GF == 1 but it 
> can 
> > be modified to do so
> > //since commissions aren't considered the Eq outcome for break 
even 
> > trades is correct
> > //the progressive product of the GF is equivalent to the Equity 
> Curve 
> > for a fixed capital investment
> > //if the intitial Equity is 1 the EQ is the standardised Equity 
> Factor
> > //Equity == Initial Equity * EF
> > //the product of individual GF's, sumbol by symbol, is the 
> Portfolio 
> > Growth Factor the progessive product of which produces the 
> Portfolio 
> > Equity Factor
> > //same bar entry/exits are not allowed but the code can be 
modified 
> > for that if required
> > 
> > //PART IA TRADE SERIES MODULE (CLOSED TRADES - ONLY ONE TRADE PER 
> > SYMBOL OPEN AT A TIME)
> > 
> > M = DayOfWeek() == 1;
> > F = DayOfWeek() == 5;
> > BI = BarIndex()== 0;
> > 
> > B = M;//Buy on Monday
> > S = F OR BI;//first bar set to sell and then sell on Friday's 
> > thereafter
> > 
> > B = Flip(B,S);//latches the Buy signal to prevent concurrent buys
> > 
> > BP = SP = C;//BuyPrice, SellPrice
> > 
> > //Plot(B,"Buy",5,1);//FFP - fault finding plot used when writing 
> the 
> > code
> > //Plot(S,"Sell",2,1);//FFP
> > 
> > //Plot(BP,"BuyPrice",5,1);//FFP
> > //Plot(SP,"SellPrice",2,1);//FFP
> > 
> > TradeSeries = IIf(S ==1 AND Ref(B,-1) == 1,SP/ValueWhen(B == 1 
AND 
> Ref
> > (B,-1) == 0, BP,1),1);//
> > 
> > Plot(TradeSeries,"TradeSeries",1,1);//as GrowthFactor
> > 
> > EF = 1;//initialises EquityFactor to 1
> > 
> > for (i = 1; i < BarCount; i++)
> > {
> > EF[i] = EF[i-1] * TradeSeries[i];
> > }
> > 
> > Plot(EF,"EquityFactor",5,1);
> > 
> > --- In amibroker@xxxxxxxxx <mailto:amibroker%40yahoogroups.com> 
> ps.com,
> > "brian_z111" <brian_z111@> wrote:
> > >
> > > Herman,
> > > 
> > > IBM PartI
> > > 
> > > I am not sure if this is along the lines that you are 
> investigating.
> > > It might be a starting point.
> > > Sophisticated functions can be built from the concept.
> > > 
> > > Example of using single symbol equity function to back 
calculate 
> > the 
> > > trade series.
> > > 
> > > I used buy Tues(C) and sell Thurs(C) with one month of data to 
> test 
> > > the code as I went along (this gave me unambiguous signals with 
> > only 
> > > one signal at a time - I believe you can use an eq flag to dump 
> > dual 
> > > signals for real life use).
> > > 
> > > Note: some weeks don't have Mons or Fris so I wanted to avoid 
no 
> > > signals, caused by short weeks, during testing
> > > 
> > > I used barindex() > 4 to cut out the first week in the month so 
> > that 
> > > I started with no signals for a few bars before the first buy.
> > > 
> > > I left the plot code in there but commented out (I plotted each 
> > line 
> > > to test the veracity of the code).
> > > 
> > > Note that when the trade series is used to recreate the eq 
curve 
> > (as 
> > > a cross check) it only matches on the exit bars for each trade.
> > > I tried it on 10 years of Yahoo data and the final eqs matched 
to 
> 2 
> > > decimal places (rounded off).
> > > 
> > > //P_InLineEquity
> > > //code to reverse engineer the trade series from the equity 
curve
> > > //it is reversed at the end to check the accuracy of the method
> > > 
> > > InitialEq = 10000;//input required
> > > 
> > > SetOption("InitialEquity", InitialEq ); 
> > > 
> > > Buy = BarIndex() > 4 AND DayOfWeek() == 2;//use your own
> > > Sell = BarIndex() > 4 AND DayOfWeek() == 4;//use your own
> > > 
> > > BuyPrice = C;//use your own
> > > SellPrice = C;//use your own
> > > 
> > > Plot(Equity(),"Equity",5,1);
> > > 
> > > Entry = IIf(Equity() == Ref(Equity(),-1) AND Equity() != Ref
> (Equity
> > > (),1),1,0);
> > > 
> > > //Plot(Entry,"Entry",1,1);
> > > 
> > > Exit = IIf(Equity() != Ref(Equity(),-1) AND Equity() == Ref
(Equity
> > > (),1),1,0);
> > > 
> > > //Plot(Exit,"Exit",2,1);
> > > 
> > > TradeSeries = IIf(Exit ==1,ValueWhen(Exit == 1, 
> > SellPrice,1)/ValueWhen
> > > (Entry == 1, BuyPrice,1),1);
> > > 
> > > //Plot(TradeSeries,"TradeSeries",1,1);
> > > 
> > > GF = 1;//GrowthFactor
> > > 
> > > for (i = 1; i < BarCount; i++)
> > > {
> > > GF[i] = GF[i-1] * TradeSeries[i];
> > > }
> > > 
> > > //codesters might be able to make the above loop 
better/prettier?
> > > //Plot(GF,"GrowthFactor",5,1);
> > > 
> > > 
> > > Plot(InitialEq * GF,"CalculatedEquity",1,1);
> > >
> > 
> >  
> > 
> > 
> >   _____  
> > 
> > I am using the free version of SPAMfighter for private users.
> > It has removed 516 spam emails to date.
> > Paying users do not have this message in their emails.
> > Try SPAMfighter <http://www.spamfighter.com/len>  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/