Traders Laboratory - View Single Post - Heikin Ashi Trend Indicator
View Single Post
  #17 (permalink)  
Old 02-09-2007, 06:50 PM
nicknextmove nicknextmove is offline
nicknextmove has no status.

 
Join Date: Dec 2006
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Heikin Ashi Trend Indicator

This is the code for the 3 Bricks Reversal:

[LegacyColorValue = true]; {********************************************************* 3_LineBrk_V4 Modified 2/12/04 WAV added input to show/hide paintbars (true/false) added input to show/hide brk line (true/false) added input for BrkLine length alert once per bar only use: how to hide regular price bars ( format symbol, style, BarType to Line on Close or dot, color to chart background or similar ) ********************************************************** "3 Brick Reversal" Modified and Renamed 06/21/06 PatientTrader (Lonnie VanZandt) added TrendLine drawing to draw the tops and bottoms of the "bricks" cleaned up the Alert reporting added a vertical Trendline as the last PaintBar of a box prior to a new box, to close the box cleanly. The end result is visually identical to John Carter and Hubert's "TTM Bricks" indicator. I compared the transitions to those in "Mastering the Trade" and they appear to match. (Note that Figure 11.8 (@YM Daily) in that book does not match the 2006 data for @YM for Fourth Quarter 2006. Odd... } inputs: TrendWeight(2), ShowPB(True), UpColor(Cyan), DnColor(Red); vars: TrendLeading(-1), TrendTrailing(-1), LastPb(-1), LastHigh (0),LastLow(0),DrawColor(0), AlertTime(0); arrays: LineH[2](0), LineL[2](0), color[2](0); if BarNumber = 1 then begin LastHigh = h; LastLow = l; end; {-------------------------------------- handle first 3 lines separately ---------------------------------------} If BarNumber = 4 then begin for value1 = 0 to 2 begin if c[value1+1] > LastHigh then begin LineH[0] = c[value1+1]; LineL[0] = LastHigh; color[0] = UpColor; LastLow = LastHigh; LastHigh = c[value1+1]; end else if c[value1+1] < LastLow then begin LineL[0] = l[value1+1]; LineH[0] = LastLow; color[0] = DnColor; LastHigh = LastLow; LastLow = c[value1+1]; end; end; end else {-------------------------------------- long side ---------------------------------------} begin { see if close > high of last 3 lines } if c > MaxList(LineH[0],LineH[1],LineH[2]) then begin { see if last line was down color...if so then break } if color[2] = DnColor then begin if TL_Exist( TrendLeading ) then TL_SetEnd( TrendLeading, Date, Time, LineL[2] ); TrendLeading = TL_New( Date, Time, Close, Date, Time, Close ); TL_SetSize( TrendLeading, TrendWeight ); TL_SetColor( TrendLeading, UpColor ); if TL_Exist( TrendTrailing ) then TL_SetEnd( TrendTrailing, Date, Time, LineH[2] ); TrendTrailing = TL_New( Date, Time, LineH[2], Date, Time, LineH[2] ); TL_SetSize( TrendTrailing, TrendWeight ); TL_SetColor( TrendTrailing, UpColor ); if AlertTime <> time then begin AlertTime = time; alert("Brick Reversal Long Setup on " + GetSymbolName + "."); end; end else begin if TL_Exist( TrendLeading ) then TL_SetEnd( TrendLeading, Date, Time, LineH[2] ); TrendLeading = TL_New( Date, Time, Close, Date, Time, Close ); TL_SetSize( TrendLeading, TrendWeight ); TL_SetColor( TrendLeading, UpColor ); if TL_Exist( TrendTrailing ) then TL_SetEnd( TrendTrailing, Date, Time, LineL[2] ); TrendTrailing = TL_New( Date, Time, LineH[2], Date, Time, LineH[2] ); TL_SetSize( TrendTrailing, TrendWeight ); TL_SetColor( TrendTrailing, UpColor ); end; for value1 = 0 to 1 begin LineH[value1] = LineH[value1+1]; LineL[value1] = LineL[value1+1]; color[value1] = color[value1+1]; end;{for value1} LineH[2] = c; LineL[2] = LastHigh; LastLow = LastHigh; LastHigh = c; color[2] = UpColor; DrawColor = UpColor; LastPb = TL_New( Date, Time, LineH[1], Date, Time, LineL[1] ); TL_SetSize( LastPb, 1 ); TL_SetColor( LastPb, color[1] ); end else begin {-------------------------------------- short side ---------------------------------------} { see if close < low of last 3 lines } if c < MinList(LineL[0],LineL[1],LineL[2]) then begin { see if last line was up color...if so then break } if color[2] = UpColor then begin if TL_Exist( TrendLeading ) then TL_SetEnd( TrendLeading, Date, Time, LineH[2] ); TrendLeading = TL_New( Date, Time, Close, Date, Time, Close ); TL_SetSize( TrendLeading, TrendWeight ); TL_SetColor( TrendLeading, DnColor ); if TL_Exist( TrendTrailing ) then TL_SetEnd( TrendTrailing, Date, Time, LineL[2] ); TrendTrailing = TL_New( Date, Time, LineL[2], Date, Time, LineL[2] ); TL_SetSize( TrendTrailing, TrendWeight ); TL_SetColor( TrendTrailing, DnColor ); if AlertTime <> time then begin AlertTime = time; alert( "Brick Reversal Short Setup on " + GetSymbolName + "."); end; end else begin if TL_Exist( TrendLeading ) then TL_SetEnd( TrendLeading, Date, Time, LineL[2] ); TrendLeading = TL_New( Date, Time, Close, Date, Time, Close ); TL_SetSize( TrendLeading, TrendWeight ); TL_SetColor( TrendLeading, DnColor ); if TL_Exist( TrendTrailing ) then TL_SetEnd( TrendTrailing, Date, Time, LineH[2] ); TrendTrailing = TL_New( Date, Time, LineL[2], Date, Time, LineL[2] ); TL_SetSize( TrendTrailing, TrendWeight ); TL_SetColor( TrendTrailing, DnColor ); end; for value1 = 0 to 1 begin LineH[value1] = LineH[value1+1]; LineL[value1] = LineL[value1+1]; color[value1] = color[value1+1]; end;{for value1} LineL[2] = c; LineH[2] = LastLow; LastHigh = LastLow; LastLow = c; color[2] = DnColor; DrawColor = DnColor; LastPb = TL_New( Date, Time, LineH[1], Date, Time, LineL[1] ); TL_SetSize( LastPb, 1 ); TL_SetColor( LastPb, color[1] ); end else begin if ( DrawColor = UpColor ) then begin if TL_Exist( TrendLeading ) then TL_SetEnd( TrendLeading, Date, Time, LineH[2] ); if TL_Exist( TrendTrailing ) then TL_SetEnd( TrendTrailing, Date, Time, LineL[2] ); end else begin if TL_Exist( TrendLeading ) then TL_SetEnd( TrendLeading, Date, Time, LineL[2] ); if TL_Exist( TrendTrailing ) then TL_SetEnd( TrendTrailing, Date, Time, LineH[2] ); end; end; end; end; if ShowPB then begin Plot1(LineH[2], "LineHigh",DrawColor); Plot2(LineL[2], "LineLow" ,DrawColor); end;

Reply With Quote