TulipCharts / tulipindicators

Technical Analysis Indicator Function Library in C
https://tulipindicators.org/
GNU Lesser General Public License v3.0
841 stars 157 forks source link

Chaikin Money Flow indicator #56

Closed rdbuf closed 5 years ago

rdbuf commented 5 years ago

The source is Kirkpatrick, Dahlquist. Technical Analysis: The Complete Resource for Financial Market Technicians (2 ed.), ISBN 978-0-13-705944-7. pp. 419, 421

The implementation literally follows the description: 1) Chaikin Money Flow cmf-1 2) Chaikin AD cmf-2

rdbuf commented 5 years ago

It should be noted though, there is a possibility of a div-by-zero in case high - low = 0 that won't probably ever happen. In either case, I have not found any good solution to this.

codeplea commented 5 years ago

there is a possibility of a div-by-zero in case high - low = 0

It's actually not so uncommon for data sets to have zero range days where o=h=l=c. I'm not opposed to returning NaN in general, but in this case it seems better to have AD evaluate to zero in the case of high - low = 0. I would like to see that case handled.

Take a look at ad.c, and see how it handles the same case. ta-lib also treats high - low = 0 as a zero for their AD implementation.

This is a very good PR, by the way. It has all the info I want to see - very clean. Great work!

rdbuf commented 5 years ago

Yes, it sounds totally reasonable to me. I've updated the PR.

Thanks for your appreciation :)