|
How to draw keltner channel |
Posted by peter on Aug-24-2014 00:28 |
|
Hi Peter.
Thanks a lot for your help for my last quetion. This time I need to deal with "keltner channel" staffs, I searched the topic about "keltner channel", read through Programmer's Manual. but can not find it, Can you help me on this? I am using c++.
thanks in advance!
peter |
Re: How to draw keltner channel |
Posted by Peter Kwan on Aug-26-2014 01:38 |
|
Hi peter,
If you would like to plot an indicator that is not built into ChartDirector, you can compute it
with your own code, and ask ChartDirector to include it in the chart.
As the FinanceChart is open source (the source code is in FinanceChart.h), you can use it
as a reference to see how similar indicators are added to the chart. For your case, you may
examine how the similar Bollinger Band is computer (see the addBollingerBand source code -
it only has 5 lines) and modify it to create the keltner channel.
I have not tested the code myself, but I think it should be something like (I modified the
code based on the Bollinger Band code):
//
// Formula is EMA(20) +/- (2 x ATR(10))
//
ArrayMath bandWidth = computeTrueRange().expAvg(2.0 / (10 + 1)).mul(2);
ArrayMath expAvg = ArrayMath(m_closeData).expAvg(2.0 / (20 + 1));
addBand(ArrayMath(expAvg ).add(bandWidth), ArrayMath(movAvg).sub(bandWidth),
lineColor, fillColor, "Keltner Channel");
Hope this can help.
Regards
Peter Kwan |
|