Open Jacks349 opened 2 years ago
Hello @Jacks349,
Sure it could be added. However if you or someone would like to make a PR, that would be the fastest way to get it included. 😎 I am currently blocked on existing PRs and outstanding bugs.
Kind Regards KJ
@twopirllc @Jacks349
Here is my python implementation of TRAMA modified from C# version.
I hope it shall be helpful to you.
def trama(close, length=100):
high = pd.Series(close).rolling(window=length, min_periods=1).max().values
low = pd.Series(close).rolling(window=length, min_periods=1).min().values
hh = (high - np.roll(high, 1)) > 0
ll = (low - np.roll(low, 1)) < 0
hl = np.logical_or(hh, ll).astype(float)
sma = talib.SMA(hl, length)
tc = np.power(sma, 2)
result = np.empty(len(close))
result[:] = np.nan
for i in range(1, len(close)):
if np.isnan(result[i-1]):
result[i] = close[i]
else:
result[i] = result[i-1] + tc[i] * (close[i] - result[i-1])
return result
Would be awesome to see this indicator on pandas_ta! It's a moving average that adapts to the current trend by taking into account the average of high/lows during a selected period. Link: https://www.tradingview.com/v/p8wGCPi6/
Pinescript code:
My attempt: i'm not so good at pinescript, and i'm having a lot of troubles understanding how to translate the lines
tc = pow(sma(hh or ll ? 1 : 0,length),2)
andama := nz(ama[1]+tc*(src-ama[1]),src)
to Python.Until now i managed to convert the first lines to Python, but i'm not sure if i'm doing it right: