## Solving The Indicator Problem

By: | 06/04/2015

When building a strategy it’s important to understand all of the different components that are used.

If it’s a technical-based strategy, you need to know exactly how all the indicators are calculated and implemented. Within this article we’ll talk about why we chose TA-LIB, an open-source technical indicator library, as well as how it was implemented in TRAIDE and MetaTrader 4 (MT4).

What we were able to develop was a consistent library of technical indicators that can be used across multiple platforms. We wanted to be absolutely certain that the indicators we were using in TRAIDE were calculated exactly the same as the indicators we were using in our own live trading.

#### TA-LIB

TA-LIB is an open-source technical analysis library. Started in 1999 and under a very friendly BSD license, it has basically everything you need: a large, active community (over 7,000 members), very stable versions (last major release in 2008 with a minor release in 2013), plenty of documentation/support (native C/C++, Java, .NET, Excel add-on, Perl and Python wrappers), and tons of indicators (over 125 indicators including candle-stick patterns).

One of its greatest advantages is the complete transparency into how the indicators are calculated. As with any open-source project, you are able to dive into the source code to see exactly what’s happening. While some indicators, like a simple moving average (SMA), are very straightforward, others can be much more complex. This takes care of a lot of the issues with MetaTrader 4 that I talk about in one of my previous articles.

Let’s take an example, some indicators “have memory”, meaning that the current value is dependent, to some extent, on all previous values. An exponential moving average (EMA) is calculated by looking at today’s price, multiplying it by a weight, and adding it to the previous EMA value multiplied by a weight. So every new value is based on the previous one, meaning it “remembers” all values up to that point.

Now this isn’t necessarily a problem as long as you know when the calculation began, also known as the “lookback period”. The problem with many trading platforms, and other applications, is you don’t know exactly how the lookback period is calculated. Is it just the data in the chart? All of the available historical data? The last 1,000 data points? You can try to reverse engineer it by calculating the indicator by hand and comparing the values but this is very time consuming and is an error prone process that isn’t scalable when looking at 125 indicators.

When building TRAIDE, we needed to be absolutely sure how the indicators were calculated and, even more importantly, the live implementation needed to be exactly the same.

The question we sought to answer was: “How can we be confident that the indicators used in TRAIDE will be exactly the same when you go to trade live in whatever platform you are using?”

And the answer, for MetaTrader 4, was found by building our own TA-LIB - MT4 DLL.

#### What is a DLL?

A DLL (Dynamic Link Library) is basically a small, specialized program that lets your application communicate with another specific device or program. It allows multiple applications to communicate at once, doesn’t take up a lot of space or require a large installation process, and allows for easy updates without needing to reinstall the entire program. Perfect for what we are trying to do!

A TA-LIB MetaTrader 4 DLL allows you to easily use TA-LIB’s indicators in MT4. When you select an indicator in MT4, it makes a call to TA-LIB to calculate the indicator over the MT4 data with the specified parameters.

Since TRAIDE is using TA-LIB on the backend, we can have confidence that the calculations are exactly the same in TRAIDE and MT4, and we have complete transparency into what the calculations actually are!

We are making the DLL open source and available so even if you don’t use TRAIDE, you can still use TA-LIBs indicators in MT4.

Now that we have the DLL built, we are able to support exporting any strategy to MT4, so go out there and start testing and trading your strategies live!

Happy TRAIDING and keep an eye out for candlestick patterns coming soon!