ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  RSI showing wrong value in 5.02
Posted by Mahbub on Dec-29-2010 21:50
Dear sir, I am using demo version of ChartDirector 4.10 in VB2008 for my personal purpose. Recently I've downloaded version 5.02. New version showing wrong RSI and Money Flow Index value in Financial Chart. I've manually calculated it (RSI) as 44.86 and MFI as 61.56 for an Instrument called ABBANK. Version 4.10 is showing the same value as mine. But version 5.02 is showing RSI 56.32 and MFI 53.67.

Your's MACD calculation also differ from other charting software. Though it remains same in v4.10 and v5.02.

What is the wrong? Pls help me.

  Re: RSI showing wrong value in 5.02
Posted by Peter Kwan on Dec-30-2010 02:59
Hi Mahbub,

Like many financial indicators, there are more than 1 forumula for RSI. Also, like many other financial indicators, at least one of the RSI formula is inconsistent, that is, by using the formula correctly, it is normal different people will get different results. Even the same web site can compute different results at different times.

In ChartDirector Ver 4.1, we are using a "modern" RSI formula. It computes an RSI that is consistent. Unluckily, some of our customers complain that it is incorrect, because some popular web sites (like Yahoo Finance) is using the inconsistent "classical" RSI formula.

After in depth investigation, we think the classical RSI formula is more common, so in later version of ChartDirector we switch to the classical RSI formula. That's why the RSI for Ver 4.1 and Ver 5.02 are different. Both of them are correct.

The Ver 5.02 ChartDirector implementation are now computing very simiilar RSI values to popular web sites, but not exactly the same as the classical RSI formula is inconsistent.

There are many reasons why a formula is inconsistent. For example, the classical RSI relies on the exponential average. To compute today's value, you need to compute yesterday's value first. To compute yesterday's value, you need the value of the day before yesterday, and so on. That means you need infinite amount of data to compute the exponential average. So practically, the code must stop at a certain stage. For example, for a 30 days chart, the code might just use the last 30 days of data to compute the latest RSI (instead of using infinite amount of data). Because the data range uses by everyone is different, so it is normal the RSI computed are different. However, the different is usually not big.

Another inconsistency in many financial indicators is that it may cause divisiion by zero. In fact, in RSI, divisions are needed, and it is perfectly possible to have division by zero (when the price of the stock stay the same for many days). Different people may use different methods to handle division by zero, resulting in different RSI values.

For your own RSI computation, are you just using the last 14 days of data to compute 14 days RSI, or are you using "infinite" (or a large amount) of data? If you are only using 14 days of data, it is consistent with the "modern" formula in ChartDirector Ver 4.1. If you are using a large amount of data with exponential average, it should be close to the value in ChartDirector Ver 5.02 and in some popular web sites.

In fact, I have just checked using Yahoo Finance for the RSI, MACD and MFI using Cisco data (CSCO), and I found that the RSI and MACD in ChartDirector Ver 5.02 is very close or exactly the same as that is Yahoo Finance, so I think the RSI and MACD in ChartDirector should be correct. On the other hand, the MFI differ by 5%. I will investigate the MFI to see what is the cause of the difference.

Hope this can help.

Regards
Peter Kwan

  Re: RSI showing wrong value in 5.02
Posted by Mahbub on Dec-30-2010 08:53
Thanks for your prompt reply. I personally follow :  http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators      for indicator calculation. In case of RSI, you can keep both formula in next version with diffedrent name. Also my request for you to check other indicators in version 5.02.
One more request, as chartdirector calculates the indicators very fast, can chart director return the latest indicator e.g. RSI, MACD value of a stock for defined period? (for the developers)

  Re: RSI showing wrong value in 5.02
Posted by Peter Kwan on Dec-30-2010 18:55
Hi Mahbub,

In ChartDirector Ver 5.02, we use the same formula as you do (which is the classical formula and is published in the stockcharts site). So if you would like to have an implementation that uses the same formula as you do, ChartDirector Ver 5.02 is the one.

Note that as mentioned in my previous message, the classical RSI formula is inconsistent. So it is normal everyone computes a different RSI, yet all of them can be correct.

