175 1 20
KDJ indicator
Remove from Favorite Scripts Add to Favorite Scripts
study("KDJ Indicator")
// KDJ Indicator, Rev 03
// Rewrite for Tradingview "Pine Script" by Kocurekc, April 2014
// https://getsatisfaction.com/tradingview/
// https://www.tradingview.com/u/kocurekc/
// Code is provided as public domain, no warranty
lenL = input(title="Lookback Period, Long", type=integer, defval=14, minval=2)
lenS = input(title="Lookback Period, Short", type=integer, defval=5, minval=2)
bE = input(title="Use EMA?", type=bool, defval=true)
bJ = input(title="Smooth the %J?", type=bool, defval=false)
lenJ = input(title="%J Smoothing", type=integer, defval=5, minval=1)
s = stoch(close, high, low, lenL)
pK = bE ? ema(s,5) : sma(s,5)
pD = bE ? ema(pK, lenS) : sma(pK, lenS)
pJ = (3 * pD) - (2 * pK)
plot(pK, color=blue)
plot(pD, color=red)
plot(bJ ? sma(pJ,lenJ) : pJ, color=green)
Thanks for posting this, link back to the original post,
Pine Script, KDJ Indicator, Free

This indicator was originally noted in the tradingview help forums. Noted from "Google's Finance Site," but they use a modified (using EMA instead of traditional SMA) slow stochastic with the %J equation (%J =3 * D – 2 * K ). I can't find any references to the origins of the %J equation, but it is noted in several other online sites.

The basic foundation of the code is still the %J equation. I've included an option to use either the EMA (default) and the SMA (more traditional slow stochastic). You can also adjust the lookback period, %D smoothing, and I've included the option to smooth the %J. This last option slows the indicator down a little, but really cuts out the choppiness of the %J crossings.
Ideas Scripts Chart
United States
United Kingdom
Home Stock Screener Forex Signal Finder Economic Calendar How It Works Chart Features House Rules Moderators For the WEB Widgets Stock Charting Library Priority Support Feature Request Blog & News FAQ Help & Wiki Twitter
Private Messages Chat Ideas Published Followers Following Priority Support Public Profile Profile Settings Account and Billing Sign Out