L2 KDJ with Whale Pump and Oust for ThinkOrSwim

samer800

Moderator - Expert
VIP
Lifetime
eN83qND.png

Author instructions:
The KDJ oscillator display consists of 3 lines (K, D and J - hence the name of the display) and 2 levels. K and D are the same lines you see when using the stochastic oscillator. The J line in turn represents the deviation of the D value from the K value. The convergence of these lines indicates new trading opportunities. Just like the Stochastic Oscillator, oversold and overbought levels correspond to the times when the trend is likely to reverse.

Function
L2 KDJ with Whale Pump and Oust is a composite indicator that combines both KDJ and Whale Pump and Oust detector. By virtue of this, fake signal of KDJ can be filtered out to some degree.

Key Signal
whalepump --> whale buy behavior will be detected and displayed in green histograms
oust --> after whale buy behavior, there usually a oust action from whale to drive out profitable orders to reduce the selling pressure of subsequent pull ups. This oust will be detected and displayed in red histograms
k --> k value of a stochastic oscillator
d --> d value of a stochastic oscillator
j --> the deviation of the d value from the d value of a stochastic oscillator
Pros and Cons

Pros:
1. filter out KDJ fake signal by introducing whale pump/oust detector
2. J value can be used to detect overbought and oversold regions

Cons:
1. It works better in small time frame and sideways. Extreme long or short conditions may cause KDJ staturate.
2. It can only indicate in current time frame, larger time frame trend info is missing.

Remarks
An improved version of L2 KDJ with Whale Pump Detector by adding oust function. Works fine in 15mins time frame.

CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at #https://mozilla.org/MPL/2.0/
#// © blackcat1402
#https://www.tradingview.com/script/bhdaBHlg-blackcat-L2-KDJ-with-Whale-Pump-and-Oust/
#study("[blackcat] L2 KDJ with Whale Pump and Oust"
# Converted by Sam4Cok@Samer800 - 08/2022

#//inputs
input ShowBubble     = yes;
input ShowHistogram  = yes;
input BuyAlertLimit  = 0;   # "BuyAlertLimit"
input SellAlertLimit = 100; # "SellAlertLimit"
input Period = 18;
input SignalK = 4;
input SignalD = 4;

#//functions
declare lower;
def na = Double.NaN;
script nz {
    input data  = 1;
    input repl  = 0;
    def ret_val = if IsNaN(data) then repl else data;
    plot return = ret_val;
}
#xrf(values, length) =>
script xrf {
    input values = close;
    input length = 0;
    def r_val;
    r_val = if length >= 1 then
        fold i = 0 to length
            with p do
            if IsNaN(r_val[1]) or !IsNaN(values[i]) then values[i] else r_val[1] else Double.NaN;
    plot return =  r_val;
}
#xsa(src,len,wei) =>
script xsa {
    input src = close;
    input len = 0;
    input wei = 0;
    def sumf;
    def ma;
    def out;
    sumf =  nz(sumf[1]) - nz(src[len]) + src;
    ma   =  if IsNaN(src[len]) then Double.NaN else sumf / len;
    out  =  if IsNaN(out[1]) then ma else (src * wei + out[1] * (len - wei)) / len;
    plot return = out;
}
#alma(series, length, offset, sigma, floor)
script ALMA {
input series = close;
input windowsize = 9;
input Offset = 0.85;
input Sigma = 6;
def m = Offset * (windowsize - 1);
def s = windowsize/Sigma;
def Sum = fold i = 0 to windowsize with WS do
           WS + Exp(-1 * (sqr(i-m))/(2*sqr(s))) * getValue(series, windowsize - i - 1);
def norm = fold j = 0 to windowsize with CW do
           CW + Exp(-1 * (sqr(j-m))/(2*sqr(s)));
plot ALMA = sum / norm;
}
#//algorithm for whale pump an oust-----
    def var1 = xrf(ohlc4,1)[1];
    def var2 = xsa(AbsValue(low - var1), 13, 1) / xsa(Max(low - var1, 0), 10, 1);
    def var3 = ExpAverage(var2, 10);
    def var4 = Lowest(low, 33);
    def var5 = ExpAverage(If(low <= var4, var3, 0), 3);

#//define KDJ
def rsv = (close-lowest(low,Period))/(highest(high,Period)-lowest(low,Period))*100;
def k = alma(xsa(rsv,SignalK,1),3,0.85,6);
def d = alma(xsa(k,SignalD,1),3,0.85,6);
def j = alma(3*k-2*d,3, 0.85,6);

########
#// plot signal
    plot kLine = k;
    kLine.SetDefaultColor(Color.WHITE);
    plot dLine = d;
    dLine.SetDefaultColor(Color.ORANGE);
    plot jLine = j;
    jLine.AssignValueColor( CreateColor(17, 118, 242));
    jLine.SetLineWeight(2);

#//plot whale buy histograms

    def bgcolor = if j crosses above BuyAlertLimit then 1 else
                  if j crosses below SellAlertLimit then -1 else 0;

AddChart(high = if bgcolor > 0 then Double.NEGATIVE_INFINITY else na,
         low = if bgcolor > 0 then Double.POSITIVE_INFINITY else na,
         open = if bgcolor > 0 then Double.POSITIVE_INFINITY else na,
         close = if bgcolor > 0 then Double.NEGATIVE_INFINITY else 0,
         type = ChartType.CANDLE, growcolor = Color.DARK_GREEN);