For example, if you compute today's RSI based on the data for the last 14 days, you would get one RSI value. If you compute today's RSI based on the data for the last 15 days, you will get another RSI value. You can try it yourself. (The RSI requires at least 14 days of data, but you can use more, and this will produce different values.)

For programs using the classical formula, the standard practice is to use all data that are used on the chart to compute the RSI. So if you are passing the last 120 days of data to the charting engine, the last day's RSI will be computed based on the data for the last 120 days.

For returning the internal financial data computed by ChartDirector, see:

http://www.chartdir.com/forum/download_thread.php?bn=chartdir_support&thread=1264519533#N1264527203

Hope this can help.

Regards
Peter Kwan

  Re: RSI showing wrong value in 5.02
Posted by Mahbub on Dec-31-2010 00:06
Thanks Peter. What about MFI?

MACD is also inconsistent according to period in -- http://stockcharts.com/school/doku.php?id=chart_school:chart_analysis  -- website. They use a smoothening factor for calculating EMA for later dates (after 26 period)

StochRSI is also different from version 4.1. I didn't check other indicators like CCI, OBV, ADX etc.


Please publish a new version for all users who are familiar with version 4.1 logic.

Just request.

Regards

Mahbub.

  Re: RSI showing wrong value in 5.02
Posted by Peter Kwan on Dec-31-2010 03:05
Hi Mahbub,

As far as I know, only RSI and its derivative StochRSI is changed between Ver 4.x and Ver 5.x. The other indicators should remain the same. I will double check to see if MFI remains the same or is different.

You are correct that any indicator using EMA (such as MACD) is inconsistent. So it is normal that everybody computes different values. For EMA, the inconsistency should approach zero if a large amount of data is used. So if a large enough amount of data are used to compute the EMA (and the MACD), the inconsistency should approach zero.

For example, for a 100 days chart, the MACD computed by ChartDirector and Yahoo Finance is very close for the last day. If your code also uses 100 days to compute the MACD for the last day, it should be very close to the value computed by ChartDirector too.

Many indicators are developed long time ago before computers are common, so they are designed to be computed by hand. The EMA is much easier to compute incrementally by hand. So the "classical" formula in many indicators are based on EMA. It is hoped that after many days of incrementally updating the indicator, the inconsistency will approach 0.

It also means that if you want to compute a certain indicator (say MACD(26, 12)), you should use a long sequence of values (eg. 100 points), and not just use the minimal number of points (26), because the result will be more consistent if a large number of points are used.

Hope this can help.

Regards
Peter Kwan

  Re: RSI showing wrong value in 5.02
Posted by Mahbub on Dec-31-2010 09:56
Thanks Peter for all your effort. Please let me know, at your free time, if you find any discrepancy in MFI or other indicators (that were not discussed).

Thanks again.

  Re: RSI showing wrong value in 5.02
Posted by Mahbub on Dec-31-2010 13:43
Sorry Peter to disturb you again. But, in version 5.02, MACD is showing fixed value instead of duration based variation. MACD value of 6 months and 3 years of an instrument showing same value. In VB example in your documentation uses Random data, so MACD value changes. But in real situation, an instrument's MACD value is same irrespective of it's date duration.

Please check it.

Thanks

  Re: RSI showing wrong value in 5.02
Posted by Peter Kwan on Dec-31-2010 21:10
Hi Mahbub,

From our investigation, we have found that the MFI has not changed between ChartDirector Ver 4.1 and Ver 5.x. We have checked using real data (historical stock quotes obtained from Yahoo's web site) and the indicator values are identical.

If you think the MFI computed by ChartDirector Ver 4.1 and Ver 5.x are different, would you mind to inform me the data you are using, and the charts obtained using ChartDirector Ver 4.1 and Ver 5.x.

For MACD, there is nothing abnormal that the MACD value of the last day is the same no matter you are plotting a 6 months or a 3 years chart. It is because the inconsistency could have been reduced to a negligible value with so many data points.

For indicators like MACD, the "correct value" can be computed provided you use infinite amount of data. In practice, we can only use a finite amount of data. The more data we use, the closer we are to the "correct value".

If you use very few data points (like 2 days and 3 days), you should see the inconsistency very clearly. If you use 6 months and 3 years, the inconsistency should have reduced to negligible values.

Hope this can help.

Regards
Peter Kwan