Create an EA Using a (Custom) Indicator

Indicators are important values used by your expert advisor (EA), both for signals to create entry and exit conditions and for some of the modules to set your stop loss (SL)/ take profit (TP). Before you can use any indicators, you will first have to add these to the Indicator section of your EA.

By default, we provide all the standard MT4 and MT5 indicators, which you are probably already accustomed to. In addition, you can add your own indicators, which you either developed yourself or obtained from online sources.

Although technically not indicators, these widely used values can still be found at the indicator section of your EA when adding indicators: Bar Open, Bar Close, Bar Low and Bar High

How to Add a (Custom) Indicator to Your EA

Before you can add an indicator to an EA, you will first have to add an EA to your account. Once you have added an EA to your account, you can add an indicator to your EA by clicking on the '+ Add' button in the Indicators section of your EA.

add a new indicator
Add a new indicator to your expert advisor

Available Indicators

Now you will see a list which contains all the available MetaTrader 4/ 5 indicators, your own indicators (if you uploaded any) and some indicators sourced from the web. You can select any of these indicators or you can upload a new custom indicator. When ready, click 'Next' for the indicator you would like to add to your EA. We will select the standard 'Moving Average' indicator now. In the next part of this tutorial we will upload a custom indicator.

indicator list
A list of available indicators for your expert advisor

Indicator Parameters

Once you've clicked 'Next' on the indicator you would like to add to your EA, you can now asign a name to your indicator and optionally adjust parameter values. We advise you to give your indicator a short friendly name which is easy to remember, especially when using the same indicator multiple times with different settings, like a different timeframe. Once completed, click the 'Save' button after which your indicator will be added to your EA. If the 'Save' button is grayed out, this indicates that you have forgotten to enter a required parameter value.

save indicator
Modify your indicator parameter values.

If you've carefully examined the above image, you may have noticed a checkbox labeled 'Linked'. If you've added the same indicator multiple times with different parameter values and wish for these values to be consolidated into a single input, enable this checkbox. By having only 1 input, instead of multiple, you simplify and speed up optimization in MetaTrader. However, it's important to note that altering this value in one indicator will result in all other instances of that indicator having the same value for this parameter.

Upload a Custom Indicator

In case you want to use a custom indicator, instead of using a standard indicator, you can upload the indicator. There are 2 paths to upload a custom indicator:

  • When adding an indicator to your EA.
  • At the 'My Indicator' page, which you can find in the menu.

We support custom indicators in both the mq4/ mq5 (mql)- and ex4/ ex5 (ex) format.Mqlis the source code file and is the preferred format, because it's faster and more accurately analyzed. In case you don't have the mql file, it is possible to upload the ex file, for which our system makes its best effort to analyze the indicator. To upload a custom indicator click on the Upload Custom Indicator button and select your indicator file. When our webtool analyzes the indicator file, it detects the indicator's parameters and modes (which you will learn more about in a minute). This process can take up to 15 minutes before your indicator is analyzed and ready to use.

Once you've uploaded your indicator and processing is ready, you can proceed by selecting 'Next' in the list of indicators.

upload your custom indicator
Upload your custom indicator

When Trying To Upload a Custom Indicator Results in Error

If the indicator fails to analyze, please double-check that you've uploaded the correct file. If the issue persists, feel free to contact us. Please note that a subscription is required to upload Market place indicators. This is because we manually process these indicators for you, once we've received your request (contact us).

upload your custom indicator error
Contact us if you're trying to upload a Market place indicator.

Finished Uploading a Custom Indicator

If all went well, you've successfully uploaded your custom indicator. Chances are you've already used it in MetaTrader. If not, take some time to do so and familiarize yourself with your indicator. Pay special attention to the important Mode parameter almost every indicator shows after uploading.

The Mode Parameter

