Breadth Ratio Study for Think or Swim

This is a follow up to the breadth code that I posted a couple of weeks ago. You might have noticed from the diagram there was an extra study that I hadn't published. That study is the Breadth Ratio code. The code is very similar to the Breadth code except instead of plotting $UVOL/$DVOL we are plotting $UVOL/$TVOL.

$UVOL-$DVOL for 7/20/10 - 7/22/10

The following study plots the breadth ratio ($UVOL/$TVOL) for the Think or Swim trading platform. If the breadth ratio is above 80% then we have a bullish market. If it is below 20% then the market is bearish. If we are in the middle that usually indicates a choppy day.  So you can see on Tuesday we started off choppy and then took off in the afternoon. $UVOL-$DVOL was just chopping around in the morning, but you could see a rise in the Breadth and the Breadth Ratio that gave a hint of things to come. On Wednesday nothing happened until Ben Bernanke gave his little speach. And Friday, the market just kept on going and going. Note that the Breadth Ratio was pegged at 90 most of the day.

I'm publishing this under a Creative Commons license, so you can use it freely based on the agreement below.

Creative Commons License
Breadth Indicator by Delta Latitude is licensed under a Creative Commons Attribution 3.0 Unported License.
Based on a work at

#hint:atbBreathRatio\nPlots breadth ratio on lower axis\n(c) 2010 Deltalatitude, LLC
# This work is licensed under the Creative
# Commons Attribution 3.0 Unported License.
# To view a copy of this license, visit
# or send a letter to Creative Commons,
# 171 Second Street, Suite 300,
# San Francisco, California, 94105, USA.
#hint Exchange:Select NYSE or NASDAQ

declare lower;

input exchange = {default NYSE, NASDAQ};
input upper = 80;
input lower = 20;

def up;
def total;

switch (exchange) {
case NYSE:
up = close("$UVOL");
total = close("$TVOL");
case NASDAQ:
up = close("$UVOL/Q");
total = close("$TVOL/Q");

plot breadth = up/total * 100;

def positive = breadth > breadth[1];

breadth.SetPaintingStrategy(PaintingStrategy.LINE, yes);
breadth.DefineColor("Positive", Color.GREEN);
breadth.DefineColor("Negative", Color.RED);
breadth.AssignValueColor(if positive
then breadth.color("Positive") else breadth.color("Negative"));

plot us=upper;
us.DefineColor("Upper", Color.LIGHT_GRAY);

plot ls=lower;
ls.DefineColor("Lower", Color.LIGHT_GRAY);

 Good luck trading.

No comments: