How Do I Set Up A Custom Indicator In MT4?

share.this:
Editorial Note: While we adhere to strict Editorial Integrity, this post may contain references to products from our partners. Here's an explanation for How We Make Money. None of the data and information on this webpage constitutes investment advice according to our Disclaimer.

To create and/or edit a custom indicator for MT4, you need to:

  • Open the MQL4 code editor;

  • Write or edit the code of the custom indicator;

  • Write the code without errors. The custom indicator will then become available in the list of indicators on the MT4 platform, and you can add it to the price chart.

MQL4 (MetaQuotes Language 4) is a programming language developed by MetaQuotes Software for creating custom indicators and using them on the MetaTrader 4 (MT4) platform.

In this article, through detailed explanations and examples, I will show how you can create a custom MQL4 indicator to use in your trading.

  • How do I create my own trading indicator?

    Popular trading platforms like MetaTrader, TradingView, TD Ameritrade, and others allow users to create custom indicators using programming languages that describe formulas for calculating custom indicators.

  • How can I customize an indicator?

    Use the parameters available for customizing the indicator. For instance, the key parameter for customizing EMA and RSI indicators is the period. If you find a specific setting lacking, you can add it by editing the indicator's code.

  • How do I add indicators to MQL4?

    To add an indicator to the MQL4 code editor, launch the MT4 platform and press F4 to open the MQL4 editor. Click on Open (Ctrl+O) to add the indicator code with the .mq4 extension that you wish to edit. Here's a detailed guide: How to Add Indicators to MT4 - a step-by-step guide

  • What is the most powerful MT4 indicator?

    If the simplest indicator is deemed the most powerful, then a simple moving average (SMA) fits that description. In practice, if trading leads to losses, analyzing how trades align with the SMA can provide valuable insights. Perhaps, by experimenting with periods, this indicator can become a filter that helps turn your losses into profits.

Start trading Forex now with eToro!
eToro is a multi-asset platform which offers both investing in stocks and cryptoassets, as well as trading CFDs.

How to create a custom indicator in MQL4?

After learning about the most common indicators available on the MT4 platform, such as MACD, RSI, ADX, and others, you may want to create your own custom indicator based on your unique idea.

However, before diving into creating a custom indicator, I recommend weighing the pros and cons of this decision.

👍 Advantages of custom indicators:

Uniqueness. Custom indicators allow you to tailor tools to specific trading strategies, meeting individual requirements, and potentially providing a competitive edge;

Automation. They can automate certain parts of the analysis process, saving time and reducing the likelihood of human error;

Strategy Testing. They facilitate testing the effectiveness of trading hypotheses, as well as collecting and processing statistics.

👎 Some disadvantages:

False Signals. Like all indicators, custom ones may generate false signals, risking the illusion that a custom indicator created from one's idea will guarantee profits;

Feasibility. Not all ideas are feasible. For example, it is simply impossible to stop the ZigZag indicator from getting redrawn;

Complexity. Creating custom indicators requires programming knowledge or additional costs to cover the work of a freelance programmer;

Over-Optimization. There is a risk of overfitting, where a custom indicator performs well on historical data but fails in real trading.

Therefore, if the advantages outweigh the disadvantages in your case, let's proceed.

There are three ways to create a custom MQL4 indicator:

  1. Manually writing (or editing) the indicator code yourself. You can use existing open-source code as a basis;

  2. Using various code-generating tools. ChatGPT4 is one of such tools;

  3. Hiring a freelance programmer.

Let's explore how each of these three methods works.

How to create MQL4 indicator code yourself

Launch MetaTrader 4, then press F4 to open the MQL4 code editor, where custom indicators are created.

Next, open the existing code (Ctrl+O) or create one from scratch (Ctrl+N) using pre-set templates. You can also drag the indicator code in .mql format onto the workspace.

How to edit indicator code in the MQL4 editor

How to edit indicator code in the MQL4 editor

The screen above displays the MQL4 code editor interface:

  • On the left are the available indicators;

  • In the center is the area for editing the code. Personally, I do not have advanced programming knowledge, but I can guess what each line of code means;

  • The compile button (indicated by the arrow). Press it when the code is finished;

  • At the bottom is the area where a list of errors may appear during compilation. If there are no errors, the custom indicator will become available in MT4 after compilation.

The MQL4 programming language is similar to the C programming language and is not considered difficult to learn. Knowledge of programming language can become a universal assistant in trading for solving various tasks: creating custom indicators, trading robots, collecting and processing statistics, configuring connections to various services, etc.

How to create a custom indicator using MQL4 code generators

