Add tanh-estimators indicator for normalized series
Author: abegy
Creation Date: 7/16/2017 7:02 AM
profile picture

abegy

#1
Hi Eugene,

Is it possible to add tanh-estimators as an indicator in Wealth-Lab to normalize a serie ?
As you will see in the following forum (https://stats.stackexchange.com/questions/7757/data-normalization-and-standardization-in-neural-networks), this is the best formula.

You have the same conclusion in the following article here : http://www.cse.msu.edu/~rossarun/pubs/RossScoreNormalization_PR05.pdf.
profile picture

Eugene

#2
Hi Alexandre,

Sorry, this is not my bread and butter. I don't know what these "tanh-estimators" are all about. So the answer to "is this possible" depends on your coding skills. If it presents difficulty you could try hiring a programmer with experience in this field.
profile picture

abegy

#3
Eugene,

Ok. I understand. But I find the java code for the formula here : https://github.com/xochipilli/Coinalyzer/blob/master/Coinalyzer/src/main/java/nu/dyn/caapi/coinalyzer/nn/normalizers/TanHNormalizer.java

Maybe it can be helpful ?
profile picture

lepete

#4
I can help give me a few minutes and i'll send the c# for tanh.
profile picture

lepete

#5
The syntax in c# for tanh is below. The constant terms in the equation are tricks for improving neural nets:

CODE:
Please log in to see this code.


You would need to find out how to call the .Net tanh function in WealthLab, but it is a C# math function, so maybe only the "Math." needs to be dropped.
profile picture

Eugene

#6
Math is part of System, no need to include anything. However, it does not seem to work as expected:

CODE:
Please log in to see this code.
profile picture

lepete

#7
You would need to "mean-zero standardize" the close prices over the lookback bars. If you can generate a single double called e.g. "avg" that is equal to the average of all close prices over the lookback bars, and get the standard deviation "sd" of close price over the same lookback bars, you would then need to create a DataSeries called Z using something like:

CODE:
Please log in to see this code.


which should work. The trick is that the input series to tanh needs to be centered at zero with preferably half the values of the transformed close prices above zero, and half below. You might have to detrend the data, since I typically do that for cycle analysis of close prices.
profile picture

lepete

#8
Here is a plot similar to what Close_tanh should look like (basically a sigmoidal s-curved function with a min of -1 and max of 1). Tanh is a common transform for inputs into neural nets.
profile picture

Eugene

#9
For what it's worth:

CODE:
Please log in to see this code.
profile picture

lepete

#10
That looks good and it checks out when charting, so the OP is addressed. For the OP request, one must realize that the mean and sd of Close go all the way to bar 0, so if all the chart's data were going to be required it would be appropriate to use the existing code. However, the look back bars could also be decreased if the entire Close array was not required (obviously).
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).