[amibroker] Re: Backtest - reference account balance to workout lots size

2010-07-14 Thread rise_t575
Mike (and anyone who can help here), As always - many thanks for your reply! No - "Use previous bar equity for position sizing" is not activated. Following are the very first 3 days of the backtest - starting with the initial equity of 100,000 so one can see how "equity" develops. I've found

[amibroker] Re: Backtest - reference account balance to workout lots size

2010-07-14 Thread Mike
Rise, It's been a while since I last delved down to that level of detail. So take this with a grain of salt. There are a couple of things that can be at play here. Fist is whether or not you have opted to use the previous bar's equity for position sizing (AA Settings option or SetOption). Sec

[amibroker] Re: Backtest - reference account balance to workout lots size

2010-07-14 Thread rise_t575
Mike, I've used your ps formula & switched to "Detailed Log" in the BT settings. I've chosen a trade somewhere in the middle of the backtest, so that current equity is not identical to the initial equity. I'm getting the following info: Trade Date: 2004-07-27 Enter Long, T, Price: 25.34, S

[amibroker] Re: Backtest - reference account balance to workout lots size

2010-07-14 Thread rise_t575
Mike, 1. No, I'm not using ApplyStops. Most simple system imaginable for testing purposes (i. e. long-only MA crossover). 2. Doesn't make a difference. 3. Thanks! Have to find out where exactly to add custom metrics code into my mid-level CBT code. The custom metrics examples I am aware o

[amibroker] Re: Backtest - reference account balance to workout lots size

2010-07-13 Thread Mike
1. Are you using ApplyStops? One of the arguments controls when resulting funds become available for any entries that occur on the same bar as the stop. That might be affecting things. 2. Try adding SetBarsRequired( sbrAll, sbrAll ); to the top of your code and see if that makes a difference.

[amibroker] Re: Backtest - reference account balance to workout lots size

2010-07-13 Thread rise_t575
Hi Mike, Your math is obviously correct. Nonetheless, I've found a small mistake in your SetPositionSize formula; the SetPositionSize function expects the percentage value (e. g. for 50%) in the format "50", whereas the formula you've described ("P") has a result with the format "0.50"

[amibroker] Re: Backtest - reference account balance to workout lots size

2010-07-12 Thread Mike
No offence taken. Check my math since I've written this out quickly. But... You have said: a) TotalPos = psUnits * Price You have also said: b) psUnits = currEquity * [(pctVolaRisk / 100) / (ATR * PointVal)] Substituting b into a you get: c) TotalPos = {currEquity * [(pctVolaRisk / 100) / (ATR

[amibroker] Re: Backtest - reference account balance to workout lots size

2010-07-12 Thread rise_t575
Mike, Thanks for your reply (I hope I did not say anything upsetting you, as this definitely wasn't my intention - how could I - you've helped me many times here on the forum). The result of formula (1) is in units, the result of formula (2) is a percentage of equity. Thus, in formula

[amibroker] Re: Backtest - reference account balance to workout lots size

