# EminiAddict.com # # MARKETBREADTH # http://www.thinkscripter.com # thinkscripter@gmail.com # Last Update 21 Jan 2009 ######################################################################### # BWD_MarketBreadth ToS Study # # Author: BigWaveDave (dopdahl). # Version: 1.1 # Release Date: 6/26/12 # Email me with bugs: dopdahl@gmail.com # No guarantees as to accuracy expressed or implied # Use at your own discretion # # Changes for v. 1.1 # ====================== # + Added option to abbreviate label text # # I wanted to find a better way to see the daily trend in breadth. # Since the trend is more important than the actual value, I normalized # breadth to be zero-based instead of 1-based to make the chart easier to # read. I also used gradient coloring to give some sense of the strength # of the current trend in breadth. # # If you just want a breadth label with no chart, unselelct 'show plot' in the settings # And click the 'Move Up' button as necessary to get this study in the upper chart. declare lower; # Display Adv/Decl ratio, Issues, volumeratio or volume input DisplayValue = {ADIssuesRatio, ADIssues, default ADVolumeRatio, ADVolume}; input Market = {default NYSE, NASDAQ, BOTH}; input AbbreviateText = {default "No", "Yes"}; input ShowChartLabels = {"No", default "Yes"}; # This value determines whether or not we normalize to zero.. mainly for ease of reading the trend input NormalizeToZeroLine = {"No", default "Yes"}; input DisplayZeroLine = {"No", default "Yes"}; # number of bars to look backward to determine trendNoiseBalance strength input TrendStrengthLength = 5; DefineGlobalColor("NYSEPos", Color.GREEN); DefineGlobalColor("NYSENeg", Color.RED); DefineGlobalColor("NASDAQPos", Color.BLUE); DefineGlobalColor("NASDAQNeg", Color.DARK_ORANGE); def advancing = close("$advn"); def declining = close("$decn"); def advVolume = close("$uvol"); def decVolume = close("$dvol"); def Normalize; def IsRatio; def Breadth; switch (DisplayValue) { case ADIssuesRatio: Breadth = If(advancing > declining, (advancing / declining), (-declining / advancing)); Normalize = NormalizeToZeroLine; IsRatio = 1; case ADIssues: Breadth = advancing - declining; Normalize = 0; IsRatio = 0; case ADVolume: Breadth = advVolume - decVolume; Normalize = 0; IsRatio = 0; case ADVolumeRatio: Breadth = If( advVolume > decVolume, (advVolume / decVolume), (-decVolume / advVolume)); Normalize = NormalizeToZeroLine; IsRatio = 1; } def advancing2 = close("$advn/q"); def declining2 = close("$decn/q"); def advVolume2 = close("$uvol/q"); def decVolume2 = close("$dvol/q"); def Breadth2; switch (DisplayValue) { case ADIssuesRatio: Breadth2 = If(advancing2 > declining2, (advancing2 / declining2), (-declining2 / advancing2)); case ADIssues: Breadth2 = advancing2 - declining2; case ADVolume: Breadth2 = advVolume2 - decVolume2; case ADVolumeRatio: Breadth2 = If( advVolume2 > decVolume2, (advVolume2 / decVolume2), (-decVolume2 / advVolume2)); } def ShowNYSE; switch (Market) { case NYSE: ShowNYSE = 1; case NASDAQ: ShowNYSE = 0; case BOTH: ShowNYSE = 1; } plot NYSEPlot = If (ShowNYSE, If (Normalize, If (Breadth >= 1, Breadth - 1, Breadth + 1), If ((Breadth >= 1 and Breadth[1] < 1) or (Breadth < 1 and Breadth[1] >= 1), Double.NaN, Breadth)), Double.NaN); # Remove comment below to enable non-gradient color painting and add comment to 2nd line down #value.AssignValueColor(if Breadth >= 0.0 then globalColor("NYSEPos") else globalColor("NYSENeg")); NYSEPlot.AssignNormGradientColor(TrendStrengthLength, GlobalColor("NYSENeg"), GlobalColor("NYSEPos")); NYSEPlot.SetPaintingStrategy(PaintingStrategy.LINE); NYSEPlot.SetLineWeight(1); def ShowNASDAQ; switch (Market) { case NYSE: ShowNASDAQ = 0; case NASDAQ: ShowNASDAQ = 1; case BOTH: ShowNASDAQ = 1; } plot NASDAQPlot = If (ShowNASDAQ, If (Normalize, If (Breadth2 >= 1, Breadth2 - 1, Breadth2 + 1), If ((Breadth2 >= 1 and Breadth2[1] < 1) or (Breadth2 < 1 and Breadth2[1] >= 1), Double.NaN, Breadth2)), Double.NaN); # Remove comment below to enable non-gradient color painting and add comment to 2nd line down #value2.AssignValueColor(if Breadth2 >= 0.0 then globalColor("NASDAQ") else globalColor("NASDAQNeg")); NASDAQPlot.AssignNormGradientColor(TrendStrengthLength, GlobalColor("NASDAQNeg"), GlobalColor("NASDAQPos")); NASDAQPlot.SetPaintingStrategy(PaintingStrategy.LINE); NASDAQPlot.SetLineWeight(1); plot ZeroLine = If (DisplayZeroLine, 0.0, Double.NaN); ZeroLine.SetDefaultColor(Color.DARK_GRAY); ZeroLine.SetPaintingStrategy(PaintingStrategy.LINE); ZeroLine.SetStyle(Curve.SHORT_DASH); def LabelBreadth = (If (!AbbreviateText, Breadth, Round(Breadth, 2))); # Now for the chart labels AddLabel(ShowChartLabels and ShowNYSE, Concat(LabelBreadth, Concat(if !AbbreviateText and IsRatio then ":1" else "", " NYSE")), if Breadth > Breadth[1] then GlobalColor("NYSEPos") else GlobalColor("NYSENeg")); def LabelBreadth2 = (If (!AbbreviateText, Breadth2, Round(Breadth2, 2))); AddLabel(ShowChartLabels and ShowNASDAQ, Concat(LabelBreadth2, Concat(if !AbbreviateText and IsRatio then ":1" else "", " NASDAQ")), if Breadth2 > Breadth2[1] then GlobalColor("NASDAQPos") else GlobalColor("NASDAQNeg"));