Welcome Features News Download Registration Support FAQ Wish list Links
Advanced stock charting and analysis program

AFL Library

This is read-only version of AFL library entry. Ability to add user formulas and comment is only available from members-only area.

Details:

Formula name: Market Breadth Chart-In-Chart
Author/Uploader: Jorgen Wallgren - jorgen.wallgren [at] gmail.com
Date/Time added: 2009-04-07 05:05:49
Origin: S&C Traders' Tips Issue 12/2005, in the article "Overhauling Market Breadth" by Jacobus R. van den Brink a transformation of Arms index that makes it more useful for everyday trading is presented. Ori
Keywords: Market Breadth chart-in-chart Gfx
Level: medium
Flags: indicator

DISCLAIMER: Most formulas present in AFL on-line library are submitted by the users and are provided here on an "as is" and "as available" basis. AmiBroker.com makes no representations or warranties of any kind to the contents or the operation of material presented here. We do not maintain nor provide technical support for 3rd party formulas.
Description:

In order to save chart space, I created this gfx code which gives a \"chart-in-chart\" feature. Drag and drop this file into your price chart and adjust the location and size of this chart. Since this indicator is decribed in an article with copyright, for usage please refer to the original article which can be purchased at http://traderscom.stores.yahoo.net/stcov236ovma.html for US$3.95.
Unless you are using IQFeed, remember to adjust the below symbols which are data-source dependent!

Formula:

_SECTION_BEGIN("Market Breadth Chart-In-Chart");
// S&C Traders' Tips Issue 12/2005, in the article "Overhauling Market Breadth"
by Jacobus R. van den Brink 
// a transformation of Arms index that makes it more useful for everyday
trading is presented.
// Original AB code by Tomasz Janeczko, AmiBroker.
// 
// In order to save chart space, I created this gfx code which gives a
"chart-in-chart" feature. Drag and drop 
// this file into your price chart and adjust the location and size of this
chart.
// Since this indicator is decribed in an article with copyright, for usage
please refer to the original article 
// which can be purchased at
http://traderscom.stores.yahoo.net/stcov236ovma.html for US$3.95.
// Unless you are using IQFeed, remember to adjust the below symbols which are
data-source dependent!

Title = "";
//=====================================================================================================================
// THE GFX CALCULATIONS AND PLOTTING. MARKET DATA IN THE DATA MODULE.
//=====================================================================================================================
NMBOnOff		 	= ParamToggle("Market Breadth Chart","Off|On", 1);
Market 			= ParamList("Market", "NASDAQ 100|NASDAQ COMP|NYSE|SnP500", 1); 
MainChartWidth 	= Status("pxchartwidth");
MainChartHeight 	= Status("pxchartheight");
Font				= ParamList("Font:","Arial|Calibri|Futura|Tahoma|Times New Roman", 0);
ChartColor			= ParamColor("Background Color", colorWhite); 
X_Location	 		= Param("X Location", 50, 1, MainChartWidth, 1); 
Y_Location	 		= Param("Y Location", 100, 1, MainChartHeight, 1); 
ChartWidth	 		= Param("Chart Width", 365, 1, MainChartWidth, 1); 
ChartHeight		= Param("Chart height", 300, 1, MainChartHeight, 1); 
BarsToDisplay		= Param("Bars To Display", 80, 24, 390, 1); 
TimeFrameOnOff	= ParamToggle("Time Frame","Off|On", 1);
TimeFrame			= Param("Set Time Frame", 5, Interval()/60, 60, 1);

function BrinTransform( x ) 
{ 
 return ( 1 - x )/Max( 1, x ); 
} 

