Stock Portfolio Organizer

The ultimate porfolio management solution.

Shares, Margin, CFD's, Futures and Forex
EOD and Realtime
Dividends and Trust Distributions
And Much More ....
For Portfolio Manager Click Here

WiseTrader Toolbox

#1 Selling Amibroker Plugin featuring:

Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
Find Out More Here

BB + TrendLines for Amibroker (AFL)

Rating:
4 / 5 (Votes 3)
Tags:
trendline, amibroker, bands

Another great AFL got from a friend.
This one Uses Bollinger Bands And TrendLines.
All Credit Goes to the Original Authors.
Results are Mind Blowing so suspect Future leak.

Indicator / Formula

Copy & Paste Friendly
SetPositionSize(1,spsShares);

_SECTION_BEGIN("BB TrendLines"); 
SetChartOptions(0,chartShowArrows|chartShowDates); 
if (ParamToggle("Candle Type","Heiken Ashi|Normal",0)) 
   { 
   HaClose = Close; 
   HaOpen = Open; 
   HaHigh = High; 
   HaLow = Low; 

   Color = colorBlack; 
} 
else 
   { 
   HACLOSE=(O+H+L+C)/4; 
   HaOpen = AMA( Ref( HaClose,  -1 ),  0.5 ); 
   HaOpen[0] = Open[0]; 
   HaHigh = Max( H,  Max( HaClose,  HaOpen ) ); 
   HaLow = Min( L,  Min( HaClose,  HaOpen ) ); 
   Halow[0] = Low[0]; 
    
   color = colorWhite; 
} 
PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, Name(), color, styleCandle ); 

xx=BarIndex(); 
x=xx; 
Lx=LastValue(x); 


ShowMini = ParamToggle("TrendLines","Don't Show|Show", 1); 

SetBarsRequired( sbrAll, sbrAll); 

Periods = Param( "BB Periods", 30, 1, 250, 1 ); 
Width = Param( "Width", 1, 0, 5, 0.1 ); 

npiv_Mini    = Param("Pivots to Extend TL",4,1,10,1); 

RespectAngle_Mini     = ParamToggle("Respect TrendLine Angles","No|Yes", 1); 
CleanPivots_Mini     = ParamToggle("Clean Pivots","No|Yes",0); 
showNonConfirmed_Mini = ParamToggle("Non Confirmed Pivots","Don't Show|Show", 0); 
showRelation_Mini     = ParamToggle("Show Pivots Relation","None|HH LH LH LL", 1); 

BBTOp = BBandTop( HaHigh, Periods, Width ); 
BBBot = BBandBot( HaLow, Periods, Width ); 

Plot( BBTop, "BBTop", colorBlue, styleLine ); 
Plot( BBBOt, "BBBot", colorBlue, styleLine ); 

Fundo_Mini = (Low <= BBBot); 
Pico_Mini  = (High >= BBTop); 


BI_Fundo_Mini = ValueWhen(Fundo_Mini, x, 0); 
BI_Pico_Mini  = ValueWhen(Pico_Mini , x, 0); 
    
Next_Pivot_Type = BI_Pico_Mini > BI_Fundo_Mini; 

Fundo_Mini = Fundo_Mini AND (Next_Pivot_Type==0 OR x==BI_Fundo_Mini); 
Pico_Mini  = Pico_Mini  AND (Next_Pivot_Type==1 OR x==BI_Pico_Mini); 

px1=ValueWhen(Pico_mini,x,1); tx1=ValueWhen(Fundo_mini,x,1); 

if (shownonconfirmed_Mini==0) 
   { 
   Pico_Mini  = Pico_Mini AND ( px1 < BI_Fundo_Mini); 
   Fundo_Mini = Fundo_Mini AND (tx1 < BI_Pico_Mini); 
} 


if(CleanPivots_mini) 
   { 
   px0=ValueWhen(Pico_mini,x,0); tx0=ValueWhen(Fundo_mini,x,0); 
   px2=ValueWhen(Pico_mini,x,2); tx2=ValueWhen(Fundo_mini,x,2); 
   ph0=ValueWhen(Pico_mini,HaHigh,0); tl0=ValueWhen(Fundo_mini,HaLow,0); 
   ph1=ValueWhen(Pico_mini,HaHigh,1); tl1=ValueWhen(Fundo_mini,HaLow,1); 
   ph2=ValueWhen(Pico_mini,HaHigh,2); tl2=ValueWhen(Fundo_mini,HaLow,2); 

   Pico_Mini = IIf((ph0>=ph1 AND tx0>px0 AND px0!=px1) OR (ph1<ph2 AND px2>tx1) OR (ph0>=ph1 AND tx0<px0 AND tx0==tx1 AND px0!=px1) 
      ,False,Pico_mini); 
   Fundo_Mini = IIf((tl0<=tl1 AND px0>tx0 AND tx0!=tx1) OR (tl1>tl2 AND tx2>px1) OR (tl0<=tl1 AND px0<tx0 AND px0==px1 AND tx0!=tx1) 
      ,False,Fundo_mini); 
} 


PlotShapes(shapeSmallCircle*Fundo_Mini,colorBrightGreen,0, HaLow,-10); 
PlotShapes(shapeSmallCircle*Pico_Mini,colorRed,0, HaHigh ,10); 

