Backtesting with tick data - page 3

 

BTW - the script in your attached .rar file. Is that exactly the same as the script you posted (cut and paste) in the forum earlier?

 
mikey:

BTW - the script in your attached .rar file. Is that exactly the same as the script you posted (cut and paste) in the forum earlier?

Yes. The post is a cut and paste from the file...


Regarding this:

One thing tho - not a major drama - but the last line of the output file is thus:

2004.02.23,08:34,,,,,1

The script assumes that at the end of the last line the file will end. In your case the file probably had a newline character at the end of the last line, hence the loop did not detect an 'end of file' and continued to process the last line which was actually empty... Many ways to solve this, for example you can add a condition that variable 'sclose' is not empty before writing:

if (sclose != "")     // make sure close price exists in last line processed
   FileWrite(trg_handle,output);
 

Thanks mate. One quick question re: the swap cost in the strategy tester. Is this added in at the end or is it added in as we go along. I think it may be added in as we go along: Ive noticed that for some trades: for example if the take profit (TP) is at 100 when it closes with a TP then a profit of +100 is not returned but instead a TP of a lower amount eg. +80. Could this be because of swap costs added onto that trade (to account for the days that it has been held overnight - and of course with this method we have more "nights" than we shoudl have). (swap costs wont be too much for my overnite as I am trading with 0.1 lots, but then because of the many night factor it adds up).

It is still running. One thing I would say is that the results are very different from with M1. So, if this is indeed valid - it was certainly worth doing. is giving me much more of an idea.

 
mikey:

Thanks mate. One quick question re: the swap cost in the strategy tester. Is this added in at the end or is it added in as we go along. [...]

It's added exactly as it's added in a Live/Demo account. From 'Testing Features and Limits in MetaTrader 4':

All swaps, margin requirements, expirations, GTC-orders are modeled.

Note that the value of swap is taken from the account you are currently connected to at the moment u press 'Start' in the Tester.

 

A new hurdle. When I load in 3 months worth of tick data into the History centre (treated as we have ironed out in this thread - to make each tick have its own M1 bar) - seemingly everything is ok BUT just seen this in the journal:

Historybase: not enough memory '#CLX01' [8412861 bars]
Memory handler: cannot allocate 370166236 bytes of memory

So, is this to say that it didnt load all the data?

 
mikey:

A new hurdle. When I load in 3 months worth of tick data into the History centre (treated as we have ironed out in this thread - to make each tick have its own M1 bar) - seemingly everything is ok BUT just seen this in the journal:

Historybase: not enough memory '#CLX01' [8412861 bars]
Memory handler: cannot allocate 370166236 bytes of memory

So, is this to say that it didnt load all the data?

It might be because u hit the 2GB limit. After u press 'Start' the tester creates a FXT file that contains ticks for the test (in your case it's 1 tick per bar). This file is created in the folder '\MetaTrader 4\tester\history'. Open this folder and check if the last created file is about ~2GB in size. If so, then u have hit the Tester's limit. There is no solution for this besides testing on shorter periods of time...


I am not sure if this is the reason though, it might be something else...

 

The tester is still running when i checked the size. So, may increase?

But anyway as of now the size is just 412 MB. Which I presume is well under 2 GB?

 

BTW - the journal that this error message is in is NOT in the strategy tester. but in the other one (the one for the account)

 

Im getting somewhat frustrated. Fair enuf - im tyring something new and so there bound to be problems.

But ON UNRELATED TO THIS THREAD - ive just noticed on a bog standard metatrader strategy run with proper M1 data (so not related to what we talkling about in this thread) for 3 months oil data i got. and i noticed that the strategy tester just stopped opening any trades after around 2 weeks. in the code - whenever there is no trade open a new trade should be opened (never had any probs with this in forward testign). But strategy tester is ok for 2 weeks, opening trades and then has no trades opened for like 2.5 months (despite being 5000 dollars in profit)! Also, the kind of results delivered are just so far removed from my forward testing so far. Doubts are beginning to creep into my mind about the engine of the metatatrader strategy tester and its validity and use.

(the data all loaded into tester ok because for its date range on the report - has the correct range)

my dream/aim: What I was hoping was that give the strategy tester good historical data (especially if you can get tick data) and you will get a good insight into how tyour strategy would have really traded over that history (slippage, spread variance etc. accepted). But now im begginnning to dout whether this is attainable. if the strategy engine can actually deliver this. IS THIS AIM ACHIEVABLE WITH METATRADER? Someone throw me some hope!

 
mikey:

BTW - the journal that this error message is in is NOT in the strategy tester. but in the other one (the one for the account)

Well then it probably has nothing to do with the Tester (you can see it's logs in 'MetaTrader 4\tester\logs' folder), but I can't be sure.
Reason: