technical
technical copied to clipboard
Trama
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
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.
The moment you have point at time i
depend on i-1
, your only option is usually to loop, as the prior point directly influences the current datapoint.
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. Now the influence of the very first candle will decrease significantly over time - but in theory, you can still see a (very small, potentially disappearing due to float representation) difference 200 or 2000 candles into the dataframe by simply modifying the very first candle
Please run black
locally - it'll auto-fix the errors CI is pointing out ;)
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. For example right before the long, red candle, this indicator is touching the green candle - but the tradingview one isn't.
are you sure the algorithm is corresponding to the tradingview variant?