ChatGPT4 is one way that allows creating a custom indicator for those who do not have sufficient programming knowledge.

Let me show you what it may look like. Suppose we ask ChatGPT4 to create a code for an indicator that gathers statistics based on the query: «How does the price change on average, starting from XX:XX to YY:YY within a day.»

Here's what it looked like on my screen:

Creating a custom MQL4 indicator in ChatGPT4

Creating a custom MQL4 indicator in ChatGPT4

I copied the code, pasted it into the MQL4 editor, and compiled it. Fortunately, there were no errors. If there were any, I would need to copy the error descriptions and ask ChatGPT4 to correct them.

Compiling a custom MQL4 indicator

Compiling a custom MQL4 indicator

Then I added the indicator to the chart in MetaTrader 4 and the indicator gave me this message: "No data available.”

Working with a custom MQL4 indicator

Working with a custom MQL4 indicator

I tried several times to modify the request for ChatGPT4, but my custom indicator consistently failed to provide the statistics. And this is the main drawback of this method - it is highly possible that you will not get a custom indicator with the desired functionality (even with simple conditions, as in this example).

Problem is that ChatGPT uses "natural" language processing to analyze digital market data, so the effectiveness of the created indicator directly depends on how correctly you manage to formulate queries for the AI to work.

But in the future, ChatGPT will be able to combine technical analysis with text and video information from financial news and social networks, as well as help automate the process of training and conducting complex backtests of any trading systems.

The advantage is that you can easily try this method - it is possible that it will work in your case.

Freelancers for creating custom MQL4 indicators

Ordering custom indicators from freelancers is a more reliable way to get the desired result. There is a special section on the MT4 platform developers' website for this:

How to create a custom MQL4 indicator on demand

How to create a custom MQL4 indicator on demand

You need to provide a detailed description of the custom indicator you want to create, propose your price, and select a freelancer from among those who respond to your request.

Best Forex brokers in 2024

1
9.4/10
Go to broker
eToro is a multi-asset investment platform. The value of your investments may go up or down. Your capital is at risk. Don’t invest unless you’re prepared to lose all the money you invest.
Minimum deposit:
$50, $100 (for UK clients)
Bonus for deposit:
0%
Regulation:
CySEC, FCA, ASIC
2
9.2/10
Go to broker
Your capital is at risk.
Minimum deposit:
No minimum
Bonus for deposit:
0%
Regulation:
FSC (BVI), ASIC, IIROC, FCA, CFTC, NFA

How to use custom MT4 indicators?

Creating custom indicators in MQL4 or any other programming language for trading platforms requires attention to detail and an understanding of trading strategies. Here are some key tips to help you create effective and useful custom indicators:

Define the indicator's goal. Before starting work, clearly define what your indicator should do and what problem it solves. A clear understanding of the goal will help you design the indicator more purposefully.

Be realistic. The higher the probability of profit you want to achieve with the indicator, the higher the likelihood that it may not work out.

Study other indicators. It's possible that someone else has already had the idea for your custom indicator, and there's already a ready and available solution.

Conduct testing. Use historical data to test your indicator and make sure it works as expected. Use debugging features in MetaEditor to find and fix errors in the code.

Keep improving. Study technical analysis, programming languages. Experiment with developing your own indicators, scripts, strategies, trading robots - this can be valuable experience that will ultimately improve your quality of life.

Conclusion

Creating custom MQL4 indicators for the Metatrader 4 trading platform is a solvable task, but it may come with challenges. In any case, you will have to deal with the MQL4 code editor to create your own indicator independently, with the help of ChatGPT, or in collaboration with a programmer.

Team that worked on the article

Oleg Pylypenko
Contributor

For over 15 years, Oleg worked as a copywriter and journalist at advertising and marketing agencies, as well as radio and television companies. His writing style is aimed at using simple terms to explain only those things that matter to the reader – benefits, risks, and realizable ideas. During the 2008 financial crisis, Oleg got interested in the stock and Forex markets and thoroughly explored price action to start working as an independent expert in 2018.

Dr. BJ Johnson
Dr. BJ Johnson
Developmental English Editor

Dr. BJ Johnson is a PhD in English Language and an editor with over 15 years of experience. He earned his degree in English Language in the U.S and the UK. In 2020, Dr. Johnson joined the Traders Union team. Since then, he has created over 100 exclusive articles and edited over 300 articles of other authors.

Mirjan Hipolito
Cryptocurrency and stock expert

Mirjan Hipolito is a journalist and news editor at Traders Union. She is an expert crypto writer with five years of experience in the financial markets. Her specialties are daily market news, price predictions, and Initial Coin Offerings (ICO).