MQL5 TUTORIAL - SIMPLE IAC EXPERT ADVISOR

Опубликовано: 24 Март 2026
на канале: MQL5 Tutorial
647
16

https://mql5tutorial.com/?s=iac

Video Chapters:

Introduction to Accelerator Oscillator Trading (00:00 - 00:12)

Introduction to trading with the Accelerator Oscillator and its trend indications.
Understanding Long and Short Trends with the Oscillator (00:12 - 00:26)

Explanation of how the Accelerator Oscillator indicates long and short trends.
Creating an Expert Advisor for the iAC Indicator (00:26 - 00:47)

Initial steps to create an Expert Advisor for the iAC MQL5 indicator.
Setting Up the MetaEditor (00:47 - 01:04)

Instructions on opening MetaEditor and setting up a new Expert Advisor.
Initializing the Price Array (01:04 - 01:19)

Creating and defining a price array to hold price values.
Defining Properties of the iAC Expert Advisor (01:19 - 01:40)

Setting up the properties for the iAC function in MQL5.
Sorting and Filling the Price Array (01:40 - 02:06)

Sorting the price array and using CopyBuffer to fill it according to the iAC definition.
Calculating and Getting the iAC Value (02:06 - 02:24)

Calculating the value for the current candle using the price array.
Creating a Chart Output Based on iAC Value (02:24 - 02:47)

Implementing logic to create a chart output depending on the iAC value.
Outputting Long and Short Signals on the Chart (02:47 - 03:31)

Using the comment function to output "iAC is long" or "iAC is short" signals on the chart.
Compiling and Fixing Warnings in the Code (03:31 - 03:59)

Compiling the code and addressing any warnings or errors.
Testing the Expert Advisor in MetaTrader (03:59 - 04:27)

Instructions for testing the newly created Expert Advisor in MetaTrader.
Visual Demonstration of the Expert Advisor (04:27 - 04:27)

Visual demonstration of the Expert Advisor at work in MetaTrader.

In this video we are going to trade the Accelerator Oscillator.
You see that it changes the directions here.
Whenever it produces the bars above the dotted line that would be a signal for a long trend, like here, and when it stays below the dotted line here for a while this could indicate a short trend.
Now how can we create an Expert Advisor that is able to calculate long or short entries here for the iAC MQL5 indicator?
To do that please click the little button here or press F4 on your keyboard and now you should see the Metaeditor window and here you want to click on: “File/New/Expert Advisor” from template (template), Continue (Next).
I will call this version “Simple IAC” (SimpleIAC). Continue, continue and finish.
Now you can remove everything above the “OnTick” function and please also delete the two comment lines here, and to get started we need to create an array that can hold several prices.
Let's call it: “myPriceArray”. It's a double array so it can hold floating-point values.
Now we are going to define the properties of the iAC EA. That's very easy in MQL5 because for the iAC function you only need to pass the current chart and the selected period on the chart as parameters.
Now we are going to sort the price array from the current candle downwards,s that can be done by using “ArraySetAsSeries” for the price array we have created here. And now we use copy buffer to fill our price array according to the iAC definition we have created above.
This zero stands for the first line of the indicator and we need the values from the current candle zero for three candles, that's the three here and the result will be stored in the array.
After we have done that we can actually get the value for the current candle, I will call it: “iACValue”. It contains the price from candle zero in our price array.
Now let's create a chart output depending on the value. Let's say: if the iAC value is bigger than zero – that's the case when it's above the dotted line – and if that is the case we want to use the built-in comment function to output the text: “iAC is long” followed by the calculated value.
There is also the other case; if the iAC value is below zero – that would be the case when the calculated bars are below the dotted line – and then the output on the chart should be: “iAC is short” and this one is also followed by the value.
Okay. That's it! Please don't forget the closing bracket here and when you are done you can click on “compile” or press F7 and you shouldn't get any errors.
We have one warning because I have used the float value here. A float is only 4 bytes, a double variable could contain a lot of more digits here, but in our case float is enough. When everything is fine, please click on the little button here or press F4 to go back to Metatrader.
In Metatrader you can click on “View/Strategy Tester” or press CTRL and R. Please pick the SimpleIAC.ex5 file. Mark the visualization option here and start a test. And here is our little Expert Advisor at work and you have created it with a few lines of MQL5 code.