Below code is in pine script.
ta.sma(math.abs(src - out), 499)
I am trying to write code in Python for the above statement but not able to match trading view values.
As per my understanding, I wrote this code but it is not working.
out
is a fixed value
sma_499 = sma(src, out, len(data))
print(sma_499)
def sma(src, out, window_size):
sum = 0.0
for i in range(window_size):
print(abs(src[i]-out)/window_size)
sum = sum + (abs(src[i]-out) / window_size)
# print(sum)
return sum
Need to print SMA
values for each candle.
New contributor
Bhavesh Varshney is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.