If your custom indicator has one or more values (lines/ arrows/ etc.), it's crucial to use the one(s) you want to use in your EA. To do this, you must select the correct Mode. For you to find the correct Mode, we've created a complete and detailed plan we recommend following. Please note that in this example we're using an arrows indicator. The same plan must be followed for any type of indicator (histogram, line, color, etc.), as the process is exactly the same.

We're first going to see if the modes were automatically detected by our tool when uploading your indicator. Click on your indicator and select the 'Modes' tab in the right tool bar. When detecting modes succeeded, you will see something similar to the image below. If the below image matches with what you see, consider Plan A to find your modes. If plan A doesn't work, you'll be directed to plan B. It's possible that the modes have already been named for you, as our system may have recognized the indicator. If this is the case, please ensure that the mode names correspond to the values you use on your charts. If they do, there's no need to follow a specific plan to identify your modes; you can proceed directly to setting up the signal.

upload indicator success with modes
2 modes were found when analyzing the indicator. Follow Plan A.

When detecting modes automatically failed, you will see something similar to the image below. If the below image matches with what you see, consider Plan C to find your modes.

upload indicator without modes
No modes were found when analyzing the indicator. Follow Plan C.

Plan A: When Finding Modes Succeeded

If our tool was able to sucessfully detect you indicator's modes, the next step is to find which of the modes is the one you want to use. With a bit of luck this is very easy. Otherwise, we're going to need to do a bit more work. So, when 'lucky' the number of modes in MetaTrader equals the number of modes analyzed by our tool. To see the modes in MetaTrader, open the Data Window (CTRL + D). Here's an example of an indicator with 2 modes visible in MetaTrader and 2 modes found by our tool.

indicator has equal modes
2 modes were found by our system and 2 modes are visible in the Data Window.

In the above image we have 2 modes. One mode contains the values of the Up arrows and one mode contains the values of the Down arrows. We can find which of the 2 modes is the Up or Down arrow by hovering our mouse over an Up or Down arrow on the chart and observing which of the 2 modes in MetaTrader's Data Window presents a value. If the first mode presents a value when hovering our mouse over the Up arrow, we know the first mode (Mode 0) are the Up arrows. Now, also hover over a Down arrow to verify the 2nd mode contains the Down arrows. If it does, then now you know the 2nd mode (Mode 1) are the Down arrows.

In the image above you can see that when hovering over the down arrow, the Data Window shows a value for the 2nd mode of the found modes (value '2349.4000'). The same will happen for the Up arrows, which will display a value on the first mode (Mode 0).

To make things easier when building your EA, make sure you rename your Mode 0 and Mode 1 to 'Up arrow' and 'Down arrow' respectively.

indicator modes renamed
We renamed the 2 modes to Up Arrow and Down Arrow. Click Save.

You're now finished adding your indicator and you can proceed to set up the signal.

If the number of modes found by our tool doesn't match the number of modes you find in the Data Window in MetaTrader, then you're going to use a free tool to find out which mode contains your Up and Down arrows. Follow Plan B to do this.

Plan B: Find the Correct Modes Using the Buffer Reader

Open the Market Place in MetaTrader and search for the EA called 'Buffer Reader' (MT4) or 'Buffer Reader for MT5'. Install this EA. Now apply the EA to your chart. Enter the name of your indicator, without the 'ex4' or 'ex5' extension and export the data. If you get an error, make sure you made no typing error and that your indicator is in the 'Indicators' folder and not some sub-folder, like 'Examples', 'Market' or any other folder.

buffer reader mt4 mt5
The MetaTrader Market Place 'Buffer Reader For MT5' EA. Install this EA.

Now open the exported data in Excel, which you can find by going to your MetaTrader Folder (Ctrl + Shift + D, 'MQL4/5', 'Files'). You'll now see all the values of your indicator. The first 2 columns represent the row number and timestamp. The subsequent columns correspond to your indicator's 'Buffers' which represend the mode number you're looking for. By examining the data in Excel, you can determine which row contains the values for each bar, identified by timestamp. This allows you to identify which column (mode) contains the value of your arrow. Once you locate the value in the Excel sheet, you'll know which Mode corresponds to your arrow.

