Friday, July 19, 2019

Why the same indicator plots differently on different platforms?

Sometimes we need to convert an indicator from one platform to another, but indicator can plot differently on two different platforms, that's quite normal if you understand how indicator works. To understand why this happens, the first thing you need to know is what indicators really are.

An indicator consist of two parts, input(data) and output(plot).
The plot what we see on chart, it depends on two factors:
  1. Algorithm: the formula(equation) used to calculate the input data.
  2. Input Data: Price(Open, High, Low, Close), Volume and other value such as Time and number of bars on chart.

Let's use SMA as example,  (SMA) is an arithmetic moving average calculated by adding recent closing prices and then dividing that by the number of time periods in the calculation average.

Let's say we compare the current 9-SMA plot on platform A and B with same symbol and chart timeframe, such as SPX and 5-minute.

The algorithm of 9-SMA is the sum of the last 9 Close price divided by 9.

Assuming the last 9 Close price on platform A are: 1,2,3,1,2,3,1,2,3.

The value of 9-SMA on platform A is: (1+2+3+1+2+3+1+2+3)/9=2

Assuming the last 9 Close price on platform B are: 1,3,3,1,3,3,1,3,3.
The value of 9-SMA on platform B is: (1+3+3+1+3+3+1+3+3)/9=2.33

Now we see that the 9-SMA has two different value on
platform A and B. That's because the input values(price data) of the equation are different.

The example above is just a very simple demonstration, the reality is more complicated.

When you see an indicator plots differently on different platforms, if the algorithm is the same on both platforms, in most case, the input data(mentioned above) is different, that's a very common situation, since the datafeed is different between platforms.

The easiest way to tell if the price data is different on two platforms is by viewing the chart candle, we can compare the last 20 to 30 bars on both chart to see if there is any inconsistency.

Sometimes, the candles look almost the same on both sides, then we need to check each bar's Price(open, high, low, close) and Volume value, just checking the last 10 bars will be enough to tell if there is any difference. 

We can also download the chart data and export it to CSV file, most platforms support this method.
Then we can compare the data between different platforms, there are many ways to do that, please check this link for more info: how to compare two columns in excel
Some indicators are very sensitive to the price or volume data, even a little difference can cause the plot totally different.

Based on my experience, the quickest way to find if it's caused by different datafeed is by checking the indicator on a Monthly chart. Because the price data of a Monthly chart is almost the same on all platforms.
If the indicator had very different plot on a Monthly chart on both sides, there could be something wrong with the code(algorithm). Then we need to debug the code.
If the indicator plots identically on both platforms on a Monthly chart, it means the code(algorithm) works the same on both sides. The reason it plots differently on Tick, Range or Minute chart must be the different of datafeed. In that case we can do nothing about it.








No comments:

Post a Comment