if(NMBOnOff)
{
 dnvol = upvol = advn = decl = UnCh = TotI = uptick = dntick = 0;
 // data-source dependent symbols: 
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// DATA-SOURCE DEPENDENT SYMBOLS.
// THESE SYMBOLS ARE FOR IQFEED. CHECK WITH YOUR DATA
// PROVIDER THE SYMBOLS FOR:
// dnvol = Issues Volume Down
// upvol = Issues Volume Up
// advn  = Issuse Up
// decl  = Issues Down
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

 if(Market == "NASDAQ 100")
 {
  dnvol	= Foreign("VI5D.Z", "C");  
  upvol	= Foreign("VI5A.Z", "C"); 
  advn 	= Foreign("II5A.Z", "C" ); 
  decl 	= Foreign("II5D.Z", "C"); 
 }

 if(Market == "NASDAQ COMP")
 {
  dnvol	= Foreign("DIQD.Z", "C"); 
  upvol	= Foreign("DIQA.Z", "C"); 
  advn 	= Foreign("IIQA.Z", "C" ); 
  decl 	= Foreign("IIQD.Z", "C"); 
 }

 if(Market == "NYSE")
 {
  dnvol	= Foreign("DIND.Z", "C"); 
  upvol	= Foreign("DINA.Z", "C"); 
  advn 	= Foreign("IINA.Z", "C" ); 
  decl 	= Foreign("IIND.Z", "C"); 
 }

 if(Market == "SnP500")
 {
  dnvol	= Foreign("VI6D.Z", "C"); 
  upvol	= Foreign("VI6A.Z", "C"); 
  advn 	= Foreign("II6A.Z", "C" ); 
  decl 	= Foreign("II6D.Z", "C"); 
 }
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 if(TimeFrame <  Interval()/60)
	TimeFrame = Interval()/60;

 if(TimeFrameOnOff)
	TF = TimeFrame;
 else
 	TF = Interval()/60;

 TimeFrameSet(TF * in1Minute);
 TFTrinx 	= (dnvol/ upvol ) * ( advn / decl ); 
 TFBRINx 	= BrinTransform(TFTrinx); 
 TFILine 	= BrinTransform((advn/decl)^2 ); 
 TFVLine 	= BrinTransform((dnvol/upvol)^2 ); 
 TimeFrameRestore();

 // THE LOW_LEVEL GRAPHICS FOR THE CHART:
// GfxSetOverlayMode(Transparent);
 x1Chart = X_Location; 
 y1Chart = Y_Location;
 x2Chart = X_Location + ChartWidth; 
 y2Chart = Y_Location + ChartHeight;

 // THE PLOT AREA:
 HeightPercent 	= 0.05;
 CellHeight 		= (HeightPercent * ChartHeight/2);
 RightMargin 		= 0.05;
 UpperLimit		= y1Chart + ((HeightPercent + 0.01) * ChartHeight);
 LowerLimit		= y1Chart + ((1 - HeightPercent - 0.01) * ChartHeight);
 LeftLimit 		= x1Chart + 1;
 RightLimit		= X_Location + (ChartWidth	 * (1 - RightMargin));

 // Draw the Chart Area:
 GfxSelectPen(colorBlack); 
 GfxSelectSolidBrush(ChartColor); 
 GfxRectangle(x1Chart, y1Chart, x2Chart, y2Chart);

 // Draw lines, where some text/time will be located:
 GfxMoveTo(LeftLimit, y1Chart + (HeightPercent * ChartHeight));
 GfxLineTo(RightLimit	, y1Chart + (HeightPercent * ChartHeight)); 
 GfxMoveTo(LeftLimit, y1Chart + ((1 - HeightPercent) * ChartHeight));
 GfxLineTo(RightLimit	, y1Chart + ((1 - HeightPercent) * ChartHeight)); 

 // Add the headline- which Index used:
 GfxSelectFont(Font, CellHeight); 
 GfxSetTextColor(colorBlack);
 DisplayText = Market + ":   BRIN = " + NumToStr(TFBRINX, 1.4, 0) + ", ILine =
" + NumToStr(TFILine, 1.4, 0) + ", VLine = " + 
				NumToStr(TFVLine, 1.4, 0) + " | (" + NumToStr(TF, 1.0, 0) + "-min)";
 GfxDrawText(DisplayText, x1Chart + 2, y1Chart, X_Location + ChartWidth,
y1Chart + (HeightPercent * ChartHeight), 32 + 4); 

 // Draw the limit lines:
 GfxSelectPen(colorLightGrey, 1); 
 GfxMoveTo(LeftLimit, UpperLimit); 
 GfxLineTo(RightLimit, UpperLimit);
 GfxMoveTo(LeftLimit, LowerLimit); 
 GfxLineTo(RightLimit, LowerLimit);

 // Draw the zero line:
 GfxSelectPen(colorBlack, 1);
 GfxMoveTo(LeftLimit, (UpperLimit + LowerLimit) / 2);
 GfxLineTo(RightLimit, (UpperLimit + LowerLimit) / 2);

 // THE ACTUAL PLOTTING:
  BarWidth = (RightLimit - LeftLimit) / BarsToDisplay;
}

function VerticalPosition(Value)
{
 if(Value >= 0)
   YPosition = UpperLimit + ((((UpperLimit + LowerLimit) / 2) - UpperLimit) *
(1-Value));
 else
 	YPosition = ((UpperLimit + LowerLimit) / 2) + ((((UpperLimit + LowerLimit) /
2) - UpperLimit) *  abs(Value));
 return YPosition;
}

procedure PlotGfx(Value, PlotColor, Position)
{
 YPosition1 = VerticalPosition(Value[BarCount-1-Position]);
 YPosition2 = VerticalPosition(Value[BarCount-1-Position-1]);
 GfxSelectPen(PlotColor, 1);
 GfxMoveTo(RightLimit - (BarWidth* Position), YPosition1 );
 GfxLineTo(RightLimit - (BarWidth* (Position+1)), YPosition2  );
} 

if(NMBOnOff)
{
 for(i = 0; i < BarsToDisplay; i++)
 {
  PlotGfx(TimeFrameCompress(TFBRINx, TF * in1Minute), colorBlack, i);
  PlotGfx(TimeFrameCompress(TFILine, TF * in1Minute), colorRed, i);
  PlotGfx(TimeFrameCompress(TFVLine, TF * in1Minute), colorBrightGreen, i);

  GfxSelectPen(colorBlack, 1);
  GfxMoveTo(RightLimit - (BarWidth * i), y1Chart + ((1 - HeightPercent) *
ChartHeight));
  GfxLineTo(RightLimit - (BarWidth * i), LowerLimit + ChartHeight * 0.03);
 }
}
_SECTION_END();

Comments:

Brian

2009-04-11 23:36:46
This did not work for me. I use yahoo data. What version of amibroker is required for this to work?
Jorgen Wallgren
jorgen.wallgren [at] gmail.com
2009-04-13 11:53:41
Brian, since you are using Yahoo data did you change the data-source dependent symbols as described in the file? If not, that will explain your problem. If you did, please describe what didn\\\'t work?
Thomas Ludwig

2009-05-04 07:02:32
Very nice, Jorgen. A good template that can be modified very easily.
Jorgen Wallgren
jorgen.wallgren [at] gmail.com
2009-05-09 22:55:09
Thank you very much Thomas!


About | Privacy | Terms of Use | Contact information
Copyright © 2001 AMIBROKER.COM