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

Re: [amibroker] Correct futures - forex backtesting


  • Date: Wed, 03 Feb 2010 11:45:32 +0100
  • From: Tomasz Janeczko <groups@xxxxxxxxxxxxx>
  • Subject: Re: [amibroker] Correct futures - forex backtesting

PureBytes Links

Trading Reference Links



Hello,

Normal lot is $100000. So, with 8 lots (each $100000), real position size is $800000. You should read the documents of your broker
and you will see. In such case, if currency changes as little as 1% down (such fluctuations are happenning on currencies virtually every day!) you are LOSING $8000 on that position. That is where your loses coming from. Your initial equity evaporates that way. When your equity drops below zero you will receive margin call (and you need
to deposit MORE MONEY to your account to keep it alive) or your broker will liquidate your position immediatelly and close your account.
Backtester will not pick up the phone and call you, instead it will show you the same thing using numbers. That is what negative backtest result tells you - how much money you would need to deposit during entire period under test (how far underwater you are and how much more money you would need to have at start not to become bankrupt).  For stocks, it will stop when your account is zero because there is a built-in -99.8% ruin stop for stocks, but for highly-leveraged (1:100 as in your case) undercapitalised accounts it is possible to wipe account and go negative in a matter of seconds (for example when you got 8-lot open position worth nearly $1 million when you got only $10K account) when Fed is announcing rate decision.
Again: that is what backtest results are telling you: you are way way undercapitalised.

Best regards,
Tomasz Janeczko
amibroker.com

On 2010-02-03 06:04, İlhan Ketrez wrote:


Thank you for your prompt replies.
Please find below my answer to both Aron and Tomasz:
 
Negative test results are very late indication of insufficient funds. Falling of the equity level below total maintenance margin means I need to deposit extra money. And this level is far above zero.
 
To inspect this we need to trace these values in backtest. The mistake in current beacktest procedure is:
 
You open a position for example 8 lots with $1000 margin deposit. The real position size is then $8000 and this is constant until you close the position if the position is a winner. The cash amount should change in accodance with price change and pointvalue. If the position is a loser, and if the account is $10000, you first lose the $2000 cash. Then the $8000 position value goes down until it reaches to maintenance deposit. 
To sum up, in the current backtest procedure PositionSize is changing instead of the cash (available funds).
Please check it up.
 
 
Best regards,
Ilhan

 
2010/2/3 Tomasz Janeczko <groups@xxxxxxxxxxxxx>
 

Hello,

In other words negative result tells you how much extra cash you would need to deposit on your account
to keep trading. This is margin call. Either you deposit extra money or you say good bye to your account.



Best regards,
Tomasz Janeczko
amibroker.com

On 2010-02-03 01:22, Tomasz Janeczko wrote:


Hello,

Well, certainly with $10000 account then in fact you should not trade forex at all, because you are undercapitalized and this is straight way to blow you account, at that is precisely what backtest results tell you.

Best regards,
Tomasz Janeczko
amibroker.com

On 2010-02-02 21:07, İlhan Ketrez wrote:
[Attachment(s) from =?UTF-8?Q?=C4=B0lhan_Ketrez?= included below]

Hello,
 
If I have 10,000 and if the initial margin is 1000, can't I open 8 lots? Then what does the initial margin mean?
 
If Amibroker trades far away from margin call everything works perfectly. For example if I have 100,000 and trade one contract, there is no problem. Amibroker takes the position value, multiplies it with the price difference... These are OK. The document you suggest mainly explains these essential details and some basic concepts (http://www.amibroker.com/kb/2006/08/09/amibroker-for-forex/) .
 
In forex & futures, the trick is to be able to trade near limits without getting caught by the limits. And there is nothing in Amibroker about these limits as far as I see. Moreover, it seems that it is impossible to formulate a correct custom backtest procedure due to improper handling of PositionSize and read-only Equity and Cash variables in CBI.
 
I wonder your additional comments on the subject, especially your answer to my first two questions. The final equity becomes -378,320 with 10,000 initial equity with the same settings. Attached you may find the formula file.
 
Best regards,
Ilhan

 
2010/2/2 Tomasz Janeczko <groups@xxxxxxxxxxxxx>
 

Hello,

You are using wrong settings.

> Contract number is 800

That is wrong. No forex broker would allow you to open 800 lots.

You should use SetPositionSize( 1, spsShares ); to ensure you are trading one lot
(or what every lots you really trade).

You need to read this:
http://www.amibroker.com/kb/2006/08/09/amibroker-for-forex/

Best regards,
Tomasz Janeczko
amibroker.com



On 2010-02-02 18:37, İlhan Ketrez wrote:


Hello,

I am a registered user of Amibroker and have sent this problem to Amibroker support before sending to the mailgroup.
By now, more than one week has passed and there is no reply.

I still do not want to believe that Amibroker cannot perform a correct futures/forex bactest and I am afraid of hearing that it can't. However, to me, my tests clearly indicate that there's something wrong with the default behaviour of "futures mode" backtesting. Shortly, you open a position, and as the position be exhausted you still have cash in your account. Even after the position size goes below zero, you still have cash and may open a position if you code accordingly. Ability of the position size to go below zero may just be another discussion topic. There is no such account in real life. Normally, the position size does not change if the position is a winner and if the position is a loser, it consumes the cash first, then consumes itself down to the maintenance margin where the broker liquidates the position.

All in all, my request from Amibroker stuff is to either invalidate my comments by writing a few sentences or clearly accept that Amibroker cannot perform a correct futures backtest and stop misleading people.

Best regards,
Ilhan


2010/1/28 İlhan Ketrez <ketrezilhan@xxxxxxxxx>
 
[Attachment(s) from =?UTF-8?Q?=C4=B0lhan_Ketrez?= included below]

Dear friends

I am trying to test a simple system and understand the behaviour of Amibroker testing mechanism.
I have set up an AFL file very similar to the one described here.

Testing period: 01.01.2008 - today
Initial equity: 1,000,000
Final equity: -38,033,810


The position size is -80.
Margin deposit: 1000.
First entry details are as follows:
Contract number is 800
Entry position size: 800,000. Cash: 200,000.

The details I find interesting are:
As the position grows position size also grows and cash continues as 200,000.
Later, position size goes below zero as cash floats constantly above zero.
The default result in Amibroker is something impossible to encounter in real life. (To go into a debt of 38 million)
I defined a real cash value and observed the difference via debugview.


Report and debugview log are attached including the system codes.

I hope to find a way to test correctly using Amibroker with your help.
Thank you very much in advance.

Regards,
Ilhan Ketrez






Attachment(s) from =?UTF-8?Q?=C4=B0lhan_Ketrez?=

1 of 1 File(s)









__._,_.___


**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/





Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___