Skip to content
This repository has been archived by the owner on Feb 19, 2022. It is now read-only.

Calculation for the Stochastic Oszillator is wrong. #5

Open
HermanoCrespo opened this issue Jun 1, 2018 · 5 comments
Open

Calculation for the Stochastic Oszillator is wrong. #5

HermanoCrespo opened this issue Jun 1, 2018 · 5 comments

Comments

@HermanoCrespo
Copy link

SOk = pd.Series((df['Close'] - df['Low']) / (df['High'] - df['Low']), name='SO%k')

is not the correct calculation of the stochastics %K

See here:
http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:stochastic_oscillator_fast_slow_and_full

%K = (Current Close - Lowest Low)/(Highest High - Lowest Low) * 100
%D = 3-day SMA of %K

Lowest Low = lowest low for the look-back period
Highest High = highest high for the look-back period
%K is multiplied by 100 to move the decimal point two places

@deepbrook
Copy link
Collaborator

@HermanoCrespo ,
thanks for the contribution! Do you think you could submit a PR for this ? I'm currently swamped and might not have the time to update the function in the next days.

@KeithLW
Copy link

KeithLW commented Jun 13, 2018

I agree with @HermanoCrespo and the link is a very good reference. The usual lookback period for this is 14 periods (ie days, weeks, months) and the smoothing function is typically a 3 or 5 period simple moving average of %k. Can be described as (14,3,SMA) or(14,5,SMA). Should pass the lookback period and the smoothing period as parameters to the function for maximum flexibility. I am new to python but I might take a crack at it as I am converting my excel macro that does this calculation to python.

@KeithLW
Copy link

KeithLW commented Jun 16, 2018

I tried to post my stochastic version. I am new to GitHub and don't know if I did it correct. I think I have a fork under my name with the proposed function. If I am to just paste it here let me know. It didn't look like the correct format when I just pasted it here.

@deepbrook
Copy link
Collaborator

@akitxu
Copy link

akitxu commented Nov 7, 2021

@HermanoCrespo
This sentence

%K = (Current Close - Lowest Low)/(Highest High - Lowest Low) * 100

it should not be

'%K = (Current Close - Lowest Low)*100/(Highest High - Lowest Low) '

I'm sorry if I are wrong. Best regards

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants