Dr Wish's Black & Green Dot Indicator For ThinkOrSwim

Thanks for the kind words, @lmk99

I am not quite sure how to handle the Green Line BreakOut bit. For the moment you can add in the following code to the end of the script. This will plot a horizontal line at the high of each month on the daily chart. Nothing fancy but it works for now.


Code:
# -- Green Line BreakOut -- Monthly timeframe, all time high not surpassed for 3 months

def aggM = AggregationPeriod.Month;
plot GLBO =  High(period = aggM);
GLBO.SetPaintingStrategy(paintingStrategy.Horizontal);
GLBO.setLineWeight(2);
GLBO.setDefaultColor(color.green);

Plan to tinker with it more to get it to look better and decide how to have any signals or triggers when crossed. It is crude but at least makes it easier to eyeball it when the cross is about to happen.


Edit: Added to main code in earlier posting.
 
Last edited by a moderator:
From the Green Line Breakout article Dr. Wish mentions he likes for the stock to '... to have already doubled from its lowest price over the past year. This attribute helps, but is not always required...' so I made some labels to help with that.

Code:
# --- Find yearly low of stock, want price to double from it's lowest price over the past year
def YearLow = Lowest(Low, 261); # 52weeks x 2day weekend = 104, 365-104 = roughly 261 trading days in a year
AddLabel(yes, " Yearly Low: " +round(YearLow, 2)+  ", x2 = "  +round(YearLow, 2)* 2+ ", Current: " +round(close, 2)+ "", color.light_gray);

#-- Percentage from YearlyLow
def data = close;
def avg = YearLow;
def pct = (data/avg) - 1;
AddLabel(yes, "% change from YearLow of " +round(YearLow, 2)+ " is " + AsPercent(pct)+ "" , if pct > 1 then Color.GREEN else Color.PINK);

I will add this to my main code from earlier.

Sorry @mashume if I have stepped on your thread. I liked the concept and wanted to improve my coding skills with what you provided. My attempt to pay it forward and give back to the forum in what small way I can.
 
Last edited by a moderator:
This looked interesting so thought I would muck about with it a little. Found a few other articles on this system and added in their suggestions. Such as the 30 week avg for buy condition. The 21 exp and 30 sma for black dot condition visuals. As well as 5 day low marker at dot signals for the support level / entry exit stop if trade fails. Chartbubbles for the dot signals only appear if signal in previous 5 days (to reduce clutter) can be turned off.

I changed the black dots to magenta to be seen easier on my dark chart background. Also changed the black (magenta) dots to triangles to be able to detect easier when they overlap green dots at the same spot.

Modified stoch lower panel includes green cloud as preferred buy zone between 50 and 25. Fast crossing (up / down) slow signal arrows.

Red and blue exponential ribbons for trend detection in separate chart window .

Ideas from
https://wishingwealthblog.com/2018/03/green-dot-strategy-defined/
as well as the Red White Blue ribbons from
https://wishingwealthblog.com/glossary/
mentioned in
https://aaiidcmetro.com/slides/(2019-07-13)wish.pdf

Basically three chunks of code.
1)Main chart with green / black dots
2)Lower panel of main chart has modified stoch
3)Side chart with ribbon code

Screen setup FlexChart at the moment consists of main window - left 2/3rds of screen with green / black dots and lower panel with modified stochastic. The right 1/3 screen side window chart has the RWB ribbon (to reduce main chart clutter).

First time sharing chart, hope it works http://tos.mx/aA8Yizg

Main chart code.
Code:
# Jan 2022 my mucking about with code from mashume
# https://usethinkscript.com/threads/dr-wishs-black-green-dot-indicator-for-thinkorswim.8110/
# to include stuff from
# https://wishingwealthblog.com/2018/03/green-dot-strategy-defined/
# https://aaiidcmetro.com/slides/(2019-07-13)wish.pdf
# https://wishingwealthblog.com/glossary/

# Dr Wish's Black & Green Dot Indicator For ThinkOrSwim
# @Joshua 9/2021
# with green dots by mashume
# from TC2000 code found here: https://wishingwealthblog.com/2021/06/follow-on-to-traderlion-conference-this-wednesdays-long-island-talk-examples-of-black-dot-signals-gmi6-of-6/

def black =
    Sum(StochasticFull(10,1) <= 25, 3) >= Yes
    and close > close[1]
    and (close > Average(close,30)
        or
        close > expAverage(close,21)
    )
;


    # Added the Stoch suggested cross over up to occur at oversold values less than 50.
def green = if stochasticFull(10, 4)[1] < Average(StochasticFull(10, 4)[1], 4)
and stochasticFull(10, 4) < 50
AND StochasticFull(10, 4) > Average(StochasticFull(10, 4), 4) then low else double.nan;



plot bDot = if black then low else double.nan;
bDot.SetPaintingStrategy(paintingStrategy.triangles);
bDot.setLineWeight(3);
bDot.setDefaultColor(color.magenta); # instead of black to show on black chart background


plot gDot = green;
gDot.SetPaintingStrategy(paintingStrategy.POINTS);
gDot.setLineWeight(3);
gDot.setDefaultColor(color.lime); #green

# ---  Finding lowest 5 day value for possible support level and entry stop out if trade fails.
# ---  ToS only compares two values at a time.
def A = Min(low, low[1]);
def B = Min(low[2], low[3]);
def C = Min(A, B);
def D = Min(C, low[4]);


# -- to show only current few (5) days worth of level stop bubbles, reduce clutter
def plotThis =  if getday() >= (getlastday() - 5) and GetLastYear() == GetYear() then 1 else 0;


# -- extra dots for lookback stop value
plot bDotLB = if black then D else double.nan;
bDotLB.SetPaintingStrategy(paintingStrategy.Horizontal); #triangle in case they overlap green dot
bDotLB.setLineWeight(2);
bDotLB.setDefaultColor(color.magenta); # instead of black to show on black chart background

plot gDotLB = if green then D else Double.NaN;
gDotLB.SetPaintingStrategy(paintingStrategy.Horizontal);
gDotLB.setLineWeight(2);
gDotLB.setDefaultColor(color.lime); #green

input ShowBubbles = yes;
AddChartBubble(ShowBubbles and plotThis == 1 and green, D, "Support / \n Stop: " +D+ "", Color.lime, no);
AddChartBubble(ShowBubbles and plotThis == 1 and black, D, "Support / \n Stop: " +D+ "", Color.magenta, no);

# -- 30 week avg for Dr Wish, one of the conditions for determining trend.  Stock should be above.
def agg = AggregationPeriod.WEEK;
def ThirtyWeek = close(period = agg);
plot wk30sma = Average(ThirtyWeek, 30);
wk30sma.setDefaultColor(color.light_green);
AddLabel(close > wk30sma, " Above 30wk sma ", color.green);
AddLabel(close < wk30sma, " Below 30wk sma ", color.pink);


# -- moving avgs for black dot confirmation
input ShowBlkDotMA = yes;
plot BlkDtsma = if ShowBlkDotMA then Average(close, 30) else Double.nan;
plot BlkDtexp = if ShowBlkDotMA then ExpAverage(close, 21) else Double.nan;


# -- Green Line BreakOut -- Monthly timeframe, all time high not surpassed for 3 months
def aggM = AggregationPeriod.Month;
plot GLBO =  High(period = aggM);
GLBO.SetPaintingStrategy(paintingStrategy.Horizontal);
GLBO.setLineWeight(2);
GLBO.setDefaultColor(color.green);


# --- Find yearly low of stock, want price to double from it's lowest price over the past year
def YearLow = Lowest(Low, 261); # 52weeks x 2day weekend = 104, 365-104 = roughly 261 trading days in a year
AddLabel(yes, " Yearly Low: " +round(YearLow, 2)+  ", x2 = "  +round(YearLow, 2)* 2+ ", Current: " +round(close, 2)+ "", color.light_gray);

#-- Percentage from YearlyLow
def data = close;
def avg = YearLow;
def pct = (data/avg) - 1;
AddLabel(yes, "% change from YearLow of " +round(YearLow, 2)+ " is " + AsPercent(pct)+ "" , if pct > 1 then Color.GREEN else Color.PINK);

lower panel modified stoch
Code:
# Jan 2022 my mucking about with code from mashume
# https://usethinkscript.com/threads/dr-wishs-black-green-dot-indicator-for-thinkorswim.8110/
# to include stuff from
# https://wishingwealthblog.com/2018/03/green-dot-strategy-defined/
# https://aaiidcmetro.com/slides/(2019-07-13)wish.pdf
# https://wishingwealthblog.com/glossary/




#
# TD Ameritrade IP Company, Inc. (c) 2008-2021
#

declare lower;

input over_bought = 80;
input over_sold = 20;
input KPeriod = 10;
input DPeriod = 10;
input priceH = high;
input priceL = low;
input priceC = close;
input slowing_period = 3;
input averageType = AverageType.SIMPLE;
input showBreakoutSignals = {default "No", "On FullK", "On FullD", "On FullK & FullD"};

def lowest_k = Lowest(priceL, KPeriod);
def c1 = priceC - lowest_k;
def c2 = Highest(priceH, KPeriod) - lowest_k;
def FastK = if c2 != 0 then c1 / c2 * 100 else 0;

plot FullK = MovingAverage(averageType, FastK, slowing_period);
plot FullD = MovingAverage(averageType, FullK, DPeriod);

plot OverBought = over_bought;
plot OverSold = over_sold;



#def upK = FullK crosses above OverSold;
#def downK = FullK crosses below OverBought;
#  Green Dot criteria
def upK = FullK < 50 and FullK crosses above FullD;
def downK = FullK crosses below FullD;

def upD = FullD crosses above OverSold;
def downD = FullD crosses below OverBought;

plot UpSignal;
plot DownSignal;
switch (showBreakoutSignals) {
case "No":
    UpSignal = Double.NaN;
    DownSignal = Double.NaN;
case "On FullK":
    UpSignal = if upK then OverSold else Double.NaN;
    DownSignal = if downK then OverBought else Double.NaN;
case "On FullD":
    UpSignal = if upD then OverSold else Double.NaN;
    DownSignal = if downD then OverBought else Double.NaN;
case "On FullK & FullD":
    UpSignal = if upK or upD then OverSold else Double.NaN;
    DownSignal = if downK or downD then OverBought else Double.NaN;
}


plot FiftyMark = 50;
FiftyMark.setDefaultColor(color.light_green);

AddCloud(25, 50, color.light_green, color.light_green);



UpSignal.setHiding(showBreakoutSignals == showBreakoutSignals."No");
DownSignal.setHiding(showBreakoutSignals == showBreakoutSignals."No");

FullK.SetDefaultColor(GetColor(5));
FullD.SetDefaultColor(GetColor(0));
OverBought.SetDefaultColor(GetColor(1));
OverSold.SetDefaultColor(GetColor(1));
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);

side window ribbons
Code:
# Jan 2022 my mucking about with code from mashume
# https://usethinkscript.com/threads/dr-wishs-black-green-dot-indicator-for-thinkorswim.8110/
# to include stuff from
# https://wishingwealthblog.com/2018/03/green-dot-strategy-defined/
# https://aaiidcmetro.com/slides/(2019-07-13)wish.pdf
# https://wishingwealthblog.com/glossary/





# -- 30 week avg for Dr Wish, one of the conditions for determining trend.  Stock should be above.
def agg = AggregationPeriod.WEEK;
def ThirtyWeek = close(period = agg);
plot wk30sma = Average(ThirtyWeek, 30);
wk30sma.setDefaultColor(color.light_green);
AddLabel(close > wk30sma, " Above 30wk sma ", color.green);
AddLabel(close < wk30sma, " Below 30wk sma ", color.pink);


# -- Red White and Blue exp avg ribbons
# -- Prefer seeing all red avgs as a ribbon with white chart background space above blue avgs ribbon.
# -- Strong pattern all avgs lined up with each above the next longer avg and the close leading them all higher.
# -- Red ribbons
plot Red3 = ExpAverage(close, 3);
Red3.setDefaultColor(color.pink);
plot Red5 = ExpAverage(close, 5);
Red5.setDefaultColor(color.pink);
plot Red8 = ExpAverage(close, 8);
Red8.setDefaultColor(color.pink);
plot Red10 = ExpAverage(close, 10);
Red10.setDefaultColor(color.pink);
plot Red12 = ExpAverage(close, 12);
Red12.setDefaultColor(color.pink);
plot Red15 = ExpAverage(close, 15);
Red15.setDefaultColor(color.pink);

