|
Wishlist: Heikin-Ashi candlesticks |
Posted by oscillator on Jun-02-2009 08:20 |
|
Please consider adding heikin-ashi candles in your next release:
The candles themselves are constructed with the following parameters.
Close = (Open+High+Low+Close)/4
Open = [Open (previous bar) + Close (previous bar)]/2
High = Max (High,Open,Close)
Low = Min (Low,Open, Close)
http://www.investopedia.com/terms/h/heikinashi.asp
http://www.investopedia.com/articles/technical/04/092204.asp
Heikin-ashi candles can be used to spot trends easily.
Here is a comparison between standard candlesticks and heikin-ashi candles:
|
Re: Wishlist: Heikin-Ashi candlesticks |
Posted by Peter Kwan on Jun-02-2009 18:02 |
|
Hi oscillator,
Thanks a lot for your suggestion. We will add this to our feature list to be considered in the future versions of ChartDirector.
Currently, if you want to add "Heikin-Ashi candlesticks" to FinanceChart, you can do so by adding them using XYChart.addCandleStick layer. Your own code would need to compute the adjusted High, Low, Open, Close values of the indicators.
Hope this can help.
Regards
Peter Kwan |
Re: Wishlist: Heikin-Ashi candlesticks |
Posted by Ajmal on Nov-18-2014 10:14 |
|
Any example of how we can add these in php, is this how it is to be done..??
$ha-max = max (m_highData,m_openData,m_closeData);
$ha-min = min (m_lowData,m_openData,m_closeData);
$ha-close = (m_highData + m_lowData + m_openData + m_closeData)/4;
$ha-oarray = new ArrayMath($this->m_openData);
$ha-ocarray = new ArrayMath($this->m_closeData);
for ($i=0;$i<count($myArray1);$i++)
$ha-open[i] = ($ha-oarray[$i-1] + m_closeData[$i-1])/2;
but replacing these in candlestick layer is giving errors..? |
Re: Wishlist: Heikin-Ashi candlesticks |
Posted by Peter Kwan on Nov-19-2014 00:44 |
|
Hi Ajmal,
The code in my message does not seem to be legal PHP code. For example, $ha-max is
not a valid variable name in PHP. (It is illegal to use "-" in variable names.)
First, you need to use valid PHP syntax. Please try $haMax. Also, you need to perform
arithmatic on numbers, not arrays. The code is something like:
for ($i = 0; $i < count($myOpenData); ++$i) {
# Close = (Open+High+Low+Close) / 4
$haClose[$i] = ($myOpenData[$i] + $myHighData[$i] + $myLowData[$i] +
$myCloseData[$i]) / 4;
.....compute $haOpen, $haHigh and $haLow .....
}
#suppose you want to add Heikin-Ashi in the main price chart
$myMainPriceChart = $myFinanceChart->addMainChart(....);
$myMainPriceChart->addCandleStickLayer($haHigh, $haLow, $haOpen, $haClose,
0x00ff00, 0xff0000);
Note that like many financial indicators, the published formulas are incomplete. For
example, in the formula in this thread, it uses the data from the "previous bar", but it
does not mention what to do if there is no previous bar (what to do for the first bar?).
You may need to perform further research to see how to handle them and implement it in
your own code.
Regards
Peter Kwan |
|