TulipCharts / tulipindicators

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

make 'crossany' more useful #103

Open aEgoist opened 3 years ago

aEgoist commented 3 years ago

crossany returns 1 both crossover and crossunder situations why not return 1 for crossover and -1 for crossunder? then use abs(crossany(..)) to get the original returns if needed. thus we can get crossover and crossunder in a single calculation, otherwise we'd have to call crossover(a,b) and crossover(b,a) to do so.

codeplea commented 3 years ago

I wouldn't want to change the existing cossany() or crossover() functions. They are very useful signals for vectorized algorithms.

It might make sense to create a new function, call it crossdir(), that indicates direction by returning a -1 or 1, as you describe.