2010-07-12 Thread Mike
Hi, Your examples are not valid. In the first you did an additional multiplication by 100, the second you did not. Adjusting your second example to match the first you get: 2.) Suggested non-CBT solution using spsPercentOfEquity: SetPositionSize(Price * ( pctVolaRisk / 100 ) / ( ATR(period) *

[amibroker] Re: Backtest - reference account balance to workout lots size

2010-07-12 Thread rise_t575
Taking another look at the results, I've just noticed that Mike's formula would "theoretically" work in this special case, if you alter it to SetPositionSize( pctVolaRisk / ( ATR(period) * pointVal ), spsPercentOfEquity); I say theoretically, as there seems to be another problem; when coding i

[amibroker] Re: Backtest - reference account balance to workout lots size

2010-07-12 Thread rise_t575
I've forgot to mention: In the AB manual, Percent Volatility PS is implemented in the following way (which is incorrect as well): "For the end, here is an example of Tharp's ATR-based position sizing technique coded in AFL: TrailStopAmount = 2 * ATR( 20 ); Capital = 10; /* IMPORTANT: Set

[amibroker] Re: Backtest - reference account balance to workout lots size

2010-07-12 Thread rise_t575
Mike, Tomasz, anyone: Many thanks for your reply, Mike (as well as for all the other problems you have helped me with in the past) - but unfortunatley, I don't think it will work that way. While I am relatively new to AmiBroker, I believe that I know a thing or two about proper position sizi

[amibroker] Re: Backtest - reference account balance to workout lots size

2010-07-10 Thread Mike
I believe that you will get what you want simply by using a dynamic value passed to SetPositionSize, expressed as a percentage of equity. AmiBroker will use the current value of equity, on a bar by bar basis, when resolving the calculation. The situations that require CBT are when you need to k

[amibroker] Re: Backtest - reference account balance to workout lots size

2010-07-10 Thread rise_t575
Mike, Just out of interest (as I've already solved this using CBT): Is it possible to code the following exact position sizing formula without using CBT? I think not, as one needs the updated current equity during the backtest (as with all PS models): psUnits = int( currEquity * ( pctVolaR

[amibroker] Re: Backtest - reference account balance to workout lots size

2010-07-10 Thread rise_t575
Made a small change to the code; now the URL has changed: http://www.amibroker.com/members/library/detail.php?id=1307 --- In amibroker@yahoogroups.com, "rise_t575" wrote: > > > > The Percent Volatility Money Manager is online now at AB's AFL Libary: > > http://www.amibroker.com/members/libr

[amibroker] Re: Backtest - reference account balance to workout lots size

2010-07-09 Thread Mike
SetPositionSize((Risk * 0.01) / (ContractSize * ATR()), spsPercentOfEquity); Mike --- In amibroker@yahoogroups.com, "pcmoxon" wrote: > > Hi, > > I am trying to write some AFL so I can backtest various trading systems for > forex. > > One part of the system is to workout how much equity to use

[amibroker] Re: Backtest - reference account balance to workout lots size

2010-07-09 Thread pcmoxon
Thanks Rise-T, very much appreciated. Pete --- In amibroker@yahoogroups.com, "rise_t575" wrote: > > > > The Percent Volatility Money Manager is online now at AB's AFL Libary: > > http://www.amibroker.com/members/library/detail.php?id=1306 > > --- In amibroker@yahoogroups.com, "rise_t575" wr

[amibroker] Re: Backtest - reference account balance to workout lots size

2010-07-09 Thread rise_t575
The Percent Volatility Money Manager is online now at AB's AFL Libary: http://www.amibroker.com/members/library/detail.php?id=1306 --- In amibroker@yahoogroups.com, "rise_t575" wrote: > > > > > > > I've coded exactly what I think that you want one week ago or so as a nice > universal out

[amibroker] Re: Backtest - reference account balance to workout lots size

2010-07-09 Thread rise_t575
I've coded exactly what I think that you want one week ago or so as a nice universal out-of-the-box procedure which is very easy to include into any system. I'll put it into AB's AFL library after I'm done trading today. One has to use the Custom Backtester (at least that's how I've done it)

[amibroker] Re: Backtest - reference account balance to workout lots size

2010-07-09 Thread pcmoxon
I am trying to implement a volatility based position size. The system I am working on is based on a 60min timeframe. I read the ATR of the daily timeframe then use that in the calculation to determine the lots size to trade. 'Risk' is a user input variable representing a percentage. Pete --- I

[amibroker] Re: Backtest - reference account balance to workout lots size

2010-07-09 Thread rise_t575
Just curious, What are you trying to achieve here? Standard Percent Volatility PS? Why do you multiply risk (how do you define risk) with 1%? --- In amibroker@yahoogroups.com, "pcmoxon" wrote: > > Hi, > > I am trying to write some AFL so I can backtest various trading systems for > forex. >