Forex Blog

First-hand Forex trading experience and information about foreign exchange market that will be useful to traders

Archives

Coding Anything for Trading Platforms?

October 5, 2020 by

According to many authors and my own experience, achieving success in Forex is nearly impossible without a great deal of automation. Such automation can involve market analysis tools, signal indicators, execution automation (expert advisors), and performance analysis tools. Automating any of those components, brings about verifiability, repeatability and, hopefully, reliability to the trading process — all very important to actually be profitable in the FX market.

A Forex trader is coding his holy grail robot

When a trader first decides to automate something that they were doing (or planning to do) manually, they stumble upon the limitations presented by their trading platform. The limitations also apply to the coding language that should be used to create the conceived script, indicator, or expert advisor. Most traders avoid switching their trading platform and continue with automation using the platform they trade normally. This results in that most popular trading platforms also end up providing the most popular coding language and tools in the industry. Which in its turn increases the popularity of the platform (hence the pervasiveness of MT4).

Yet the quality of the trading platform itself isn’t always matched with the quality of the coding language and development environment it provides. For example, as of today, it is very noticeable with TradingView and their Pine Script.

Here is the brief description of each of the options presented in the poll below:

  • MQL4 — the oldest of the platform coding languages presented in the poll, and probably still the most popular one in retail Forex trading, it has evolved quite strong from its initial version released back in 2005. The language is C-like, but can also now work with classes and can be extended with DLL imports to perform almost any task. Coding in MQL4 is pretty straightforward but is ridden with the limitations of MT4 platform.
  • MQL5 — a younger brother of MQL4 with a lot more features and intrinsic bias to object-oriented programming. Doing simple stuff can be quite complicated with MQL5, but a huge set of standard libraries simplifies most of that. It is also much more versatile than MQL4 because MT5 as a platform is built to be a universal trading tool.
  • cAlgo — the coding language of cTrader platform is based on C#, extended with lots of platform-related classes. It is much easier for an existing C# coder to switch to cAlgo than it is for an existing C++ coder to switch to either MQL4 or MQL5. However, cAlgo is still quite lacking in terms of the features available for interaction with the platform. Despite that, there are many cAlgo coders in the official community.
  • NinjaScript — a bit younger than MQL4, NinjaScript is somewhat similar to cAlgo in that it is also extends C#. It looks to be very popular among NinjaTrader users, but NinjaTrader itself isn’t too popular with spot Forex traders, it is more a futures-oriented platform.
  • Pine Script — the newest of the trading platform languages listed in the poll below. Pine Script is used to create indicators and strategies for TradingView, which is currently one of the most popular charting platforms itself. Pine Script certainly lacks the power of the above-mentioned languages — it is very simple. But its simplicity makes it accessible to non-coders who are interested in automating a part of their trading strategy.
  • General purpose languages, such as Python, Go, R, and even C++, can (and are) used by traders to automate analysis and trading execution process. This requires some sort of connectivity between the broker’s server and the program created by the developer. Such connectivity is attained via a set of API‘s. Of course, not all brokers provide API access to their servers and not all traders are savvy enough to develop an app that would work that way.
  • Excel (or its LibreOffice counterpart) is used quite extensively to perform market analysis based on data provided by brokers via API. It is even possible to connect an Excel spreadsheet to a MetaTrader platform running on your PC using rather simple DDE access. This requires very little knowledge of actual coding and is a great way for Excel professionals to tap into Forex trading automation.

My own programming experience with trading platforms is limited to MQL4/MQL5 (99% of what I code is in those languages nowadays), cAlgo, and Pine Script. I’ve experimented with connecting to trading servers via API with Python, Go, and Excel, but that never moved on past some really basic exercises.

I invite you to vote even if your coding experience is very limited (e.g., you succeeded adding alerts to some custom indicator using our alerts tutorial, or managed to fix an OrderSend() Error 130 in someone else’s expert advisor). It is very important for me to know how popular are different platform coding languages are with my blog’s readers.

Do you code in MQL4/MQL5 or any other trading platform languages?

View Results

Loading ... Loading ...

Please use the commentary form below to share more about your experience coding for Forex trading platforms. How did you learn? How difficult it was? What was the most complex program you developed for trading or analysis purposes? Which of the retail Forex platforms offer the best coding language and development environment in your opinion?

2 Responses to “Coding Anything for Trading Platforms?”

  1. Ben

    I used to work with MT4 and MQL. Some time ago switched to cTrader (cAlgo).
    Working with C# is much faster with all the .Net features, like LINQ, lambas, events. Also, in my experience resulting code is much less prone to errors comparing to MQL. Just because C# language and compiler has more features to avoid those, and you have good refactoring tools.
    And working in Visual Studio comparing to MetaEditor is like day and night.
    I think these instruments saves me a lot of time and definitely make development process much more pleasant.

    Tried PineScript as well. It has some nice features like coloring bars based on conditions. But features set is poor.

    Reply

    Andriy Moraru Reply:

    Hi Ben!

    Yes, I would agree that the code written in C# for cTrader is much more reliable, which is especially important when working on big projects. It is also usually easier to jump into some old source code and modify/add features than it is the case with MQL4/MQL5.

    Reply

Leave a Reply

required
required (will not be published)