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

Message ListMessage List     Post MessagePost Message

  Indicators' value is not fixed
Posted by Takeshilaw on Jul-09-2018 23:27
Attachments:
Hi Peter,

I tried to make my financechart able to be scrolled horizontally based on your financedemo sample code in QT. When I scroll the chart, I realised that the indicators' value of a designated date (RSI and MACD, 12 May 2017 in this case) varies at the left part of chart, probably in the area of a few days from the left-most chart. The indicators' value remains stable at RSI:75.0949 and MACD:0.01932 when I scroll the designated date to the right further. Could I ask is it because of the starting day being shifted backwards by "extraPoints" which makes the value changes at the front part of chart? How I can achieve if I want to make the indicator value to be stable always?

Please help and thank you very much for your time in advance.


Best Regards,
Takeshi
1.PNG
2.PNG

  Re: Indicators' value is not fixed
Posted by Peter Kwan on Jul-10-2018 15:21
Hi Takeshilaw,

Many of the financial indicators by definition is unstable. To obtain a stable value requires infinite amount to data.

For example, many financial indicators use something like "exponential average". An example is:

indicator_value_today = 0.8 x indicator_value_yesterday + 0.2 x close_price_today

So to computer the "indicator_value_day", you need to know the "indicator_value_yesterday". But to computer the yesterday indicator value, you need to know the indicator value the day before yesterday. So you can never compute the indicator value because it each day depends on the previous day, and the previous day depends on the day before the previous day, and it goes not forever.

In practice, we must start at some arbitrary date. In your case, the indicator values for those two charts are different because the data started from different date. The effect will be more visible near the start date of the data (that is, on the left side), and will be less visible on the right side. It is because as there are more and more data, the two series will tend to "converge" even if they start from different dates.

If both charts include data from very long time ago (you can use extra_points to remove them on the chart so the data long time ago are not visible), then the indicators should be almost the same as the they should "converge".

Note that other charting programs will also have this effect, as it is related to the definition of the indicator.

Regards
Peter Kwan

  Re: Indicators' value is not fixed
Posted by Takeshi on Jul-14-2018 12:28
Attachments:
Hi Peter,

Thank you very much for your insightful comments.
I am thinking of using an alternative way by implementing a combo box with a list of time range selection. All the OHLC data within the selected time range are obtained from database and stored in the total_ OHLC data, and from there retrieve the m_ OHLC data to be shown in the graph. However, how can I calculate the indicators value base on the total_ OHLC data so that the indicators value could be probably fixed for the selected time range?

Thank you for your time.

Best Regards,
Takeshi
1.png

  Re: Indicators' value is not fixed
Posted by Peter Kwan on Jul-14-2018 18:48
Hi Takeshi,

In your code, you should have an "extraPoints" parameter. For example, in one of the examples in this forum, the extraPoints is set to:

int extraPoints = std::min(10, startIndex);

See:

https://www.chartdir.com/forum/download_thread.php?bn=chartdir_support&thread=1467686966#N1467786759

For your case, instead of using 10, you can use 100 or 200. I think that is enough for the indicators "converge" to a few decimal places so the differences are not noticeable. You can also use a value like 1000000, in which case all the data will be used to compute the indicator.

Regards
Peter Kwan

  Re: Indicators' value is not fixed
Posted by Takeshi on Jul-15-2018 12:51
This solves my problem.
Thank you very much Peter.

Best Regards,
Takeshi