Black Dog System Indicator for ThinkorSwim - Strategy

BenTen

BenTen

Administrative
Staff
VIP
Attached is the Black Dog indicator for ThinkorSwim along with a strategy on how to use it. Black dog system is a trading strategy based on the moving averages (EMA) to plot the highs and lows band. I came across this while browsing the ThinkorSwim Yahoo group.



Some notes I found:

After reading through the Black Dog System literature, I came up with the following script that should be used ONLY for the 5 minute Time Frame. It uses and Exponential Moving Average (EMA) to plot the highs/lows band instead of the plain average. Yellowish and Blueish arrows are the SESs (Standard Entry Signal). Yellowish arrows for closes above the band and blueish arrows for closes below the band.

It plots WHITE Black Dogs, for both up and down crosses of the SLOW 100-period EMA by the Fast 20 period EMA instead of BLACK ones since I normally use a black background. These EMAs and their crosses are computed after changing the aggregation period to 20 minutes (4 times the base aggregation period of 5 minutes).

This script should be used only on 5 minute aggregation period charts. To use on a 15 or 60 minute chart, one should edit and rename this script and change the

Code:
def agg = AggregationPeriod.TWENTY_MIN;
line to

Code:
def agg = AggregationPeriod.HOUR;
or

Code:
def agg = AggregationPeriod.FOUR_HOURS;
There is not a 40-minute aggregation period constant for use with a 10-minute chart, but maybe one could use the "THIRTY_MIN" constant as a substitute.

thinkScript Code

Rich (BB code):
#   Black Dogs & SESs---For 5 minute chart ONLY
#   NAMED BlackDog_SES_5min

#   Here, "Black Dogs" are WHITE for use on a dark background.

input Hprice = high;
input Lprice = low;
input price = close;
input Hlength = 50;
input Llength = 50;
input Hdisplace = 0;
input Ldisplace = 0;

#   High / Low Band for SES computations---------------------------
#   EMA of HIGHS-----------------------------------------------------------
plot HAvg = MovAvgExponential(Hprice[-Hdisplace], Hlength);

HAvg.SetDefaultColor(Color.WHITE);
HAvg.SetLineWeight(5);
HAvg.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
HAvg.SetStyle(Curve.FIRM);
HAvg.HideBubble();
HAvg.HideTitle();

HAvg.AssignValueColor(if HAvg< HAvg[1] then Color.VIOLET else (if HAvg == HAvg[1] then Color.YELLOW else Color.YELLOW));

#   EMA of LOWS------------------------------------------------------------
plot LAvg = MovAvgExponential(Lprice[-Ldisplace], LLength);

LAvg.SetDefaultColor(Color.WHITE);
LAvg.SetLineWeight(5);
LAvg.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
LAvg.SetStyle(Curve.FIRM);
LAvg.HideBubble();
LAvg.HideTitle();

LAvg.AssignValueColor(if LAvg< LAvg[1] then Color.VIOLET else (if LAvg == LAvg[1] then Color.YELLOW else Color.YELLOW));

#   Crosses for SES Arrows----------------------------------------------
#   SES = Standard Entry Signal

#   Cross above High Average -----------------------------------------
def CrossUp = if price > HAvg AND price[1] < HAvg then 1 else 0;
Plot SESup = if CrossUp then high else double.nan;

SESup.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
SESup.SetLineWeight(3);
SESup.SetDefaultColor(color.YELLOW);
SESup.HideBubble();
SESup.HideTitle();

#   Cross above Low Average --------------------------------------------
def CrossDn = if price < Lavg AND price[1] > LAvg then 1 else 0;
Plot SESdn = if CrossDn then low else double.nan;

SESdn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
SESdn.SetLineWeight(3);
SESdn.SetDefaultColor(color.VIOLET);
SESdn.HideBubble();
SESdn.HideTitle();

#   ================================================
#
#    Black Dog Arrows------------------------------------------------------

#   Change Aggregation Period to 20 minutes------------------------
def agg = AggregationPeriod.TWENTY_MIN;
def data = close(period = agg);

#   2 EMAs of Black Dogs--------------------------------------------------
def BDfastEMA=ExpAverage(DATA,20);
def BDslowEMA=ExpAverage(DATA,100);

#   Black Dog UP for EMA20 crossing ABOVE EMA100-------------
def UpCross = if BDfastEMA > BDslowEma AND BDfastEMA[1] < BDslowEMA then 1 else 0;
Plot BDup = if UpCross then high else double.nan;

BDup.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
BDup.SetLineWeight(5);
BDup.SetDefaultColor(color.WHITE);
BDup.HideBubble();
BDup.HideTitle();

#   Black Dog DN for EMA20 crossing BELOW EMA100-----------
def DnCross = if BDfastEMA < BDslowEma AND BDfastEMA[1] > BDslowEMA then 1 else 0;
Plot BDdn = if DnCross then low else double.nan;

