How to add a second indicator
Step 1: Load the Indicator in DATFRA's Indi->EA Wizard
First, load the Indicator (as seen in my first post as seen in "STEP 2: Transform Indicator => Expert Advisor"). In this example, I use the RSI
Only load it, dont press "Create Expert Advisor".
Then go to the "Internals" Tab, where you can see the MQL Code for calling this EA (lower half of the image)
http://s1.directupload.net/images/140804/xerqovtc.png
Step 2: Paste the code into the Expert Advisor
For this example, lets re-use our initial EA, as its the most simple one (can be found here: http://pastebin.com/vgWN6zP2 , it's the one from the first post).
Now just paste the code from Step 1 into that EA's source. Afterwards, we can query the value of the RSI Indicator
http://s7.directupload.net/images/140804/gbgzkeg6.png
Step 3: Add an input variable for the new indicator
As we want to backtest the Indicator Setups with different Parameters, we need to add an input variable for the RSI Period, so we can later change it from within the backtester, to try different values.
So, we add an external variable to our EA:
http://s14.directupload.net/images/140804/orwb275a.png
Step 4: Add the RSI Filter to the EA's entry logic
Now, we want to use the RSI in the EA's trading decisions. In this example, we only want to enter LONG trades when the RSI is oversold (< 30) and enter SHORT trades when the RSI is overbought (>70).
For this, we first call the indicator and save it's value, and then we add a new IF filter:
http://s7.directupload.net/images/140804/2cnnc63x.png
Step 5: Done, backtest it!
NOTE: This is just an example, it is no valid trading strategy to combine a MACD-Histogram and an RSI in this way. If you backtest the EA, you see that it only trades very very rarely!!
Here is the full source of that example EA: http://pastebin.com/cHk9h6Cn
http://s1.directupload.net/images/140804/itxtoopt.png
-Darwin
Step 1: Load the Indicator in DATFRA's Indi->EA Wizard
First, load the Indicator (as seen in my first post as seen in "STEP 2: Transform Indicator => Expert Advisor"). In this example, I use the RSI
Only load it, dont press "Create Expert Advisor".
Then go to the "Internals" Tab, where you can see the MQL Code for calling this EA (lower half of the image)
http://s1.directupload.net/images/140804/xerqovtc.png
Step 2: Paste the code into the Expert Advisor
For this example, lets re-use our initial EA, as its the most simple one (can be found here: http://pastebin.com/vgWN6zP2 , it's the one from the first post).
Now just paste the code from Step 1 into that EA's source. Afterwards, we can query the value of the RSI Indicator
http://s7.directupload.net/images/140804/gbgzkeg6.png
Step 3: Add an input variable for the new indicator
As we want to backtest the Indicator Setups with different Parameters, we need to add an input variable for the RSI Period, so we can later change it from within the backtester, to try different values.
So, we add an external variable to our EA:
http://s14.directupload.net/images/140804/orwb275a.png
Step 4: Add the RSI Filter to the EA's entry logic
Now, we want to use the RSI in the EA's trading decisions. In this example, we only want to enter LONG trades when the RSI is oversold (< 30) and enter SHORT trades when the RSI is overbought (>70).
For this, we first call the indicator and save it's value, and then we add a new IF filter:
http://s7.directupload.net/images/140804/2cnnc63x.png
Step 5: Done, backtest it!
NOTE: This is just an example, it is no valid trading strategy to combine a MACD-Histogram and an RSI in this way. If you backtest the EA, you see that it only trades very very rarely!!
Here is the full source of that example EA: http://pastebin.com/cHk9h6Cn
http://s1.directupload.net/images/140804/itxtoopt.png
-Darwin