If Excel doesn't show your columns properly, go to the 'Data' tab in Excel, click 'Get Data', 'From File', 'From text/ csv' and select your file again. Click 'Load'.

buffer reader export for arrows indicator
Mode 1 contains a value at 17:07, meaning that the corresponding arrow (Down arrow) is Mode 1. The long number '2147...', which you see on other rows, means 'empty value'.

To make things easier when building your EA, make sure you rename your Mode 0 and Mode 1 to 'Up arrow' and 'Down arrow'.

indicator modes renamed
We renamed the 2 modes to Up Arrow and Down Arrow. Click Save.

You're now finished adding your indicator and you can proceed to set up the signal.

Plan C: Finding Modes using the Buffer Reader

If our tool couldn't successfully detect your indicator's modes, the next step is to try to find them manually. It's also possible that the indicator doesn't contain any modes. In such cases, the indicator cannot be used for automation and another, similar, indicator must be found.

Open the Market Place in MetaTrader and search for the EA called 'Buffer Reader' (MT4) or 'Buffer Reader for MT5'. Install this EA. Now apply the EA to your chart. Enter the name of your indicator, without the 'ex4' or 'ex5' extension and export the data.

buffer reader mt4 mt5
The MetaTrader Market Place 'Buffer Reader For MT5' EA. Install this EA.

Now open the exported data in Excel, which you can find by going to your MetaTrader Folder (Ctrl + Shift + D, 'MQL4/5', 'Files'). You'll now see all the values of your indicator. The first 2 columns represent the row number and timestamp. The subsequent columns correspond to your indicator's 'Buffers' which represend the mode number you're looking for. By examining the data in Excel, you can determine which row contains the values for each bar, identified by timestamp. This allows you to identify which column (mode) contains the value of your arrow. Once you locate the value in the Excel sheet, you'll know which Mode corresponds to your arrow.

If Excel doesn't show your columns properly, go to the 'Data' tab in Excel, click 'Get Data', 'From File', 'From text/ csv' and select your file again. Click 'Load'.

buffer reader export for arrows indicator
Mode 1 contains a value at 17:07, meaning that the corresponding arrow (Down arrow) is Mode 1. The long number '2147...', which you see on other rows, means 'empty value'.

Now we know which modes you want to use, go ahead and add your indicator to your EA. Make sure you rename your indicator so that you know which value this indicator contains. For example if you indicator file is called 'Haos', then you can rename your indicator to 'Haos Up' and set your Mode to value 0. Now add the same indicator ('Haos') to your EA again and rename the indicator to 'Haos Down' and set your Mode to value 1.

buffer reader export for arrows indicator
Manually entering the Mode number.
indicator modes renamed
Added the indicator twice, once with the mode for arrow up and once for arrow down.

You're now finished adding your indicator(s) and you can proceed to set up the signal.

How to add your indicator to Buy/ Sell signal

The above plans helped you find your mode(s). In the example, we followed these plans to find modes for an arrows indicator. Do note that the procedure for finding modes for other type of indicators is identical and should be followed in exactly the same manner.

Now we'll look at using the indicator in your Buy/ Sell signals.

Depending on what type of indicator you're using, the signal will be slightly different, but logical once you understand. There are 4 common types of indicator values:

  • An object, like an arrow.
  • A colour switch.
  • A line crossing a level.
  • A line crossing another line.

When adding the indicator to your EA, ensure that all the modes you intend to use are selected. Any modes not selected will be filtered out to prevent clutter.

indicator modes selected
Both modes are selected to be used by this EA.

How to set your signal for an arrow indicator

Now that you've found your modes, renamed them and enabled them when adding your indicator, it's now time to create the condition(s) which will make your EA open and/ or close orders.

