Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, TipmyPip, Edgar_Herrera), 804 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Doubt about Capital and Required Capital, nothing is enough! #453246
07/13/15 18:19
07/13/15 18:19
Joined: Nov 2013
Posts: 123
Mithrandir77 Offline OP
Member
Mithrandir77  Offline OP
Member

Joined: Nov 2013
Posts: 123
I have a doubt about Capital required, in the manual it states in the definition of the Capital variable:

Quote:

Capital
Initial invested capital in units of the account currency (default = 0 = no initial capital). This has no effect on trading, but on calculating the strategy performance in the simulation. Set this to the initial capital when the strategy reinvests profits; make sure that it exceeds the required capital for avoiding negative equity on the account. Zorro then calculates CAGR instead of AR and determines performance parameters from the invested capital instead of the required capital.


I have trouble understanding what it is underlined. For instance, I have a portfolio trained with WFO and I test without reinvestment and I get that the Capital required is 342$ , here are all the stats:
Click to reveal..
Code:
BackTest TradePortofolio1 EUR/USD

Simulated account   AssetsFix.dta 
Bar period          1 hour
Test period         01.05.2009-31.12.2014
Lookback time       2000 bars (17 weeks)
Monte Carlo cycles  200
Assumed slippage    10.0 sec
Spread              0.3 pips (roll -0.12/0.05)
Commission          0.60
Contracts per lot   1000.0

Gross win/loss      5854$ / -3712$ (+24596p)
Average profit      378$/year, 32$/month, 1.45$/day
Max drawdown        -259$ 12% (MAE -423$ 20%)
Total down time     74% (TAE 84%)
Max down time       40 weeks from Jan 2013
Max open margin     154$
Max open risk       475$
Trade volume        938088$ (165522$/year)
Transaction costs   -21$ spr, -3.30$ slp, -28$ rol, -48$ com
Capital required    342$

Number of trades    801 (142/year, 3/week, 1/day)
Percent winning     61%
Max win/loss        89$ / -48$
Avg trade profit    2.67$ 30.7p (+136.6p / -137.9p)
Avg trade slippage  -0.00$ -0.0p (+0.4p / -0.7p)
Avg trade bars      145 (+163 / -115)
Max trade bars      1874 (16 weeks)
Time in market      338%
Max open trades     16
Max loss streak     8 (uncorrelated 7)

Annual return       110%
Profit factor       1.58 (PRR 1.43)
Sharpe ratio        1.09
Kelly criterion     1.07
R2 coefficient      0.747
Ulcer index         7.1%
Prediction error    23%
Cycle performance   1.61 1.58 1.49 1.64 1.56 

Confidence level     AR   DDMax  Capital

 10%                137%   168$  276$
 20%                133%   180$  285$
 30%                129%   190$  293$
 40%                126%   200$  300$
 50%                121%   218$  313$
 60%                117%   234$  324$
 70%                112%   254$  339$
 80%                104%   289$  365$
 90%                 97%   326$  391$
 95%                 91%   362$  418$
100%                 73%   502$  519$




So, ok, I set Capital to 1000 which is more than 342 and I train factors and test with reinvestment and I get that the capital required is 4119, here are the details
Click to reveal..

Code:
BackTest TradePortofolio1 EUR/USD

Simulated account   AssetsFix.dta 
Bar period          1 hour
Test period         01.05.2009-31.12.2014
Lookback time       2000 bars (17 weeks)
Monte Carlo cycles  200
Assumed slippage    10.0 sec
Spread              0.3 pips (roll -0.12/0.05)
Commission          0.60
Contracts per lot   1000.0
Capital invested    1000$

Gross win/loss      166247$ / -116792$ (+24596p)
Average profit      8726$/year, 727$/month, 34$/day
Max drawdown        -4986$ 10% (MAE -9231$ 19%)
Total down time     67% (TAE 95%)
Max down time       25 weeks from Jul 2012
Max open margin     3934$
Max open risk       6831$
Trade volume        36525302$ (6444733$/year)
Transaction costs   -822$ spr, -165$ slp, -675$ rol, -1886$ com
Capital required    4119$

Number of trades    801 (142/year, 3/week, 1/day)
Percent winning     61%
Max win/loss        4708$ / -1474$
Avg trade profit    62$ 30.7p (+168.1p / -188.0p)
Avg trade slippage  -0.21$ -0.1p (+0.6p / -1.2p)
Avg trade bars      145 (+163 / -115)
Max trade bars      1874 (16 weeks)
Time in market      338%
Max open trades     16
Max loss streak     8 (uncorrelated 7)

