-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trama #333
base: main
Are you sure you want to change the base?
Trama #333
Conversation
The moment you have point at time Potentially, pandas' rolling() feature can help with this, and would probably be a safer option to support different usecases, as this will effectively have an indefinite lookback, as it's an expanding window starting with the very first candle. |
Please run |
Hi, sorry this took a while, finally had some time to look at this Comparing the values to tradingview, it doesn't seem to fully align. are you sure the algorithm is corresponding to the tradingview variant? |
technical/indicators/indicators.py
Outdated
hh = ta.MAX(dataframe[field], length) | ||
ll = ta.MIN(dataframe[field], length) | ||
hhll = np.where(np.diff(hh) > 0, 1, 0) + np.where(np.diff(ll) < 0, 1, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is correct, actually.
The original pinescript is making the diff first, and then does the max on top of that.
hh = max(sign(change(highest(length))),0)
ll = max(sign(change(lowest(length))*-1),0)
so maybe something around this (incomplete, untested - and switched to pandas, as to me, that transports the intend better )
change = df[field].diff()
hh = np.maximum(np.sign(change.rolling(length).max()), 0)
ll = np.maximum(np.sign(change.rolling(length).min()) * -1, 0)
# ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bkamuz the latest changes don't really go into this topic ... what's your opinion on this ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bkamuz i'd apreciate if you could take a look at the above.
i think the implemented formula is wrong - as the sequence of calls deviates from pinescript.
Name : Tradingview "Trend Regularity Adaptive Moving Average"
Pinescript Author : LuxAlgo
Link : https://www.tradingview.com/script/p8wGCPi6-Trend-Regularity-Adaptive-Moving-Average-LuxAlgo
Args :
dataframe : Pandas Dataframe
timeperiod : TRAMA length
source : Field to use for the calculation
Returns :
dataframe : Pandas DataFrame with new columns 'trama'
I've using this indicator for strategy to determine flat market.
It works perfectly, but it seems to me that we can improve it by avoiding this loop operation. But alas, no matter how I tried to use for example numpy vector operations - no success. Maybe someone will have some thoughts on this? Thank you.q