if (showRelation_mini) 
   { 
   if (NOT CleanPivots_mini) 
      { 
      ph0=ValueWhen(Pico_mini,HaHigh,0); tl0=ValueWhen(Fundo_mini,HaLow,0); 
      ph1=ValueWhen(Pico_mini,HaHigh,1); tl1=ValueWhen(Fundo_mini,HaLow,1); 
      ph2=ValueWhen(Pico_mini,HaHigh,2); tl2=ValueWhen(Fundo_mini,HaLow,2); 
   } 

   ll = Fundo_mini AND tl1 < tl2; 
   hl = Fundo_mini AND tl1 > tl2; 
   hh = Pico_mini    AND ph1 > ph2; 
   lh = Pico_mini    AND ph1 < ph2; 
   dt = Pico_mini    AND ph1 == ph2; 
   db = Fundo_mini   AND tl1 == tl2; 

   fvb = FirstVisibleValue( x ); 
   lvb = LastVisibleValue( x ); 

   for ( i = lvb;i > fvb;i-- ) 
   { 
      { 
         if ( ll[i] ) 
            PlotTextSetFont( "LL", "Arial Black", 8, i, HaLow[i], colorGreen, color, -30 ); 

         if ( hl[i] ) 
            PlotTextSetFont( "HL", "Arial Black", 8, i, HaLow[i], colorGreen, color, -30 ); 

         if ( db[i] ) 
            PlotTextSetFont( "DB", "Arial Black", 8, i+3, HaLow[i], colorGreen, color, -30 ); 

         if ( hh[i] ) 
            PlotTextSetFont( "HH", "Arial Black", 8, i, HaHigh[i], colorRed, color, 20 ); 

         if ( lh[i] ) 
            PlotTextSetFont( "LH", "Arial Black", 8, i, HaHigh[i], colorRed, color, 20 ); 

         if ( dt[i] ) 
            PlotTextsetFont( "DT", "Arial Black", 8, i+3, HaHigh[i], colorRed, color, 20 ); 
      } 
   } 
} 


if (ShowMini) 
   { 
   for (i=1;i<=npiv_mini;i++) 
   { 
     
      y0=ValueWhen(Fundo_mini,HaLow,i-1); 
      y1=ValueWhen(Fundo_mini,HaLow,i); 
      x0=ValueWhen(Fundo_mini,xx,i-1); 
      x1=ValueWhen(Fundo_mini,xx,i); 
      aa=(y0-y1)/(x0-x1); 
      ls1=aa*(xx-x1)+y1; 
      if (respectAngle_mini) 
         { 
         dls1=ls1-Ref(ls1,-1); 
         ls1=IIf(dls1<0,Null,ls1); 
      } 
      if(i==1) Plot(ls1,"",colorBrightGreen ,styleLine|styleDashed|styleNoRescale,0,0,0,1, width = 1); 
      if(i>1) 
      { 
         ls1=IIf(Fundo_mini,Null,ls1); 
         Plot(ls1,"",colorBrightGreen,styleNoRescale,0,0,0,1,width = 2); 
      } 
      y0=ValueWhen(Pico_mini,HaHigh,i-1); 
      y1=ValueWhen(Pico_mini,HaHigh,i); 
      x0=ValueWhen(Pico_mini,xx,i-1); 
      x1=ValueWhen(Pico_mini,xx,i); 
      aa=(y0-y1)/(x0-x1); 
      hs1=aa*(xx-x1)+y1; 
      if (respectAngle_mini) 
         { 
         dhs1=hs1-Ref(hs1,-1); 
         hs1=IIf(dhs1>0,Null,hs1); 
      } 
      if(i==1) Plot(hs1,"",colorRed,styleLine|styleDashed|styleNoRescale,0,0,0,1, width = 1); 
      if(i>1) 
      { 
         hs1=IIf(Pico_mini,Null,hs1); 
         Plot(hs1,"",colorRed,styleNoRescale,0,0,0,1, width = 2); 
      } 
   } 
       
} 


_SECTION_END(); 



11 comments

1. szgolyas

error:

PlotTextSetFont( “LL”, “Arial Black”, 8, i, HaLow[i], colorGreen, color, -30 );
2. jrajnikant

ERROR

3. eldertop

Signals are ultra looking forward, 20 day of retard.. ehehheheh beware cmq i post the corrections waiting the author

4. bsedoha

Error 30 at line 107.
Regards

5. LOVEENAJYOTHI

error:

PlotTextSetFont( “LL”, “Arial Black”, 8, i, HaLow[i], colorGreen, color, -30 );

@szgolyas
Ithink dat function works on v 5.71 n above, for lower versns, plz delete dat line or comment it out or substitute wid this line
PlotText( i, HaLow[i], colorGreen, color, -30 );

@jrajnikant & @bsedoha
wht r d errors ?

@eldertop
yes it looks into future, i hve alrdy notified it in description.
Plz fix it , i tried in vain only to bang my head in utter frustration , plz plz Plz fix it and help us all.
p.s. : don’t know who d author/s is/are.

6. jrajnikant

PlotTextSetFont( “LL”, “Arial Black”, 8, i, HaLow[i], colorGreen, color, -30 );

7. jrajnikant

ERROR

if ( lh[i] )
PlotText( i, HaHigh[i], colorRed, color, 20 );

8. koyickal

Replace them with…

       if ( ll[i] ) PlotText( "LL", i, HaLow[i], colorGreen);
        if ( hl[i] ) PlotText( "HL", i, HaLow[i], colorGreen);
        if ( db[i] ) PlotText( "DB", i+3, HaLow[i], colorGreen); 
        if ( hh[i] ) PlotText( "HH", i, HaHigh[i], colorRed ); 
        if ( lh[i] ) PlotText( "LH", i, HaHigh[i], colorRed ); 
        if ( dt[i] ) PlotText( "DT",  i+3, HaHigh[i], colorRed );

Thanks,

9. Atlasraketa

What sense?

10. vasudevanC

ERROR NOT SHOWN

11. vasudevanC

not working

Leave Comment

Please login here to leave a comment.

Back