I am puzzled by how to calculate stochastic. This is the psuedocode I have:
stoch_fastK(list):
````{_, _, _, todaysClose} = list.first()
````low = min(list)
````high = max(list)
````((todayClose - low) / (high - low)) * 100
stoch(list, period, d, k):
````smoothK = for 1..k, 0, fun(kIteration, acc)
````````acc + stoch_fastK( sublist(list, kIteration, period)
````smoothK / k
stoch(last_20_datapoints_reverse_order, 14, 7, 2)
last_20_datapoints_reverse_order, means that the first member is todays close, the next is yesterdays, etc.
And my results are different from trading view. I am only looking at the smooth K line.
Can anyone help me complete this?
stoch_fastK(list):
````{_, _, _, todaysClose} = list.first()
````low = min(list)
````high = max(list)
````((todayClose - low) / (high - low)) * 100
stoch(list, period, d, k):
````smoothK = for 1..k, 0, fun(kIteration, acc)
````````acc + stoch_fastK( sublist(list, kIteration, period)
````smoothK / k
stoch(last_20_datapoints_reverse_order, 14, 7, 2)
last_20_datapoints_reverse_order, means that the first member is todays close, the next is yesterdays, etc.
And my results are different from trading view. I am only looking at the smooth K line.
Can anyone help me complete this?