TradingView
farzinsabbagh
9. Nov. 2021 09:32

KDJ stochastic indicator 

Bitcoin / U.S. dollarBitstamp

Beschreibung

This is a special calculation of KDJ indicator. As you may know this is based on stochastic indicator. Stochastic indicator is a method to normalize a trending time serie (here price). the calculation of stochastic itself is a built in function in pine but it is straight forward:
In sudo code:
RSV for n days=(Cn-Ln)/(Hn-Ln)×100
In which, Cn is the closing price on the nth day; Ln is the lowest price in n days; Hn is the highest price in n days.
To calculate other indices K, D and J we use this formulas:
K = (2/3) * K[1] + (1/3) * RSV
D = (2/3) * D[1] + (1/3) * K
J = 3 * K - 2 * D
As you can see it is a recursive calculation. It means any value of the indices are affected by it's own previous value (and I'm passionate about recursive functions!) It may concern you that in the initial calculation there is no previous value and you are right. For the initial values we use value of 50 because it is an oscillator and the mean value is always 50 so we replace the first NAs with 50 using nz() function in pine.
After doing this calculations we reach to the smoothing section. I used simple moving averages, you may replace it with other more advanced smoothing techniqes like EMA or ALMA.
After I wrote this indicator I saw that it is a good indicator for reading divergences. As you can see I showed couple of these divergences to you on the chart. Notice that I analyzed divergence between price and J (very light green) line and not to K or D. I really appreciate any suggestion on this indicator and hope to improve it. The other ones present in the public library wasn't good and they differ a lot in the calculation and also the graphics doesn't look good.
Be free to change the parameter i saw these parameter are good to daily Bitcoin chart.
Kommentare
farzinsabbagh
I tried add another smoothing line. Me myself like to use simple indicators rather than complicated ones. I think J is more useful taht K and D may be I remove these lines on later versions.
Here in this picture I high lighted some cross of J and it's SMA out side of 0-100 area on EURUSD.
JosephFakhoury
Hi Farzinsabbagh,
I want to Thank You... for this Indi, I trade it on M1. Have you automated this as strategy, it would be cool to do it together, please write me a message. Thanks Again, Joseph
farzinsabbagh
@JosephFakhoury, Hi Joseph no still haven't write the code in our backtester, yes sure, we can exchange ideas about it.
Claykitesurfer
Hello Sir, thankyou for this indicator... are you able to add some basic divergence lines to this ?
blackwizardouz
This indicators is very nice, very easy on the eyes !
farzinsabbagh
@blackwizardouz, Thanks for your attention. If you need something just tell me. I can update this.
ishmael_iks
this is the best KDJ indicator i have seen so far. The backtesting give more accurate results compare to others
farzinsabbagh
@ishmael_iks, yes actually I done some on my own. Lets share ideas in private.
ishmael_iks
@farzinsabbagh, hey dude now seeing your message , sorry been busy but yes we can share ideas. i need reputations to private message you but i think you will be able to initiate the convo. i
Mehr