Closed rdbuf closed 5 years ago
This looks pretty good. Great job with the documentation!
Here's my suggestion:
Instead of using your MAX3
and TR
macros, just include "truerange.h" and use the CALC_TRUERANGE
macro. I just benchmarked it, and ce
went from 59 mfps to 77 mfps with this change (using -O2
). It also keeps it more consistent with the rest of the codebase.
You'll need 'TI_REAL truerange;` at the top, then the first loop would look like this:
for (i = 1; i < period; ++i) {
CALC_TRUERANGE();
atr += truerange;
}
and the second like this:
for (i = period; i < size; ++i) {
CALC_TRUERANGE();
atr = atr * smth + truerange * per;
...
Done. By the way, what's your approach for quick microbenchmarking within this library?
You can remove your #undef
s too.
Ok, I think you might have a serious bug. Imagine if high[4]
is the local high point, and the period is 5. Would HP
ever get set to high[4]
? It seem that HP
would skip straight to high[5]
for the first bar. Right?
You might want to look at stoch.c
as an example of maintaining the highest and lowest. This comes up in a lot of indicators. Also, the method used by stoch.c
seem to benchmark faster (it pushed ce
past 100 mfps for me, but I'm not sure if I introduced any new bugs or not).
Let me know your thoughts.
Done. By the way, what's your approach for quick microbenchmarking within this library?
I'm just doing make benchmark -B && benchmark ce
.
Make sure to remove -std=c89 -pedantic
before benchmarking too. It makes a large difference.
Yes, my bad regarding the maintainance of max/min. I’ll push an update once I’m back to my pc.
That’s interesting because I found my version consistently performing a few percent better. I was benchmarking inside a VM though and using an ad-hoc bench code, not benchmark.c.
What’s to benchmark.c, it has a dependency on ta-lib, and I haven’t still figured out how to obtain it.
...yet it must be pretty easy, right?
ta-lib is from https://www.ta-lib.org/hdr_dw.html
Benchmark will do comparisons between TI and ta-lib. We should probably update benchmark in the future so the ta-lib comparison is optional.
I've spot another bug in my code. Gonna make a _ref
implementation (#59)
I laid the ground work for streaming indicators and reference indicators. Check out https://github.com/TulipCharts/tulipindicators/pull/60
I think the reference indicators will be a big help. There are a lot of edge cases in optimized indicator code.
I've fixed everything I got wrong last time and implemented the new interfaces. Benchmarks show that there is potentially a room for improvement, so I will probably revise it later. These are available in the CI build log (thanks to #63).
Sources:
ce_high
:ce_low
: