-
Notifications
You must be signed in to change notification settings - Fork 179
Calculation for the Stochastic Oszillator is wrong. #5
Comments
@HermanoCrespo , |
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. |
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. |
https://help.github.com/articles/creating-a-pull-request/ Have a look here! |
@HermanoCrespo
it should not be '%K = (Current Close - Lowest Low)*100/(Highest High - Lowest Low) ' I'm sorry if I are wrong. Best regards |
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:
https://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
The text was updated successfully, but these errors were encountered: