MQL4 – Advanced ICCI Entry

MQL4 – Advanced ICCI Entry

Released Friday, 3rd August 2018
Good episode? Give it some love!
MQL4 – Advanced ICCI Entry

MQL4 – Advanced ICCI Entry

MQL4 – Advanced ICCI Entry

MQL4 – Advanced ICCI Entry

Friday, 3rd August 2018
Good episode? Give it some love!
Rate Episode
List

[This post contains video, click to play]
image

In the new video today we shall code an entry module (CheckEntry) with the Indicator called: Commodity Channel Index (CCI). This is an oscillator type Indicator.
See the green line here? Whenever its crosses the dotted lines above or below it generates a signal.
The sell signal is when the green line goes above the upper dotted line (overbought) therefore our expectation is that price will dive.
We receive a buy signal when the green line goes below the lower dotted line (oversold) so price is about to rise.
Alright, let’s see how to code an entry module (CheckEntry) for the Expert Advisor which shall receive buy and sell signals from the Commodity Channel Index and open a trade by using a main module for trade management like my Forex Trading Framework!
To begin – as always – please start your Metaeditor from Metatrader by using the shortcut F4 or click the button here. In the Metaeditor click on: “File/ New/ Expert Advisor (template)” from template, click “Next”,” Next” again then “Finish”.
Let’s remove all the things above the “OnTick” function even the comment lines.
Instead of using the “void OnTick” function we shall use a string function called: “CheckEntry”.
So inside the “CheckEntry” function we place a string for the signal and name it “signal” so we can easily read our code. We leave it empty without any value because we haven’t calculated yet. That shall be done in the next step here; for that we call the function: “iCCI” which is in-built in MQL4. The function needs a few parameters, such as the symbol of the current chart as the first and the second and the last are shift values.
You would use the shift if you wanted the drawing of the Indicator to be moved to the right or the left.
We do the calculation with the default values; that is 14 candles applied to the typical price. You can take a look at the default settings by clicking on: “Insert/ Indicators/ Oscillators/ Commodity Channel Index“
We are going to buy when the Indicator’s value goes above 100 – so the green line here crosses the dotted line – let’s pause the Indicator please, then click and open “properties”, here open the “levels” tab. Now you see here that the upper dotted line is sat to plus 100 and the lower dotted line is sat to minus 100 (-100).
In the code we say: if the ICCI value (ICCIValue) is greater than 100 we have an overbought condition therefore it is a sell signal and we set the “signal” to sell by rendering the word: “sell” to it. We get a buy signal when the opposite happens, so that the ICCI value (ICCIValue) is smaller than minus 100 and then we have an oversold condition therefore we render the word: “buy” to our signal. After this the final step is to return the signal to our main module.
The main module contains several functions which are opening, managing and closing a trade.
My main module is the Forex Trading Framework but you can code your own main module. You can also download a demo version of mine from my website which can trade your entry module by using the include function. You can just import this currently coded file for the Commodity Channel Index also and it will trade it. It is able to trade with most of the entries. Now please save the entry module (CheckEntry) then compile the code.
If we have no errors or warnings we can return to Metatrader, please use the F4 shortcut or click the button.

In the Metatrader we want to run a back-test and when we turn on the visual mode we want to see our Expert Advisor trading with the Commodity Channel Index the same way we would see if trading manually. To do that we will tweak the “tester.tpl” template file.
So please click on “Insert/ Indicators/ Oscillators/ Commodity Channel Index“, let’s use the standard Indicator settings, click on “OK”, now we see the Indicator on our chart, do a right-click in the chart and here click on “Template/ Save Template” and save it as: “tester.tpl”. Now the Metatrader will use this template when running the back-test.
Okay, now we can start the Strategy Tester (by clicking on “View/ Strategy Tester” or using “CTRL + R”), set your main module (I am using my own framework the Forex Trading Framework) and start the test. Don’t forget to enable the visual mode!
Here we go and our Expert Advisor is running, it has already opened a few positions and made some profit too.
So now you finished the code for an Expert Advisor entry module (CheckEntry) in MQL4 which is using the Commodity Channel Index Oscillator and you did it by yourself with only a few lines of code.

Download “MQL4 - Advanced ICCI Entry” AdvancedICCI.txt – Downloaded 0 times – 451 B

ROBOT TRADING SYSTEM CONTENT

image
Show More