BDdn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
BDdn.SetLineWeight(5);
BDdn.SetDefaultColor(color.WHITE);
BDdn.HideBubble();
BDdn.HideTitle();

#   END==========================================

Shareable Link

http://tos.mx/EpbpY9

How to Trade the Black Dog System

Some info below was found via this page. It was written to trade Forex but the concept remains relevant for trading stocks and options.



When to Buy (long):
  • Price should be within the moving average channel
  • An arrow pointing up right below the candle
  • MACD rising to the positive territory or EMA crossover (find what works for you)
  • Stop loss should be below the recent swing low
When to Sell (short):
  • Price should be within the moving average channel
  • An arrow pointing down
  • MACD dive to the negative territory or EMA crossover (find what works for you)
  • Stop loss should be above the recent swing high
 
Last edited:
M

mikeraya

New member
BenTen I had a question about the system as it applies to TOS. Supposedly the channels will go neutral when the market is moving sideways. However, I dont think the system that you gave us for TOS indicates a neutral period. Can you verify if it does or not? Thank you.

Great site you have put together with all the info on it. A great service for traders.

 
Last edited:
BenTen

BenTen

Administrative
Staff
VIP
@mikeraya A neutral period would be when the candlesticks are in between the two lines.

 
Last edited:
T

Thanhly

New member
@BenTen hi im new here . Can you invite me to Discord.

 
Last edited:
T

Thanhly

New member
@BenTen do you ever heard about Volume forecast?

 
Last edited:
BenTen

BenTen

Administrative
Staff
VIP
@Thanhly This is the only thing I could find.

Rich (BB code):
#hint: Virtual Volume   
# Mr.Script 
#Explanation - Virtual Volume analyzes up to the second volume and displays the anticipated volume quantity for the day.
•    Example  - 6.5 hours in a trading day or 390 minutes or 23,400 seconds.  If I check the volume for a stock and we are 33 minutes or 1980 seconds into the trading day and volume is 537,500. The formula would be (23,400 x 537,500) / 1980 = 6,352,272.727 Virtual Volume.

declare hide_on_daily;
declare on_volume;

input OpenTime = 0930;
input closeTime = 1600;
input length = 10;
input averageType = AverageType.EXPONENTIAL;
assert(Opentime < 1200, "Open Time must be less than 1200");
assert(closetime > 1200, "close Time must be greater than 1200");

def volumeavg = MovingAverage(averageType, volume(period = aggregationPeriod.DAY), length);

def hoursa = floor(closetime/100); 
def hoursb = floor(opentime/100);
def hoursc = absValue(12 - hoursb) + hoursa - 12;
def hoursd = hoursc * 60 * 60;
def mina = ((closetime - ((floor(closetime/100)) * 100)) * 60);
def minb = ((opentime - ((floor(opentime/100)) * 100)) * 60);

def secondsperday = absValue(hoursd - (minb - mina));

def secondsPassed = secondsFromTime(OpenTime);

def a = if secondsPassed >= 0 and secondspassed <= (closetime * 60 * 60) then secondspassed else 0;

rec b = CompoundValue(1, if IsNaN(a) then b[1] else a, a);
def day = getDay();
def month = getMonth();
def year = getYear();
def lastDay = getLastDay();
def lastmonth = getLastMonth();
def lastyear = getLastYear();
def isToday = if(day == lastDay and month == lastmonth and year == lastyear, 1, 0);

def d = if istoday then b else double.nan;

def h = if secondsPassed >= 0 and secondspassed <= (closetime * 60 * 60) and close == close(period = aggregationPeriod.DAY) then secondspassed else 0;

def vol = if istoday then volume else 0;

rec index = compoundValue(1, index[1] + vol, 0);
plot "Cumulative Volume" = if secondsPassed >= 0 and secondsFromTime(closetime) <= 0 and istoday then index else double.nan;

def j = "cumulative volume";

def k = highestall(j);

def l = if j == k then secondspassed else double.nan;

def m = highestall(l);

def n = (secondsperday * k) / m;

addLabel(yes, concat("Virtual Volume: ", round(n, 0)), if (n > volumeavg) then Color.GREEN else color.RED);

addLabel(yes, concat(concat(length, " Day's"), concat(" Volume Avg: ", round(volumeavg, 0))),  if (n < volumeavg) then Color.GREEN else color.RED);

# end study code ---
 
Last edited:
M

mikeraya

New member
was wondering how effective this system is with equities. Seems like you rarely see a Black Dog Arrow. On a few of the equites I looked at if printed four black dogs in a row. So does it work that well with equities vs. forex? Seems like the black dogs shouldnt be printing four in a row. Curious. Thank you

 
Last edited:

Top