Annual growth rate  100%
Profit factor       1.42 (PRR 1.29)
Sharpe ratio        1.21
Kelly criterion     0.17
R2 coefficient      0.918
Ulcer index         5.9%
Prediction error    23%
Cycle performance   1.48 1.39 1.29 1.52 1.42 

Confidence level     AR   DDMax  Capital

 10%                164%  1912$  5325$
 20%                159%  2131$  5484$
 30%                157%  2225$  5552$
 40%                153%  2436$  5707$
 50%                150%  2569$  5803$
 60%                148%  2720$  5913$
 70%                144%  2900$  6044$
 80%                141%  3101$  6190$
 90%                135%  3451$  6445$
 95%                130%  3815$  6710$
100%                113%  5253$  7756$




and then if I set Capital to 5000 and test, the capital required increases and so on...

So what is the relationship between Capital and Capital required? In this example, do I need 1000 or 4119 to start running the strategy? I mean, if I try to make sure that the Capital variable is more than the Capital required from the performance report, then when I test it is not enough, how come? Thanks for your help!

Re: Doubt about Capital and Required Capital, nothing is enough! [Re: Mithrandir77] #453247
07/14/15 07:40
07/14/15 07:40
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
When you set the Capital variable to a value x, and then get "Required Capital" > x, increasing Capital won't help of course because the required capital rises linearly with it. The lower limit is the required capital _without reinvestment_. The required capital is calculated from the maximum drawdown, so your capital must be higher when that happens, but not necessarily at the begin. Otherwise limit the reinvestment factor so that you won't get negative equity.

Re: Doubt about Capital and Required Capital, nothing is enough! [Re: jcl] #453256
07/14/15 17:43
07/14/15 17:43
Joined: Nov 2013
Posts: 123
Mithrandir77 Offline OP
Member
Mithrandir77  Offline OP
Member

Joined: Nov 2013
Posts: 123
Originally Posted By: jcl
When you set the Capital variable to a value x, and then get "Required Capital" > x, increasing Capital won't help of course because the required capital rises linearly with it. The lower limit is the required capital _without reinvestment_. The required capital is calculated from the maximum drawdown, so your capital must be higher when that happens, but not necessarily at the begin. Otherwise limit the reinvestment factor so that you won't get negative equity.


OK, when I don't reinvest it is clear, I have to initially invest the capital required to avoid negative equity in case of drawdowns.

The thing is when reinvesting...How can I know the initial capital of the strategy in order to be on the safe side? With your explanation Jcl and rereading the definition of capital required:

Quote:
Required initial capital for trading the strategy. For strategies that reinvest profits (Capital variable nonzero), the displayed value is the minimum initial capital for avoiding a margin call in the test period. Otherwise it's the sum of normalized drawdown and maximum margin. This amount would be required when the strategy is entered at the worst possible moment of the simulation, i.e. directly at the balance peak preceding the largest drawdown.


I guess in my example that if I start the reinvesting strategy with 1000 I have to maintain 3119 in the account for re margin in case of being near a margin call. Is that correct?

Could you share how is it the capital required calculated when reinvesting? Maybe that clarifies more my doubt.

Edit: I am using for setting the margin the formula from the workshop 6: Margin = OptimalF * Capital * sqrt(1 + max(0,WinTotal-LossTotal)/Capital);

Last edited by Mithrandir77; 07/14/15 18:03.
Re: Doubt about Capital and Required Capital, nothing is enough! [Re: Mithrandir77] #453268
07/15/15 14:18
07/15/15 14:18
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
No. Your initial capital is your investment. You can not "calculate" it, it's determined by your wealth, not by your strategy performance. It must be above the required capital without reinvestment, but by how much is up to you.

You must only observe the equity curve and check if it becomes negative. It should not. If it does, you're reinvesting too much. You should then change not your capital, but your reinvestment formula. You're not supposed to maintain money to remargin.

Re: Doubt about Capital and Required Capital, nothing is enough! [Re: Mithrandir77] #453269
07/15/15 14:56
07/15/15 14:56
Joined: Nov 2013
Posts: 123
Mithrandir77 Offline OP
Member
Mithrandir77  Offline OP
Member

Joined: Nov 2013
Posts: 123
OK, so the Capital variable does not influence drawdowns? As long as I apply the square root rule and optimalf for margin allocation and the Capital variable is more than the required capital without reinvestment I am on the safe side (at least in theory)?

Sorry, but if so, I think it contradicts the definition I quoted above of capital required when testing with reinvesting, which is the capital required to avoid a margin call on the test period.
Unless it is that applying the square root rule and optimalf for margin allocation already takes care of avoiding a margin call but then I don't understand why I get that the capital required when investing 1000 is 4119 if I applied optimalf and the square root rule for training factors...i am puzzled.