AddChart(high = if bgcolor < 0 then Double.NEGATIVE_INFINITY else na,
         low = if bgcolor < 0 then Double.POSITIVE_INFINITY else na,
         open = if bgcolor < 0 then Double.POSITIVE_INFINITY else na,
         close = if bgcolor < 0 then Double.NEGATIVE_INFINITY else na,
         type = ChartType.CANDLE, growcolor = Color.DARK_RED);
#//whale pump candles
    plot OustHist = var5;
    OustHist.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
    OustHist.SetHiding(!ShowHistogram);
    OustHist.AssignValueColor(if var5 > var5[1] then CreateColor(38,166,154) else
                          if var5 < var5[1] then Color.PINK else Color.GRAY);
#//Add Bubble
    AddChartBubble(ShowBubble and j crosses above BuyAlertLimit, j, "B", Color.GREEN, no);
    AddChartBubble(ShowBubble and j crosses below SellAlertLimit, j, "S", Color.RED, yes);

#//define bottom zone threshold values
def h1 = 90;
def h2 = 10;
def h3 = 0;
def h4 = 100;
AddCloud(h2, h3, Color.DARK_GREEN, Color.DARK_GREEN, yes);
AddCloud(h1, h4, CreateColor(255, 102, 255),  CreateColor(255, 102, 255), yes);

### END
 
Last edited by a moderator:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

@samer800, the MODS and great coders and members,

I want to thank you. I have "lurked" on this site for a few years without contribution. I have read countless posts and you, the mods, and other great coders and members have unknowingly provide guidance to me in these tough markets.
This indicator (along with 2 others from this site) have changed my trading from mediocre or at best break even, to not having any more losing weeks. Losing trades definitely......but it is AWESOME to see the live account growing for a change. Keep up the great work ALL of you.
One day soon I hope to post how I have combined the scripts/indicators I use and my rules for using them in my swing trading style.

Eddie R. (USAF MSgt Ret.)
 
@samer800, the MODS and great coders and members,

I want to thank you. I have "lurked" on this site for a few years without contribution. I have read countless posts and you, the mods, and other great coders and members have unknowingly provide guidance to me in these tough markets.
This indicator (along with 2 others from this site) have changed my trading from mediocre or at best break even, to not having any more losing weeks. Losing trades definitely......but it is AWESOME to see the live account growing for a change. Keep up the great work ALL of you.
One day soon I hope to post how I have combined the scripts/indicators I use and my rules for using them in my swing trading style.

Eddie R. (USAF MSgt Ret.)
I presume you trade crypto as the original author explain his purpose for creating it. Though I don't trade crypto, I am curious by your trading improvement process. Could you explain that process you went through? thanks
 
I trade options. Crypto is to crazy for me at this point.

Mr EDssr what are the other 2 indicators that changed your trading?
@antwerks,

Here are the links (OR a copy and paste) of codes I use. Right now I use 2 time frames. The 2hr and 30minute. I use the 2hr to find trades and I validate entries with the 30minute. I will do a better write up once I have 6 months or more of data to judge if I truly have my process down good.

WHALE PUMP:
https://usethinkscript.com/threads/l2-kdj-with-whale-pump-and-oust-for-thinkorswim.12302/
ASIAN STYLE KDJ:
***https://usethinkscript.com/threads/kdj-indicator-for-thinkorswim.9501/#post-93306
(I STACK these two and comment or "uncheck" boxes to get the look I want)
MONEY IN-FLOW / OUT-FLOW:

***https://usethinkscript.com/threads/...-indicator-for-thinkorswim.15969/#post-135253

In the volume script, it colors the Volume by amount of volume on up-tick versus amount of volume on down-tick. I comment out the labels and only use the volume candles.
NEW VOLUME:
https://usethinkscript.com/threads/...abels-for-thinkorswim.8466/page-8#post-135533
 
Last edited by a moderator:
I trade options. Crypto is to crazy for me at this point.


@antwerks,

Here are the links (OR a copy and paste) of codes I use. Right now I use 2 time frames. The 2hr and 30minute. I use the 2hr to find trades and I validate entries with the 30minute. I will do a better write up once I have 6 months or more of data to judge if I truly have my process down good.

WHALE PUMP:
https://usethinkscript.com/threads/l2-kdj-with-whale-pump-and-oust-for-thinkorswim.12302/
ASIAN STYLE KDJ:
***https://usethinkscript.com/threads/kdj-indicator-for-thinkorswim.9501/#post-93306
(I STACK these two and comment or "uncheck" boxes to get the look I want)
MONEY IN-FLOW / OUT-FLOW:

***https://usethinkscript.com/threads/...-indicator-for-thinkorswim.15969/#post-135253

In the volume script, it colors the Volume by amount of volume on up-tick versus amount of volume on down-tick. I comment out the labels and only use the volume candles.
NEW VOLUME:
https://usethinkscript.com/threads/...abels-for-thinkorswim.8466/page-8#post-135533
Actually, I also trade option, mostly credit spreads, and still curious how do you use the chart setup. Would you mind sharing the method? Thanks
 
Actually, I also trade option, mostly credit spreads, and still curious how do you use the chart setup. Would you mind sharing the method? Thanks
I do plan on sharing as soon as I have enough data (6 months or more of LIVE trading) to support my findings. The last 2 months have been good but I need more info and trades to really tell.
More to come.

THANK YOU! Do you see a big differenc ein the Asian version of the KDJ and the non-Asian?
From what I can tell, the Asian style seems to indicate better entries and filters chop better giving better entry and exit points. I use Heikin Ashi candles in my swing trading style as well to smooth things out.
 
Thread starter Similar threads Forum Replies Date
E L2 Dual KDJ Indicator For ThinkOrSwim Custom 1

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
450 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top