Backtest automation

General discussion about the Tickstory Lite software package.
Post Reply
bmigette
Posts: 6
Joined: Mon Oct 13, 2014 9:26 pm

Backtest automation

Post by bmigette »

Hi all,
First, thank you very much for making tickstory free :)

I have made some scripts to automate backtesting, and this might be useful to other, so pasting it there:

Following my Topic on how to "bruteforce blessing" http://www.jtatoday.info/forum/showthread.php?tid=16052, I have found a way to automate 99% BT with tickstory.
The idea is basically to use startup config to MT4 with a VBS Script that automates the function.
So what you need to do:
1- Copy the runBTs.vbs to a folder
2- Change your TickStory lite settings to pass as parameter the path to the generated ini file (by default it will be params.ini, you can edit the vbs paraminiFile="params.ini" 'Set this in TickStory
Image
3- Adjust all other variables such as your MT4 Data folder. Note that the script use basically timers to detect when MT4 is opened and closed. While the default values should be fine for most people (20 attempts with 2seconds pause), if you have a slow PC you might increase. You will also need to setup the Pair, EA Name, and test date range.
4- Run the script as administrator. It is not mandatory, but since we will write setfiles in MT4 data folder, that will avoid any file permission issues.

The script will now start a backtest for all .set files in the directory passed in argument. The search is recursive, meaning set files in subfolders will be backtested too.

At the end of the process, the statement is copied to the original folder. Here is an example of what it looks like

Code: Select all

C:\Users\backtest7\Google Drive\Forex\Backtests-Blessing3\OptResults>cscript runBTs.vbs GBPCHF\h1
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.

10/13/2014 11:07:22 PM - Starting BT for 'C:\Users\backtest7\Google Drive\Forex\Backtests-Blessing3\OptResults\GBPCHF\h1\GBPCHF_h1-1.set
10/13/2014 11:07:22 PM - report File willl be C:\Users\backtest7\AppData\Roaming\MetaQuotes\Terminal\9ACB2E2CE0389240C909714389C79575\GBPCHF_h1-1.htm
10/13/2014 11:07:22 PM - Copying setfile to tester dir
10/13/2014 11:07:23 PM - Closing MT4 and Waiting
10/13/2014 11:07:23 PM - Stop attempt: 1
10/13/2014 11:07:25 PM - MT4 Closed
10/13/2014 11:07:25 PM - Activating Tickstory and starting MT4
10/13/2014 11:07:25 PM - Start attempt: 1
10/13/2014 11:07:27 PM - Started
10/13/2014 11:07:27 PM - Entering file exist loop
10/13/2014 11:18:27 PM - BT Complete ... Moving the files:
10/13/2014 11:18:27 PM - C:\Users\backtest7\AppData\Roaming\MetaQuotes\Terminal\9ACB2E2CE0389240C909714389C79575\GBPCHF_h1-1.htm -> C:\Users\backtest7\Google Drive\Forex\Backtests-Blessing3\OptResults\GBPCHF\h1\GBPCHF_h1-1.htm
10/13/2014 11:18:27 PM - C:\Users\backtest7\AppData\Roaming\MetaQuotes\Terminal\9ACB2E2CE0389240C909714389C79575\GBPCHF_h1-1.gif -> C:\Users\backtest7\Google Drive\Forex\Backtests-Blessing3\OptResults\GBPCHF\h1\GBPCHF_h1-1.gif
10/13/2014 11:18:27 PM - Starting BT for 'C:\Users\backtest7\Google Drive\Forex\Backtests-Blessing3\OptResults\GBPCHF\h1\1002\1002.set
10/13/2014 11:18:27 PM - report File willl be C:\Users\backtest7\AppData\Roaming\MetaQuotes\Terminal\9ACB2E2CE0389240C909714389C79575\1002.htm
10/13/2014 11:18:27 PM - Copying setfile to tester dir
10/13/2014 11:18:27 PM - Closing MT4 and Waiting
10/13/2014 11:18:27 PM - Stop attempt: 1
In addition to that, I have made 2 other scripts:
makeSet.vbs
This one is used to generate a setfile from optimization report. It will basically merge optimization result and what I called the base set file, that is, the file you should save when you have defined all your optimization parameters.
This script will merge the Optimization generated parameters to the base file, and will rebuild the arrays ("SetCountArray", "GridSetArray", "TP_SetArray")

For this to work, just right click your optimisation result, and click copy. Then put one parameter per line and remove the begining.
For example:
952 35428.12 1759 1.65 20.14 37183.57 50.51% 0.00000000 BollingerEntry=2 LAF=3 EntryDelay=200
should become
BollingerEntry=2
LAF=3
EntryDelay=200
There is an example set file included in the zip.

makeSets.vbs
This script will basically take as input the full optimization data and call the previous script. It is therefore mandatory to have both of them in the same directory.
The input file is just copy / paste to a text file of Optimization:
Image
see example file in the zip: results.txt

Note: All scripts are provided as-is and might work or not in your environment.
I am running this on Win7 x64 pro
Attachments
HowToBTAutomation.zip
(70.76 KiB) Downloaded 618 times

tickstory
Posts: 4899
Joined: Sun Jan 06, 2013 12:27 am

Re: Backtest automation

Post by tickstory »

Hi Bmigette - Welcome to the forum and thanks for your valuable contribution to assist other Tickstory users!

Kind regards.

Post Reply