# -- Blue ribbons
plot Blue30 = ExpAverage(close, 30);
Blue30.setDefaultColor(color.cyan);
plot Blue35 = ExpAverage(close, 35);
Blue35.setDefaultColor(color.cyan);
plot Blue40 = ExpAverage(close, 40);
Blue40.setDefaultColor(color.cyan);
plot Blue45 = ExpAverage(close, 45);
Blue45.setDefaultColor(color.cyan);
plot Blue50 = ExpAverage(close, 50);
Blue50.setDefaultColor(color.cyan);
plot Blue60 = ExpAverage(close, 60);
Blue60.setDefaultColor(color.cyan);

# -- close, prefer above the ribbons.
plot ClosePrice = close;
ClosePrice.setDefaultColor(color.white);
#ClosePrice.SetPaintingStrategy(paintingStrategy.Dashes);
ClosePrice.setLineWeight(2);

Only had this running a few days so not thoroughly tested.

Edit: Added in Green Line BreakOut extra from later posting, thanks lmk99.
2-6-2022 Also added in Labels for YearlyLow and percentage to current price.
@RickAns Thank you for the sharing!! May I know what timeframe is most suitable to use it on?
 
Thanks @8Nick8 glad you like it.

From reading through the docs on Dr. Wish's green dot / black dot seems to be geared to using daily charts and is how I focused the coding. This study is for riding strong multi-day (to weeks/months) trends. Not for scalping 1 to 5 minute moves during the day if that is what you are asking.

Unless you are asking for time frame as in number of days on the charts. Going by the charts present in the above linked documents I would say a daily chart with maybe 6 months worth of data. Dr. Wish mentions using a weekly chart to help gauge overall trend direction with his month-based green line breakout. He also references seeking out the yearly low. A year or two's worth on a separate weekly/ monthly chart for current trend guidance.

A popular saying on a stock market show I like to watch (TraderTVLive) is "When in doubt, zoom out." Basically, look to the left and see where the stock is coming from and where it's support / resistance levels were. They may likely be tested in the future. Anne-Marie Baiynd says something similar like 'Previous support can become current resistance and previous resistance can become current support.' I'm working on a mashup of a few of her strategies and thinking of posting it here sometime soon.

Hope this helps,
Rick
 
Last edited by a moderator:
Thanks @8Nick8 glad you like it.

From reading through the docs on Dr. Wish's green dot / black dot seems to be geared to using daily charts and is how I focused the coding. This study is for riding strong multi-day (to weeks/months) trends. Not for scalping 1 to 5 minute moves during the day if that is what you are asking.

Unless you are asking for time frame as in number of days on the charts. Going by the charts present in the above linked documents I would say a daily chart with maybe 6 months worth of data. Dr. Wish mentions using a weekly chart to help gauge overall trend direction with his month-based green line breakout. He also references seeking out the yearly low. A year or two's worth on a separate weekly/ monthly chart for current trend guidance.

A popular saying on a stock market show I like to watch (TraderTVLive) is "When in doubt, zoom out." Basically, look to the left and see where the stock is coming from and where it's support / resistance levels were. They may likely be tested in the future. Ann Marie Baynd likes to say something similar like 'Previous support can become current resistance and previous resistance can become current support.' I'm working on a mashup of a few of her strategies and thinking of posting it here sometime soon.

Hope this helps,
Rick
@RickAns have you seen the PGO indicator? it has the Dr. Wish' Green Dot indicator in it and ads a Purple and Orange dot for stocks moving out of consolidation on volume, this one paint price, i have been trying to modify it to just shoe dots but im stuck on the ergodic portion of the code
maybe you can figure it out?
PGO Indicator for ThinkorSwim
 
Last edited by a moderator:
What a great contribution. Thank you for sharing this. I had considered trying to do all of this myself after learning about the Dr. Wish system and watching him on YouTube but it would have been difficult for me and the end result likely wouldn't have been quite right.

The only other component from his system that I wanted to work on which is still missing is the green line breakout (the idea of buying at historical all time high after drawing a green line at the previous high that is broken above). Is it possible to code this line to stay intact as the previous all time high which has been broken one time? It's not clear to me how to code a condition like that while allowing the line to be persistent.
I don't know where the Green Line Breakout scan/code can be found but would sure appreciate some guidance finding it. It seems that the green line would be drawn only if you can measure at least a 3 month gap since the last high. The theory is to find stock that have rested as Dr Wish calls it or in IBD language, formed a base.
 

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

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
350 Online
Create Post

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