In this video we are going to trade the Accelerator Indicator, that’s the indicator here, it’s an oscillator; it produces green and red bars that are formed above or below this zero line.
Whenever the bars are below the zero line it creates a buy signal and when the bars are above the zero line that’s a sell signal.
Now how can we create an Expert Advisor that is able to trade the Accelerator Indicator signal?
Well, to do that please click on the little button here or press F4 in your Metatrader and now you should see the Metaeditor window and here you want to click on “File/ New/ Expert Advisor (template)” from template, click on “Continue”; I will call this one: “CheckEntry_IAC” as this is what I’m calling from my main module. Click on “Continue”, “Continue” and “Finish” and now you can delete everything above the “OnTick” function and the two comment lines, and now we change the “OnTick” function that will from now on be a string function because it returns a string value.
It will be called Check Entry (CheckEntry) because that’s what I’m calling from my main module to get the entry signal.
Right now I’m using the Forex Trading Framework from February 2018, this is still the German beta version, and it’s a collection of several functions that are able to open and manage trades.
If you don’t know what a Forex Trading Framework is or how you can build your own version just go to (
Right now you can download a version for MQL5 and the MQL4 version will soon follow.
But back to topic we need to create an empty string for the signal that will also be called “signal” and we don’t assign any value here because we are going to calculate that later on.
Let’s actually calculate the “iACValue” for the current candle; that is done by using the “iAC” function, it has three parameters in MQL4; the first one is for the current symbol on the chart, the second one is for the time frame, and the third parameter is for the shift. We use _Symbol, _Period and we use a zero because we don’t want to shift our indicator and if the indicator has a value that is above the zero line – that would be the case when the bars are formed above this line here – we would consider that to be a sell signal and assign the word “sell” to our signal. In the other case if the value is below the zero line – so if “iACValue” is less than zero – we would assign the word “buy” to our signal.
In the last step we return the signal to our main module by using the “return” function for the signal because this is the entry module and we are going to trade with the Forex Trading Framework, we just need to save the file for the entry and import the new “CheckEntry_IAC” module in the framework.
Compile it, and that worked without any errors so now we can click on a little button here or press F4 to go back to Metatrader.
In Metatrader we are going to use a little trick; let’s click on “Insert/ Indicators/ Bill Williams/ Accelerator Oscillator”, go with the default values, click on “OK” and here you see the indicator.
Now right-click into the main chart, select “Template/ Save Template”, and save the template as “tester.tpl” because this is the template that Metatrader is going to use in the back-test.
Let’s click on “Save” and to bring up the strategy tester click on “View/ Strategy Tester” or press CTRL + R, select your main module – in my case it’s the Forex Trading Framework – pick a currency pair, enable visual mode and click on start.
This is our little Expert Advisor at work, it’s trading the Accelerator Indicator from Bill Williams and you have coded it yourself with a few lines of MQL4 code.