.
.
ATTENTION: THIS THREAD IS OUTDATED
Please go to http://datfra-expert-advisor.com/ in order to find the final result of all the research!
Hello
In this thread I will explain how you can transform any indicator into an Expert Advisor, in order to backtest it and find the very best parameters.
This can be done by any trader, you do not need any coding skills for this. The transformation will be done by my tool DATFRA, with only 2 clicks.
Then we have to add 2 or 3 lines of code, which is very very simple, and will be explained in here.
=> thats it!
"tl;dr. Video?" -> I might make one in the next days and update this post
NOTE:
This thread is the first of 3, in the next one I will explain how to find the best signal-filters for an indicator (for example, RSI thresholds, Moving Average Trends etc...). Again, done by an algorithm and without human interaction.
The last article will then be about how to use massive simulations to find the parameters that work best for an indicator.
So yes, you did read right, I will show you a 3-step way how to let your computer determine the best way to trade an indicator
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
STEP 1: Download DATFRA (its free)
Please go to my original Thread ( http://www.forexfactory.com/showthread.php?p=7595120 ) and download the tool.
Note: Unlike the other 2 steps, for this one you do not have to install it. So, you can just download the .rar, extract it somewhere and then go to the "bin" directory and start DATFRA_FREE.exe
After the first start, it downloads all mql files that the generated EA needs to compile without errors!
You find them in DATFRA\ROOT_DIRECTORY\MQL4\Include (I am not at home right now, so cant check the path, but it should be somewhere in here, seek for "datfra-utils.mqh", its all in the same directory)
Just copy the contents of that folder to your Metatrader Installation!
Note2: You will need to install gnuplot first, otherwise DATFRA will not start up (only use this version!): http://sourceforge.net/projects/gnup...p.exe/download
If the problem does not go away after installing gnuplot, see this post: http://www.forexfactory.com/showthre...05#post7634505
STEP 2: Transform Indicator => Expert Advisor
Now that you have started my tool, it will first download all needed mql files. So click "Yes" when it asks to update files.. And then, just 3 more clicks!
NOTE: This works for ALL Indicators, not just the standardt ones!
http://s7.directupload.net/images/140715/jfd74u22.png
- Click on "System -> Create EA from Indicator"
- Click on "..." and open the Indicator you want to transform
- Click on "Create Expert Advisor" and choose where to save it
THATS IT!
STEP 3: Open the just created Expert Advisor's Code
Ok, now we will add a bit of code, but it will be easy as hell, promised! However, if you have problems, add me on Skype (Darwin-FX), and if you are lucky I have some minutes to help.
First, open the just saved EA file with your Metaeditor (Open Metatrader and press F4). You will see something like this:
http://s7.directupload.net/images/140715/ko7tl9rg.png
STEP 4: Tell the EA how to use the Indicator
So, what do we have to do? The variable "indic" holds the value of the Indicator, and we have to set the variable "signal" to BUY/NEUTRAL/SELL accordingly.
Note about how the indicator is used:
The indicator code "get_MACD" is followed by 0, 1 and then by the Indicator's parameters.
The first number (0) is used to determine which output of the indicator we want to read.
You know, some indicators paint more then 1 line (for example, MACD draws a historgram and a signal line). DATFRA generates a small writeup for this, which you can see in line 39 and 40 of the code-image I posted above. So, we access the historgram-value with a mode of 0, and the signal-line-value with a mode of 1.
The second number (1) is used to determine how many candles in the past we want to look.
As these EAs are meant to trade on bar opening only, the current bar is always empty (because it has just opened), so we want to look 1 in the past
This step depends on how an indicator is used, in this example we want to go long whenever the MACD historgram is above zero, and short when its below.
And well, that is as simple as this
if(indic > 0) signal = +1; // LONG if MACD > 0 if(indic < 0) signal = -1; // SHORT if MACD < 0
Yep, that was all the coding you need. Simple, hm?. So, just put that into the EA, and the finished file should look like this: http://pastebin.com/vgWN6zP2
Now just press F7 to make an EA out of the code.
STEP 5: Backtest it!
In Metatrader4, press Ctrl + R to open the backtester. Then select the EA and all the other settings just like I did:
http://s1.directupload.net/images/140715/i4zjuunm.png
Then just hit start and watch:
http://s14.directupload.net/images/140715/n4nukz2w.png
Note: If you want to change the Indicator's parameters, you can click on "Expert Properties" and go to the "Input" tab!
Afterword:
To make the "coding" part a bit more clear, I will try and post a new example every one or two days, however, I can not promise anything, as I am quite busy
-Darwin