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

Message ListMessage List     Post MessagePost Message

  URGENT: Calculate daily stock technical indicators values only!
Posted by icasper on Aug-02-2013 18:59
Hi,

I have a data series of a stock in the following format:

say I extract 1 year data;

date,open,high,low,close,volume...

Since the ChartDirector have excellent technical indicator libraries, instead of plotting it, I
want to used the functions to calculate various technical indicators e.g. MA20, MA200, RSI4
etc. and get only the data values.

1. I will run the proposed php script on daily basis to calculate the technical indicators.
Can you provide some sample code for the above say for MA20, RSI5 etc., on the above
say 1 year series, where I can get JUST THE VALUES ONLY. The idea is to fetch first the
large amount of data from database say 1 year, and then apply different technical
indicators (getting database data is no problem) like MA20 for 20 days, MA 200 days etc.,
but then gets the last MA 20, and MA200 data only. I guess I have to get the last array
value of some sort of array.

2. I need to do this calculations for each of 10000+ securities if not more in the database.
Is there is a better way to calculate the above.

Thanks...

  Re: URGENT: Calculate daily stock technical indicators values only!
Posted by Peter Kwan on Aug-03-2013 01:59
Hi icasper,

As ChartDirector is a charting software, our sample code are designed to demonstrate how to create charts. Unluckily, we do not have any sample code for non-charting applications.

As a charting library, the reason ChartDirector computes indicator values is to plot them. Like most other programs, ChartDirector will not store these internal calculations and do not have any API to access them, and will discard them after plotting the indicator.

However, as the FinanceChart class library is open source, so you are free to modify it to make it store the data you need. See:

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

To compute the last value of any indicator, you just need to supply the necessary data as according to the nature of the indicator. For example, to compute MA 20 days, you only  need the last 20 days of data. Of course, you can pass the last 1 year or any number of amount of data to the code if high efficiency is not a concern.

Hope ths can help.

Regards
Peter Kwan

  Re: URGENT: Calculate daily stock technical indicators values only!
Posted by Icasper on Aug-04-2013 00:27
Great. The sample code is for c, do u have a similar code for php. Much appreciated. Thx

  Re: URGENT: Calculate daily stock technical indicators values only!
Posted by Peter Kwan on Aug-06-2013 01:14
Hi Icasper,

Similar code in PHP is:

function formatIndicatorLabel($name, $data) {
    $this->dataSeries[$name] = $data;

    ..... the original code in formatIndicatorLabel .....
}

Hope this can help.

Regards
Peter Kwan

  Re: URGENT: Calculate daily stock technical indicators values only!
Posted by Ajmal on Oct-23-2013 06:00
What would be the appropriate code in Ruby for the above.

Thanks for your guidance...

  Re: URGENT: Calculate daily stock technical indicators values only!
Posted by Peter Kwan on Oct-24-2013 02:06
Hi Ajmal,

The Ruby code is:

    def formatIndicatorLabel(name, data)
     if @dataSeries == nil
     @dataSeries = {}
     end
     @dataSeries[name] = data.dup

             ........

Hope this can help.

Regards
Peter Kwan