Console Optimizer

Discussions of tools and methods to backtest and optimize strategies.

Moderator: admin

Console Optimizer

Postby Konstantin.Toporov » Wed Feb 08, 2017 12:16 pm

Let's imagine a situation when there is a trading strategy but we do not have any idea how and when to use it.
Console Optimizer can help to pick up a right instrument and parameters to apply in the future.
So lets run the optimizer on all the instruments available on the account to find the most profitable of them.
We will use a standard strategy DMACD on the data of January 2017.

I made some automation to generate Console Optimizer project files.
Initially I prepared a project template based on the Optimizer documentation.
All the instrument-related data (the instrument itself, account currency, profit currency, contract currency, MMR) I replaced by variables like ${}.
(All the files mentioned here and below are included into file archive attached to this post).

To generate final project files I use Python (you need to have on the computer).
Data for the instruments I picked up from Trading Station by copying Simple Dealing Rates view data into text file.
dealing_rates.png

Then I pasted the data into file names offers.txt. This filed is used by python script offers.py

So the python script generate_opt_projects.py iterates over the offers rows and populates the project template.
Also it generates a command file to run the optimizer with the all generated project files.
(I is assumed you have SDK installed in C:\Gehtsoft\IndicoreSDK3m otherwise you need to change the python file)
The command line is:
python generate_opt_projects.py dmacd_template.xml dmacd

After the script made its job we can go to the target folder and run the command file.
run_opt.bat

It will take a while to optimize the strategy for all the instruments.
The optimizer generates output files for each project containing the information about optimization process and result.
Code: Select all
dmacd_template.xml_AUD_JPY.stat
dmacd_template.xml_AUD_USD.stat
dmacd_template.xml_CAD_JPY.stat
dmacd_template.xml_EUR_CHF.stat
dmacd_template.xml_EUR_GBP.stat
dmacd_template.xml_EUR_JPY.stat
dmacd_template.xml_EUR_NOK.stat
dmacd_template.xml_EUR_USD.stat
dmacd_template.xml_FRA40.stat
dmacd_template.xml_GBP_JPY.stat
dmacd_template.xml_GER30.stat
dmacd_template.xml_NZD_USD.stat
dmacd_template.xml_US30.stat
dmacd_template.xml_USD_CAD.stat
dmacd_template.xml_USD_CHF.stat
dmacd_template.xml_USD_CNH.stat
dmacd_template.xml_USD_JPY.stat
dmacd_template.xml_USOil.stat
dmacd_template.xml_XAU_USD.stat

I made another python script (report.py) to parse the outputs to check out the results quickly:
python report.py dmacd

Code: Select all
51696.0 NZD_USD
51654.1 XAU_USD
51618.5 EUR_GBP
51582.5 AUD_USD
51370.0 USD_CHF
51367.1 EUR_USD
51200.6 USOil
51082.2 USD_JPY
50998.9 EUR_NOK
50943.0 GER30
50904.4 USD_CAD
50890.2 EUR_JPY
50825.4 USD_CNH
50580.3 CAD_JPY
50534.2 GBP_JPY
50430.2 AUD_JPY
50375.0 FRA40
50313.9 US30
50219.2 EUR_CHF


So we can conclude NZD/USD shown the best performance with DMACD during January.
Lets open dmacd_template.xml_NZD_USD.stat to get the details:
Scroll down to find the best pass number:
Code: Select all
  <optimization-result success="true" pass-number="156"/>

Then find this pass in the same file:
Code: Select all
    <pass number="156" success="true" result="51696">
      <optimizable-parameters-values>
        <parameter name="SN" value="5" />
        <parameter name="LN" value="45" />
        <parameter name="IN" value="5" />
        <parameter name="limit" value="20" />
        <parameter name="stop" value="40" />
      </optimizable-parameters-values>
      <statistics>
        <output-parameter name="trade-count" value="12" />
        <output-parameter name="profitable-trades" value="12" />
        <output-parameter name="loss-trades" value="0" />
        <output-parameter name="max-profit" value="259.306" />
        <output-parameter name="min-profit" value="3.16756" />
        <output-parameter name="total-profit" value="1695.95" />
        <output-parameter name="max-loss" value="0" />
        <output-parameter name="min-loss" value="0" />
        <output-parameter name="total-loss" value="0" />
        <output-parameter name="max-equity" value="52062.1" />
        <output-parameter name="min-equity" value="49819.9" />
        <output-parameter name="max-fall-equity" value="984.291" />
        <output-parameter name="final-equity" value="51585.2" />
        <output-parameter name="max-balance" value="51696" />
        <output-parameter name="min-balance" value="50000" />
        <output-parameter name="max-fall-balance" value="0" />
        <output-parameter name="final-balance" value="51696" />
        <output-parameter name="total-amount" value="120000" />
      </statistics>
    </pass>


So this research should give us some trading ideas.

PS. The file archive with the python scripts and the optimizer input and output is attached to this post.
Attachments
console_optimizer_usage.zip
(213.95 KiB) Downloaded 1646 times
Konstantin.Toporov
FXCodeBase: Initiate
 
Posts: 113
Joined: Mon Aug 31, 2015 10:16 am

Return to Backtesting and Optimization

Who is online

Users browsing this forum: No registered users and 2 guests