Jason Perl's book DeMark Indicators details rules for calculating signals developed by Thomas DeMark. These rules are not complex in themselves, but there is no dirth of ifelse
structure to incrementing a signal's progression.
An example of a rule from Perl's book:
"A Bearish TD Price Flip occurs when the market records a close greater than the close four bars earlier, immediately followed by a close less than the close four bars earlier."
It's possible to implement these rules in something as clumsy as Excel, but what programming language would implement it most gracefully? The control structure suggests a C/C++ approach, but I'm wondering if Haskell, R, Python or even Prolog might be better suited.
UPDATE: here is a sample of what an R implementation might look like:
S$deMark <- ifelse(Lag(Cl(S) < Lag(Cl(S), k=5)) & Cl(S) < Lag(Cl(S), k=4), 1,0)
Where S
is an xts object.