Arrows are painted on the chart by MetaTrader when a mode gets a value. The arrow is placed at the value of this mode. Often an Up arrow is painted a little under the bar and a Down arrow is painted a little above the bar. This explains why the value of the mode you're seeing is always a bit above or below the price. The thing about the arrow indicators is that it doesn't matter which value they have, we only want to know if they're painted. In other words we just want to buy or sell when the mode has a value, meaning it's not empty.

We're now going to create the Open Buy signal for the arrow indicator, which will contain 1 condition: the 'Up Arrow' must be not equal to Empty.

open buy signal with arrow up
We selected the indicator's 'Up arrow' mode and will buy if its value is not equal to Empty.

We can now do the same thing for Open Sell, but instead we're selecting the 'Down arrow' mode. Optionally, we could duplicate the Open Buy signal to Close Sell and the Open Sell signal to Close Buy. This way, we can seamlessly switch between buying and selling whenever the arrows transition from buy to sell and vice versa.

Once you're done, your first version of your EA is ready and you can proceed to export your EA. For a full tutorial on how to run your first EA, please see how to run our first EA together.

How to set your signal for a color indicator

Now that you've found your modes, renamed them and enabled them when adding your indicator, it's now time to create the condition(s) which will make your EA open and close orders.

When MetaTrader paints a line on the chart, your interest may lie in either the color of the line itself or the transitions between colors. It's possible that in fact the colored line consists out of 2 seperate modes: one for green and one for red. If that's the case, which you found out about in the plan for finding modes, then setting up the Buy/ Sell signal is exactly the same as setting up the signal for arrows. The only difference is you'll call your modes 'Green' and 'Red', instead of 'Arrow Up' and 'Arrow Down'.

In other cases, you may have found 1 mode which contains the value of the color by comparing what you're seeing on the chart with what you see in the Data Window or Buffer Reader export. For example, when a mode has value -1 the line is red line and when it has value 1 the line is green. Sometimes there's a third color, like a value 0 for gray. If this is the case, then the logical thing to do is create a Open Buy signal which checks if the value of the color mode is 1. For Open Sell, create a condition which checks if the value of the same color mode is -1. I hope you're starting to get the logic of this.

open buy signal with arrow up
We selected the indicator's 'Color 1 or -1' mode and will buy if its value is equal to 1 (green).

We can now do the same thing for Open Sell by selecting the same indicator mode, but this time check if the value is -1. Optionally, we could duplicate the Open Buy signal to Close Sell and the Open Sell signal to Close Buy. This way, we can seamlessly switch between buying and selling whenever the color transitions from red to green and vice versa.

Once you're done, your first version of your EA is ready and you can proceed to export your EA. For a full tutorial on how to run your first EA, please see how to run our first EA together.

Using Shift when Adding Your Indicator to a Signal

When adding the conditions, you may have noticed the 'Shift' setting. When setting the 'Shift' value to 0, you choose the indicator's value at the current bar. 'Shift' 1 corresponds to the previous bar, 'Shift' 2 to the next bar, and so forth. It's crucial to select the 'Shift' that corresponds to the bar at which you intend to execute buy/sell actions. For instance, if you wish to avoid buying when the current bar displays an arrow (due to potential repainting), consider using 'Shift' 1. Often, the arrow is not painted on the current bar at all, depending on the indicator. If our analyzer determines that the selected 'Shift' will never yield a value, a red exclamation mark (!) will be displayed as a warning. A blue exclamation mark indicates that the selected 'Shift' may be repainting. While we strive for accuracy, please conduct your own research as we cannot guarantee the validity of this informational warning at all times.

My Indicators page

Besides uploading an indicator when adding an indicator to your EA, you can also use the 'My Indicators' page. Here you can upload, download or delete your custom indicators. If you would like to delete a custom indicator, make sure it is not used by any of your EA's or else it cannot be deleted.

custom indicator page
Add, delete or download your custom indicators

Next: Signals