I've been spending a lot of time with this indicator and have implemented it for other platforms. While doing that I've noticed a few problems or shortcomings that could easily be alleviated and I want to propose them here, to make a more universal and streamlined version that is better suited for implementation in TA libraries.
Here is a snippet of the affected original code:
Code:
def data = fold i = 0 to length
with s
do s + (if c > GetValue(o, i)
then 1
else if c < GetValue(o, i)
then - 1
else 0);
The first issue is that the indicator uses two sources. It looks at the open and the close. This is very uncommon and in most cases doesn't even make a difference. If there are no gaps between the candles, the close of i+1 is exactly the same as the open of i. On almost all graphs with smaller timeframes, the values will even be exactly identical. Having only one input source makes the indicator a lot more flexible though, because it can be applied to a variety of sources.
For this reason, I propose the following code change:
Code:
def data = fold i = 0 to length
with s
do s + (if c > GetValue(c, i+1)
then 1
else if c < GetValue(c, i+1)
then - 1
else 0);
The second issue is that the indicator looks at length+1 candles. A TMO 14 for example looks at 15 candles. I sincerely believe that this was not intended by the original author and is a bug in the math. I therefore propose that the code is instead changed to
Code:
def data = fold i = 1 to length
with s
do s + (if c > GetValue(c, i)
then 1
else if c < GetValue(c, i)
then - 1
else 0);
With this change, a TMO 14 would look at 14 candles and be bound between -14 and 14. It would also look back at the closing prices of
length candles, like any other indicator (moving averages, RSI, MACD).
Last but not least, I propose to normalize the result to a range between -100 and 100. It makes it straightforward to work with different values for
length, because on an oscillator this has no effect on the result.
These changes wouldn't affect the essence of TMO. The new TMO 15 would be the same as the old TMO 14, if there are no gaps. With gaps, the results would only differ ever so slightly. The normalization would bring the entry signals at a fixed e.g. +70 and -70, similar to RSI, regardless of length.
What are your thoughts? Should TMO be changed with these "fixes"? Or should the fixes go into a spin-off version that's called something like "TMO - Universal Edition"?