|
Finance chart queries |
Posted by rev on Dec-02-2014 00:20 |
|
Hi Peter,
I have some questions:)
1. How can I create such values at the end of RSI (highlighted in red)
2. How can I create such legends(with some symbols) highlighted in green
3. I'm currently using viewer object to create the image and using the crosshair.
In case of adding a new indicator I want to just load the new image and the cross hair
to work as usual. How can I achieve this? I want to load just new image without refreshing
the page.
this is related to performance: Is there any way I can load my entire data for a stock and
keep it in memory and use it when changing timeframe without hitting DB. I can do this by
fetching data using JS and sending it to php on redraw. Does chartdirector has an option
for this? Also any suggestions for firsttime chart load time? Can we generate all images for
all stocks once per day and load it from system cache or something?
Thanks in advance
|
Re: Finance chart queries |
Posted by Peter Kwan on Dec-03-2014 02:28 |
|
Hi rev,
1. You may use Axis.addMark. An example is at:
http://www.chartdir.com/forum/download_thread.php?bn=chartdir_support&thread=1395381519
2. If you are using the FinanceChart object, it will automatically add legend entries for indicators in the chart. The legend entry by default is horizontal and located in such a position that it is unlikely to overlap with the chart contents.
For your requirement, it is easy to modify the legend box to use vertical orientation. It is also easy to configure the legend box to use icons, but the icons will not be the same as in your example. Another difference is that the legend text will not be the same. For example, the FinanceChart has more detail legend text for the candlesticks, which will include the high, low, open and close values, but not the ticker symbol and session interval (in the Interactive Finance Chart example, the ticker symbol and session interval is at the top-left corner of the chart). I assume you also want the legend text to be much shorter as in your example (as the legend text in your case is very easy to overlap with the chart contents, and the box also does not look nice if the first line is much longer than the other lines).
As you need to modify all the legend text, the icons and the orientation, I think the best method is to simply modify FinanceChart.php.
(a) In the FinanceChart.php, the addLegend method configures position and orientation of the legend box to be horizontal. You may change it to vertical and add it to some other position.
(b) The addOHLCLabel function adds the legend text for the candlesticks or OHLC bars. You may modify it to add some other text with an icon. To add a legend entry with a custom icon, simply add a scatter layer with the icon you want, and with the data set name contain the text you want to appear in the legend. The scatter layer can be empty, so it will not actually plot anything.
(c) The addLineIndicator2 creates a line indicator with a default legend entry. You may use Layer.setLegendMode to disable the default legend, and use the scatter layer method in (b) to add the legend entry you like. You may do something thing for the addBarIndicator2.
There are many methods to update a part of a page without refreshing the web page. In the simplest case, you can just put your chart and crosshair in an IFRAME in your web page, and you just need to update the IFRAME. In fact, in the original "Interactive Financial Chart", the chart is updated without refreshing the entire page, but it is using <IMG> to hold the chart image. If you have crosshair, you would need to use the IFRAME to hold the chart image plus the crosshair instead of using just the <IMG>.
Another method is to use something like in the "Zooming and Scrolling with Track Line". You may notice in that sample code, there are three check boxes on the right to allow you to select the lines to plot. You can modify them the code to plot a FinanceChart, and to use the crosshair as the track line, and to modify the check boxes into your user interface to select indicators.
For performance, yes, you can freely load your data into memory, and use those data to plot charts.
Note that ChartDirector is not a database or caching software and will not load your data into memory. ChatDirector can only plot the data provided by your code. Your code can freely load and manage the data using any method you like.
I am not too sure how you would "fetch the data using JS" (which I assume refers to Javascript which runs on the browser side). Does you data reside on the server side or the browser side? If the database is on server side, does it means the browser fetch the data from the server, and then pass the same data back to the server to plot the chart?
You can certainly generate all images once per day and your PHP script can load from the stored image rather than generate the image on the fly with ChartDirector.
Hope this can help.
Regards
Peter Kwan |
Re: Finance chart queries |
Posted by rev on Dec-14-2014 18:09 |
|
Hi Peter,
Thanks for your explanation:)
Regarding candle and wick color.. I'm not able to bring the uptick color to both body and
wick and viceversa to downtick candle..
I'm using the below code. I need blue color for body and shadow for upcandle and red
color for body and shadow for downcandle.
# Add candlestick symbols to the main chart, using green/red for up/down days
$candle = $c->addCandleStick(0x81BEF7, 0xFA5858);
#$candle->setDataGap(0.05);
$candle->setLineWidth(0.5);
$candle->setBorderColor(0xFA5858,0);
#CandleStickLayer cLayer = c.addCandleStick(0x00EE00, 0xE65C01);
#$candle->getDataSet(0)->setDataColor(0x2E9AFE);
#$candle->getDataSet(0)->setDataColor(0x81BEF7,0x81BEF7);
#$candle->getDataSet(1)->setDataColor(0xFA5858,Chart.SameAsMainColor); |
Re: Finance chart queries |
Posted by Peter Kwan on Dec-16-2014 00:56 |
|
Hi rev,
The code is (in PHP):
$candle = $c->addCandleStick(-1, -1);
$candle ->getDataSet(0)->setDataColor(0x81BEF7, SameAsMainColor);
$candle ->getDataSet(1)->setDataColor(0xFA5858, SameAsMainColor);
Hope this can help.
Regards
Peter Kwan |
Re: Finance chart queries |
Posted by rev on Jan-03-2015 01:58 |
|
Hi Peter,
How can I get the last value of any technical indicator?
Id there any method to access the last value of dataset from XY chart? |
|