Welcome to the Traders Laboratory Forums.
Trading Indicators Post your custom trading indicators. If you download, remember to click INSTALL.

Reply
Fast BB MACD Details »»
Fast BB MACD
Platform: , by simterann22 simterann22 is offline
Developer Last Online: Jan 2012 Show Printable Version Email this Page

Platform: Tradestation Rating:
Released: 06-30-2009 Last Update: Never Installs: 5
 
No support by the author.

Here is a fast MACD using a Hull Moving Average and a Fractal Moving Average. The FastMACD dots change color when they breach outside their Bollinger Bands (which you can't see).

I have taken from other coder's work, so full credit goes to them. I have simply added the faster MAs and incorporated the BBs. This indicator came about just by experimenting. So try an idea out......you never know

It seems to pick the highs and lows nicely. I have coded it with a standard MACD so I can see divergences. You are quite welcome to add or remove anything and post it if you think it has merit.

The indicator also has a gapless code added which will take into account opening gaps on intraday charts. I use this with Blu-Ray's Paintbars (Similar to the Heikin Ashi), Double Stochastics and The Gapless Squeeze (here):

http://www.traderslaboratory.com/for...html#post68059


Here is the code:

Code:
{**************FMA Function******************}
//  generates very smooth and responsive moving average
// 	copyright 2008 John McCormick
//	feel free to copy and use this code royalty free 
//  as long as you don't remove the above acknowledgement
//		

Inputs: 
	Price(numericseries), 
	Length(numericsimple);

Vars:
	j(0),
	workinglen(maxlist(1,absvalue(Length))),
	peak(workinglen/3),
	tot(0),
	divisor(0);

Array:
val[100](0);

if workinglen>100 then workinglen=100;  //  use larger array to handle lengths over 100


tot=0;
divisor=0;
for j=1 to floor(workinglen+1) begin
	if j<=peak then val[j]=j/peak
	else val[j]=(workinglen+1-j)/(workinglen+1-peak);
	tot=tot+price[j-1]*val[j];
	divisor=divisor+val[j];
end;
if divisor<>0 then FMA_smooth=tot/divisor;
Code:
{jtHMA - Hull Moving Average Function}
{Author: Atavachron}
{May 2005}		
	
Inputs: price(NumericSeries), length(NumericSimple);
Vars: halvedLength(0), sqrRootLength(0);

{
 Original equation is:
 ---------------------
 waverage(2*waverage(close,period/2)-waverage(close,period), SquareRoot(Period)
 Implementation below is more efficient with lengthy Weighted Moving Averages.
 In addition, the length needs to be converted to an integer value after it is halved and
 its square root is obtained in order for this to work with Weighted Moving Averaging
}

if ((ceiling(length / 2) - (length / 2))  <= 0.5) then
	halvedLength = ceiling(length / 2)
else
	halvedLength = floor(length / 2);

if ((ceiling(SquareRoot(length)) - SquareRoot(length))  <= 0.5) then
	sqrRootLength = ceiling(SquareRoot(length))
else
	sqrRootLength = floor(SquareRoot(length));

Value1 = 2 * WAverage(price, halvedLength);
Value2 = WAverage(price, length);
Value3 = WAverage((Value1 - Value2), sqrRootLength);

jtHMA = Value3;
Code:
{***************FastMACD Function**********************

inputs: 
	Price( numericseries ), 
	FastLength( numericsimple ), { this input assumed to be a constant >= 1 }
	SlowLength( numericsimple ) ; { this input assumed to be a constant >= 1 }

MACD_HMA_FMA = jthma( Price, FastLength ) - FMA_smooth( Price, SlowLength ) ;


{ ** Copyright (c) 2001 - 2009 tradestation Technologies, Inc. All rights reserved. ** 
  ** tradestation reserves the right to modify or overwrite this analysis technique 
     with each release. ** }
Code:
{******************FastMACD Indicator*************}

inputs:
	
price(close),
fastlength (12),
slowlength (26),
signal (9),
BBstDv(1),	
DirColor(True),
BBColorUp(White),
BBColorDn(Magenta),
ZeroColor(DarkCyan);

	
VARS:
	BB_Macd(0),
	MyMACD(0),
	Avg(0),
	SDev(0),
	Alert_Msg(" "),
	Upper_Band(0),
	Lower_Band(0),
	BBColor(0),      
    Cross_Up(False),
	Cross_Dn(False);  

// gapless day transitions - John McCormick May 2008
	
Vars:
	RelO(0),		// Relative Open
	RelH(0),		// Relative High
	RelL(0),		// Relative low
	RelC(0),		// Relative Close
	gap(0),			// the opening gap (modified by the gap coefficient)
	GapCoef(1.0),	// Gap Coefficient
	Accum(0);		// The sum of all the daily gaps

if currentsession(0)<>currentsession(0)[1] or date<>date[1] then 
  begin
	gap=GapCoef*(O-C[1]);
	Accum=Accum+gap;   
  end;

if BarType<=1 then  //Valid only for Tick or Intraday	 
	
	begin

		RelO	=	O-Accum;
		RelC	=	C-Accum;
		RelH	=	H-Accum;
		RelL	=	L-Accum;

		end

		else begin

		RelO	=	O;
		RelC	=	C;
		RelH	=	H;
		RelL	=	L;
	
	end;

// Gapless - end

Var: GL_Price(0);

GL_price = RelC;
If Price=open then GL_price = RelO;
If Price=high then GL_price = RelH;
If Price=low then GL_price = RelL;



BB_Macd = FMA_smooth(MACD_HMA_FMA(GL_price, FastLength, SlowLength),3)*0.5 ;//added xaverage to smooth 'bumps'
MyMACD = MACD( GL_price, FastLength, SlowLength )*1.5 ;
//Avg  = FMA_smooth( BB_Macd, Signal);
Avg = XAverage( MyMACD,Signal ) ;
SDev = StandardDev( BB_Macd, Signal, 1);

Upper_Band = ( Avg + BBStDv * SDev );
Lower_Band = ( Avg - BBStDv * SDev );

//******************************************************//
//     Sub-Graph plot logic.                            //
//******************************************************//
	
if DirColor=True then
	
begin
	

	
   If BB_Macd > BB_Macd[1] then BBColor = BBColorUp else BBColor = BBColorDn;

   If Cross_Up = False then if BB_Macd > Upper_Band then begin
      Cross_Up = True;  
      Cross_Dn = False;  
      BBColor = Cyan;	
	  If CheckAlert then Alert( "BB cross up " + Alert_Msg );
      end;   
 
   If Cross_Dn = False then if BB_Macd < Lower_Band then begin
      Cross_Up = False;  
      Cross_Dn = True;  
      BBColor = Yellow;
	  If CheckAlert then Alert( "BB cross down " + Alert_Msg );
      end;

 
    Plot1( BB_Macd, "BBMACD" ,BBColor );
	Plot2(Avg, "Signal",Cyan); 
 
   	Plot4( 0, "Zero_Line", ZeroColor );
 	Plot3(MyMACD, "MACD", green,2);
    end
else
	setplotcolor(1,green);

Download Now

File Type: eld @SK_FAST_MACDBB.ELD (10.3 KB, 187 views)

Screenshots

Fast BB MACD-fast-macdbb.jpg  

Show Your Support

  • If you like to thanks you by the author -> Click Thanks to the Author
  • This modification may not be copied, reproduced or published elsewhere without the author's permission.
The Following 7 Users Say Thank You to simterann22 For This Useful Post:
aaa (07-05-2009), addvalue (12-27-2009), berrob (10-24-2011), RickAce (07-17-2009), shrike (07-01-2009), soulman (07-01-2009), Tams (06-30-2009)

Comments
Old 07-01-2009, 08:11 AM   #2

shrike's Avatar

Join Date: Jun 2009
Location: fantasy
Posts: 85
Ignore this user

Thanks: 44
Thanked 24 Times in 22 Posts

Re: Fast BB MACD

hi
i found this error :
Unknown Function
errLine 74, errColumn 10, errLineEnd 74, errColumnEnd 20

refer to FMA_smooth , i 've insert fma function and compile well
shrike is offline  
Reply With Quote
The Following User Says Thank You to shrike For This Useful Post:
jemko (10-03-2009)
Old 07-01-2009, 04:08 PM   #3

Join Date: Jun 2009
Location: Seattle
Posts: 63
Ignore this user

Thanks: 8
Thanked 18 Times in 16 Posts

Re: Fast BB MACD

Great ta, thx allot. Is like what I have come up with for MACD primary trading indicator, but did not have the dots....this dot version works great on the crosses in scalping!!!.....great work...thanks...
ajax358 is offline  
Reply With Quote
The Following User Says Thank You to ajax358 For This Useful Post:
simterann22 (07-01-2009)
Old 07-01-2009, 05:05 PM   #4

shrike's Avatar

Join Date: Jun 2009
Location: fantasy
Posts: 85
Ignore this user

Thanks: 44
Thanked 24 Times in 22 Posts

Re: Fast BB MACD

hi

make some change now works thanks again
shrike is offline  
Reply With Quote
Old 07-01-2009, 06:41 PM   #5

simterann22's Avatar

Join Date: May 2009
Location: Sydney
Posts: 64
Ignore this user

Thanks: 42
Thanked 51 Times in 20 Posts

Re: Fast BB MACD

I've updated the code to :

*Show crossing of BB's more accurately and to plot the correct BB lines if you so wish (you will however have to 'uncomment' the plots out to show them though). The BB lines were plotted off the standard MACD instead of the FastMACD in V1, but since I do not use the indicator this way I had not noticed.

*Allow the 'non directional plot' to work ie. if you do not want the white and magenta directional dots, they will appear green. Of course the colors are mostly hard-coded in EL for simplicity but you can easily change them if you wish to do so.

*Fixed the alert.

Please let me know if you know of any more bugs or any new ways to improve this indicator. Cheers.

Code:
{************************sk_FastMACD_Gapless*********************}
{************************Simterann22 2009************************}	
inputs:
	
price(close),
fastlength (12),
slowlength (26),
signal (9),
BBstDv(1),	
DirColor(True),
BBColorUp(White),
BBColorDn(Magenta),
ZeroColor(DarkCyan);

	
VARS:
	BB_Macd(0),
	MyMACD(0),
	Avg(0),
	AvgBB(0),
	SDev(0),
	Alert_Msg(" "),
	Upper_Band(0),
	Lower_Band(0),
	BBColor(0),      
    Cross_Up(False),
	Cross_Dn(False);  

// gapless day transitions - John McCormick May 2008
	
Vars:
	RelO(0),		// Relative Open
	RelH(0),		// Relative High
	RelL(0),		// Relative low
	RelC(0),		// Relative Close
	gap(0),			// the opening gap (modified by the gap coefficient)
	GapCoef(1.0),	// Gap Coefficient
	Accum(0);		// The sum of all the daily gaps

if currentsession(0)<>currentsession(0)[1] or date<>date[1] then 
  begin
	gap=GapCoef*(O-C[1]);
	Accum=Accum+gap;   
  end;

if BarType<=1 then  //Valid only for Tick or Intraday	 
	
	begin

		RelO	=	O-Accum;
		RelC	=	C-Accum;
		RelH	=	H-Accum;
		RelL	=	L-Accum;

		end

		else begin

		RelO	=	O;
		RelC	=	C;
		RelH	=	H;
		RelL	=	L;
	
	end;

// Gapless - end

Var: GL_Price(0);

GL_price = RelC;
If Price=open then GL_price = RelO;
If Price=high then GL_price = RelH;
If Price=low then GL_price = RelL;



BB_Macd = FMA_smooth(MACD_HMA_FMA(GL_price, FastLength, SlowLength),3)*0.5 ;//added FMA_smooth to smooth 'bumps'
MyMACD = MACD( GL_price, FastLength, SlowLength )*1.5 ;//Standard MACD
Avg  = XAverage( MyMACD, Signal);//Plotted standard MACD signal
AvgBB = XAverage( BB_Macd,Signal ) ;//Average for FastMACD, not plotted
SDev = StandardDev( BB_Macd, Signal, 1);

Upper_Band = ( AvgBB + BBStDv * SDev );
Lower_Band = ( AvgBB - BBStDv * SDev );
	
if DirColor=True then
	
begin
	

	
   If BB_Macd > BB_Macd[1] then BBColor = BBColorUp else BBColor = BBColorDn;

   If Cross_Up = False then if BB_Macd > Upper_Band then begin
      Cross_Up = True;  
      Cross_Dn = False;  
      BBColor = Cyan;	
	  Alert( "BB cross up ");
      end;   
 
   If Cross_Dn = False then if BB_Macd < Lower_Band then begin
      Cross_Up = False;  
      Cross_Dn = True;  
      BBColor = Yellow;
	  Alert( "BB cross down ");
      end;
	Plot1( BB_Macd, "BBMACD" ,BBColor );
end
else begin
	Plot1( BB_Macd, "BBMACD" ,Green);
end;
   
	
 
Plot2(Avg, "Signal",Cyan,1); 
Plot3(MyMACD, "MACD", Green,2);
Plot4( 0, "Zero_Line", ZeroColor );
//Plot5(Upper_Band,"Upper Band",Red,1);
//Plot6(Lower_Band,"Lower Band",Red,1);
Attached Files
File Type: eld @SK_FAST_MACDBB_V2.ELD (10.5 KB, 123 views)
simterann22 is offline  
Reply With Quote
The Following 3 Users Say Thank You to simterann22 For This Useful Post:
berrob (10-24-2011), shrike (07-01-2009), Tams (07-01-2009)
Old 07-01-2009, 08:21 PM   #6

simterann22's Avatar

Join Date: May 2009
Location: Sydney
Posts: 64
Ignore this user

Thanks: 42
Thanked 51 Times in 20 Posts

Re: Fast BB MACD

Here's something pretty cool IMHO.....

Just add:

Code:
//Squeeze Input
SQLength(20),
nKeltner(1.5), 
nBBands(2), 
AlertLine( 1);
under your FastMACD inputs. (Remember to change the semicolon after 'zerocolor' to a comma (,).

Then add below your FastMACD code:

Code:
Vars:
	
SDevSQ(0),ATR(0),LHMult(0),Denom(0),BBS_Ind(0);
	
if ( barnumber=1 ) then 
	Begin
	  If minmove <> 0 then
	    LHMult = pricescale/minmove;
	end;

	
	ATR = AvgTrueRangeGL(SQLength);
	SDevSQ = StandardDev(RelC, SQLength, 1);

	Denom = (nKeltner*ATR);
	If Denom <> 0 then BBS_Ind = (nBBands * SDevSQ) /Denom; 

	If BBS_Ind < Alertline then
	  SetPlotColor(1, Red);
then press F3 to compile.

This turns the FastMACD dots to red if a BB Squeeze is happening ie. when the BBs are inside the Keltner Channels. So when it turns red look for chop and slowing of volatility. When it exits red along with an increase in the distance between the dots you may be looking at a decent move. You can change the squeeze length, BB and KC settings to suit your taste.

Edit: In order for this to work you will need to install the Gapless Squeeze http://www.traderslaboratory.com/for...html#post68059, because you'll need the AvgTrueRangeGL function. If you don't want to bother then just change AvgTrueRangeGL to AvgTrueRange (although it won't be as accurate for session gaps).

Last edited by simterann22; 07-01-2009 at 08:27 PM.
simterann22 is offline  
Reply With Quote
The Following User Says Thank You to simterann22 For This Useful Post:
Tams (07-01-2009)
Old 07-01-2009, 09:07 PM   #7

Tams's Avatar

Join Date: Sep 2008
Location: Geelong
Posts: 3,779
Ignore this user

Thanks: 2,084
Thanked 1,477 Times in 912 Posts

Re: Fast BB MACD

Quote:
Originally Posted by simterann22 »
Here's something pretty cool IMHO.....

Just add:

Code:
//Squeeze Input
SQLength(20),
nKeltner(1.5), 
nBBands(2), 
AlertLine( 1);
under your FastMACD inputs. (Remember to change the semicolon after 'zerocolor' to a comma (,).

...


one small EasyLanguage programming note:

you can have more than ONE input section.

i.e. if you add the following after the first input section, you don't have to worry about changing the semi-colon.


//Squeeze Input
INPUT:
SQLength(20),
nKeltner(1.5),
nBBands(2),
AlertLine( 1);
Tams is offline  
Reply With Quote
The Following User Says Thank You to Tams For This Useful Post:
simterann22 (07-01-2009)
Old 07-01-2009, 09:57 PM   #8

simterann22's Avatar

Join Date: May 2009
Location: Sydney
Posts: 64
Ignore this user

Thanks: 42
Thanked 51 Times in 20 Posts

Re: Fast BB MACD

Hi Tams,

yeah......I just cut and shut and learn as I go.

If it works it works......but I do like to improve my coding all the time......so appreciate it. Cheers.
simterann22 is offline  
Reply With Quote

Reply

Tags
bollinger band, macd

Thread Tools
Help Others By Rating This Thread
Help Others By Rating This Thread:


Similar Threads
Thread Thread Starter Forum Replies Last Post
FAST BUCKS: How Porsche Made Billions taq Trading Videos 3 07-03-2011 03:13 AM
Screaming Fast Moving Average Minetoo Trading Indicators 47 04-10-2011 12:46 PM
Poker & Fast Intra-Session Trading UrmaBlume Technical Analysis 18 02-04-2009 02:01 AM
Is Ninja/Zen Fast Enough for EMini Futures Trading Khepfere Futures Trading Laboratory 15 11-23-2008 09:37 AM
Reg NMS - Fast Fills on NYSE? The Bear Stock Trading Laboratory 0 03-10-2007 06:39 PM

All times are GMT -4. The time now is 08:08 AM.
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
CS to VB integration by DeskLancer
©2006-2011 Traders Laboratory, All Rights Reserved.