Re: Doubt about Capital and Required Capital, nothing is enough! [Re: Mithrandir77] #453271
07/15/15 16:19
07/15/15 16:19
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
Maybe you're thinking too complicated? "Required Capital" is just max margin plus max drawdown. A drawdown happens when you lose trades and your equity goes down. How much it goes down depends on the volume of those trades. If your trade volume is higher, you get a bigger drawdown.

So even if you started with only $100 capital, you can get many thousand dollars drawdown after some years when the profit grew on your account and you've increased your trade volume accordingly.

With the square root rule and OptimalF factors you normally won't get negative equity in the simulation period anyway - regardless of your drawdown size.

Re: Doubt about Capital and Required Capital, nothing is enough! [Re: Mithrandir77] #453285
07/16/15 14:19
07/16/15 14:19
Joined: Nov 2013
Posts: 123
Mithrandir77 Offline OP
Member
Mithrandir77  Offline OP
Member

Joined: Nov 2013
Posts: 123
Yes, I am also afraid of overcomplicating things but still, there are things that are not clear and I would like to clarify them because when reinvesting I want to avoid undercapitalization risk. Anyway, I think I am progressing towards understanding finally. Just two more questions and thanks again for your patience!

1) You say "Capital required is just max margin plus max drawdown" but both in the test without reinvesting quoted above:

Max drawdown -259$ 12% (MAE -423$ 20%)
...
Max open margin 154$
...
Capital required 342$

259 + 154 == 413 != 342

And with reinvestment:

Max drawdown -4986$ 10% (MAE -9231$ 19%)
...
Max open margin 3934$
...
Capital required 4119$

4986 + 3934 == 8920 != 4119

Or is it Capital required = max(Open margin + Drawdown) in the simulation period? I am not being picky about numbers here, I want to know where the 4119 comes from since it is 4x the amount I invested.

2) Are MonteCarlo figures valid when reinvesting? These are the ones from my test:

Confidence level AR DDMax Capital

10% 164% 1912$ 5325$
20% 159% 2131$ 5484$
30% 157% 2225$ 5552$
40% 153% 2436$ 5707$
50% 150% 2569$ 5803$
60% 148% 2720$ 5913$
70% 144% 2900$ 6044$
80% 141% 3101$ 6190$
90% 135% 3451$ 6445$
95% 130% 3815$ 6710$
100% 113% 5253$ 7756$

ie, cain I say that when reinvesting with 95% confindence I will have 130% AR, 3815 DDMAX, etc?

PS: Here is the equity curve from the test with 1000 invested and reinvesting, I see no negative equity -blue below zero- so I am more assured from that point.


Re: Doubt about Capital and Required Capital, nothing is enough! [Re: Mithrandir77] #453295
07/17/15 12:54
07/17/15 12:54
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
1) For calculating the required capital, drawdown is normalized to 3 years. Otherwise you would get a different required capital depending on the length of the test period, even with no reinvestment. You can find details on the "Performance" page of the manual.

2) Yes, the figures are still "valid" with reinvesting, but are mostly irrelevant. When the reinvestment changes, all figures depending on it such as max drawdown, annual return, required capital etc. also change. What you see are their temporary, more or less random values at the end of the simulation. That's why the performance of a system with reinvestment is not measured with annual return, but with CAGR, and most of the usual performance figures have not much meaning anymore.

Re: Doubt about Capital and Required Capital, nothing is enough! [Re: Mithrandir77] #453298
07/17/15 15:11
07/17/15 15:11
Joined: Nov 2013
Posts: 123
Mithrandir77 Offline OP
Member
Mithrandir77  Offline OP
Member

Joined: Nov 2013
Posts: 123
Oh, I had forgot about normalized drawdown. Now it is clear! Also taking a closer look at the equity curve I see that the max drawdown is near 5000 so that would be were the 4119 comes from since I have no negative equity.

So looking at the performance without reinvestment

Number of trades 801 (142/year, 3/week, 1/day)
Annual return 110%
Profit factor 1.58 (PRR 1.43)
Sharpe ratio 1.09
Kelly criterion 1.07
R2 coefficient 0.747
Ulcer index 7.1%
Prediction error 23%
Cycle performance 1.61 1.58 1.49 1

And since I have 4 parameters that I optimized, that gives 142 trades per year/ 4 parameters= 35.5 trades per year per parameter which is enough for a statistically significant optimizing (though it is by convention, it comes from the fact that a sample of 20 or 30 is enough to 'build' a normal distribution),
I guess that it's a tradeable stategy, although I would like to raise Sharpe a lil bit maybe to 1. 5

Great as always Jcl, thanks for the patience explaining this topic. Money Management is one of the most difficult ones in trading for me.

Last edited by Mithrandir77; 07/17/15 15:49.

Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1