2013年1月1日

MT4歷史資料的處理方式


我們常會去找正確的tick資料來作回測
找到的資料即是FXT files
但是把這些資料匯入正在使用的MT4平台後,
隨著時間, 新的資料接收下來, 這些原始資料就不乾淨了.
以下找到一個保存原始資料的方法.可以一試

OK, so you may have some tick data in FXT files that you’d like to use for backtesting, but each time you start the test, the files are overwritten.
Here’s a quick workaround. Place the FXT files in your tester/history folder, and rename them all with “x” in the front.

Then add this simple code to your EA before start() function..
#import "kernel32.dll"
 int CopyFileA(string strExistingFile, string strCopyOfFile, int OverwriteIfCopyAlreadyExists);
#import
int init() {
 //## FXT FILE PATCH
 int time=Period();
 string symbol=Symbol();
 string strCurrentFile = TerminalPath() + "\\tester\\history\\x"+symbol+time+"_0.fxt";
 string strNewName = TerminalPath() + "\\tester\\history\\"+symbol+time+"_0.fxt";
 int copy=CopyFileA(strCurrentFile, strNewName, 0);
 Print("FXT file copied");
 return(0);
}
Here’s a screenshot of the correct location for the code:

What is does is after the MT4 generates the new FXT file, it copies your file over the MT4 generated file, and then it will proceed with the testing using your data.
———————

沒有留言:

張貼留言