Margin too high??

Posted By: boatman

Margin too high?? - 10/16/14 14:05

I have been testing a strategy that gives decent results in backtest with WFO. I'm confident that it is not curve-fitted as my trade-to-parameter ratio is high and parameters are robust across a range of values. In my backtest, my maximum drawdown is about 15%.

I'm trading it on a demo account, and to me the strategy seems to be taking positions out of proportion to the account size. The account balance is $10k and the strategy is risking almost 10% of this on some trades. For others, it risks as little as 1.5%. The strategy's win ratio is less than 50%, so risking as much as 10% per trade would surely not give a maximum drawdown of only 15%!

I'm actually using a fraction of optimal F, and reinvesting as per the square root rule. I've also tried setting the Risk parameter to a small percentage of the balance to limit the position sizes, but this only has a small effect on the backtest results - I would expect something more significant.

My questions:

1. jcl, could there be another bug in the MT4 bridge that causes excessive position sizing, like the bug that didn't honour the exitLong() and exitShort() functions?

2. Do these trade sizes seem excessive to anyone else? Should I just trust the optimal F factors? Anyone run across anything similar?
Posted By: ibra

Re: Margin too high?? - 10/16/14 14:49

Hi!

What is the "trade-to-parameter ratio and where can I read about it?

Thanks!
Posted By: boatman

Re: Margin too high?? - 10/17/14 01:45

"Trade-to-parameter ratio" simply refers to the number of trades in the simulation per parameter that is optimized, per asset used in the strategy. Having too few trades per optimized parameter in the backtest can lead to results that are not statistically robust.

The "Train mode" page in the manual (search "optimization") suggests 20 trades per parameter per asset as a rule of thumb. Ehlers suggests a minimum of 30 in his most recent book.

I'm sure that a google search on optimization/curve fitting would reveal more.

Hope that helps.
Posted By: boatman

Re: Margin too high?? - 10/17/14 01:48

As an update, I've done some calculations, and it turns out that my position sizing is out by a factor of 10 in live trading. I assume that this is related to a conversion error of the "Lot" parameter in the Assets.dta file between Zorro and MT4 via the bridge. As a work around, I will apply a factor of 0.1 to my margin calculation.

I found that this error occurs on my ThinkForex account, but not on my Global Prime account.
Posted By: Thirstywolf

Re: Margin too high?? - 10/17/14 03:10

Boatman

Is the leverage on both accounts the same?
Posted By: boatman

Re: Margin too high?? - 10/17/14 06:21

Hi Thirstywolf, no the leverages are different. How would that affect things? Shouldn't Zorro detect the account's leverage when it connects to the broker?
Posted By: 3DCat

Re: Margin too high?? - 10/17/14 14:39

can you check if its with certain assets only? I got the same problem but only with USOil and via the FXCM API
Posted By: Thirstywolf

Re: Margin too high?? - 10/17/14 16:08

Boatman,

I would assume so. Just trying to think of what other potential differences between the two accounts that would lead to an error in margin size, other than lots. However lots does seem most likely, given it is a multiple of 10 difference.
Posted By: jcl

Re: Margin too high?? - 10/20/14 17:34

Check the assets.dta from both accounts, and compare with the values published by your broker. Wrong parameters, such as a wrong minimum margin or a wrong lot size, can cause a wrong margin, but those wrong parameters are then visible in assets.dta.
Posted By: boatman

Re: Margin too high?? - 10/21/14 02:04

Thanks everyone for the suggestions.

I've found that the problem lay not with the account leverage, but with the OptimalF values assigned to the various assets during training. I made the mistake of training the strategy with capital reinvestment enabled, and this gave OptimalF values that were far to high (approximately one order of magnitude greater in most cases). When I trained the strategy with no re-investment, I got more sensible OptimalF values.

I get a sense of why this is the case, but if someone can offer a succinct explanation I'd be most appreciative!

This leads me to another potential problem:

If I have a strategy that I am trading, but want to re-train at regular intervals, how could I exclude capital reinvestment from the re-training process so as not to distort the OptimalF values? I'm thinking something like

if (not(Retrain))
Margin = OptF * Capital * sqrt(1 + ProfitClosed/Capital);

Sound correct?
Posted By: jcl

Re: Margin too high?? - 10/21/14 07:29

If (!Train) would be better. OptF has no effect on training, though, so it's normally not necessary to disable reinvestment in the training phase.

But the problem is: You're training for the account in AssetsFix.dta. This is normally a FXCM micro account. In your case, when you use the same OptF parameters for both accounts, you're also getting the same margin, but this means a ten times higher lot size on one of the accounts. For preventing this, either use your 0.1 factor for one of the accounts, or generate the OptF parameters for both accounts separately.
Posted By: boatman

Re: Margin too high?? - 10/22/14 08:25

Thanks jcl, you were spot on. When I gave the strategy a correct Assets file for that account, I got the expected OptF values.

Much appreciated!
© 2024 lite-C Forums