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

new for Amibroker (AFL)

Copy & Paste Friendly
_SECTION_BEGIN("Trendlines Multitimeframe");

// Amibroker AFL code by Edward Pottasch, 6/8/2011

// Using fractals to create automatic trendlines

// Using option to show multiple timeframes

Version(5.21);

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

nbar=Param("N Pivot Bars",3,2,50,1); 

tf=Param("Time Frame (min)",5,1,100000,1);tfrm=in1Minute*tf;

CleanPivots=ParamToggle("Use Clean Pivots","Off|On",0);

PivotSymmetry=ParamToggle("Use Symmetric Pivots","Off|On",0);

tld=ParamToggle("All trendlines","Show|Hide",1);

showSignals=ParamToggle("Display signals","Off|On",0);

TimeFrameSet(tfrm); 

if (PivotSymmetry)

{

	fc=1;

	pk=H>Ref(HHV(H,nbar*fc),-1) AND Ref(HHV(H,nbar),nbar)<=H;

	tr=L<Ref(LLV(L,nbar*fc),-1) AND Ref(LLV(L,nbar),nbar)>=L;

}

else

{

	fc=2;

	pk=H>Ref(HHV(H,nbar*fc),-1) AND Ref(HHV(H,nbar),nbar)<=H;

	tr=L<Ref(LLV(L,nbar*fc),-1) AND Ref(LLV(L,nbar),nbar)>=L;

}

px0=ValueWhen(pk,x,0); tx0=ValueWhen(tr,x,0);

px1=ValueWhen(pk,x,1); tx1=ValueWhen(tr,x,1);

px2=ValueWhen(pk,x,2); tx2=ValueWhen(tr,x,2);

ph0=ValueWhen(pk,H,0); tl0=ValueWhen(tr,L,0);

ph1=ValueWhen(pk,H,1); tl1=ValueWhen(tr,L,1);

ph2=ValueWhen(pk,H,2); tl2=ValueWhen(tr,L,2);

if (CleanPivots)

{

tr=IIf(pk AND tr AND ph1>ph2 AND tl1>tl2,False,tr);

pk=IIf(pk AND tr AND ph1<ph2 AND tl1<tl2,False,pk);

px0=ValueWhen(pk,x,0); tx0=ValueWhen(tr,x,0);

px1=ValueWhen(pk,x,1); tx1=ValueWhen(tr,x,1);

px2=ValueWhen(pk,x,2); tx2=ValueWhen(tr,x,2);

ph0=ValueWhen(pk,H,0); tl0=ValueWhen(tr,L,0);

ph1=ValueWhen(pk,H,1); tl1=ValueWhen(tr,L,1);

ph2=ValueWhen(pk,H,2); tl2=ValueWhen(tr,L,2);

pk=IIf(pk AND px1>tx1 AND ph1<tl1,False,pk);

tr=IIf(tr AND tx1>px1 AND tl1>ph1,False,tr);

pk=IIf(pk AND px0<tx0 AND ph0>ph1,False,pk);

tr=IIf(tr AND px0>tx0 AND tl0<tl1,False,tr);

pk=IIf(pk AND px2>tx1 AND ph1<=ph2,False,pk);

tr=IIf(tr AND tx2>px1 AND tl1>=tl2,False,tr);

pk=IIf(pk AND px0>px1 AND px1>tx1 AND px1>tx0 AND ph0>ph1,False,pk);

tr=IIf(tr AND tx0>tx1 AND tx1>px1 AND tx1>px0 AND tl0<tl1,False,tr);

px0=ValueWhen(pk,x,0); tx0=ValueWhen(tr,x,0);

px1=ValueWhen(pk,x,1); tx1=ValueWhen(tr,x,1);

px2=ValueWhen(pk,x,2); tx2=ValueWhen(tr,x,2);

ph0=ValueWhen(pk,H,0); tl0=ValueWhen(tr,L,0);

ph1=ValueWhen(pk,H,1); tl1=ValueWhen(tr,L,1);

ph2=ValueWhen(pk,H,2); tl2=ValueWhen(tr,L,2);

pk=IIf(pk AND px1>tx1 AND ph1<tl1,False,pk);

tr=IIf(tr AND tx1>px1 AND tl1>ph1,False,tr);

pk=IIf(pk AND px0<tx0 AND ph0>ph1,False,pk);

tr=IIf(tr AND px0>tx0 AND tl0<tl1,False,tr);

pk=IIf(pk AND px2>tx1 AND ph1<=ph2,False,pk);

tr=IIf(tr AND tx2>px1 AND tl1>=tl2,False,tr);

pk=IIf(pk AND px0>px1 AND px1>tx1 AND px1>tx0 AND ph0>ph1,False,pk);

tr=IIf(tr AND tx0>tx1 AND tx1>px1 AND tx1>px0 AND tl0<tl1,False,tr);

px0=ValueWhen(pk,x,0); tx0=ValueWhen(tr,x,0);

px1=ValueWhen(pk,x,1); tx1=ValueWhen(tr,x,1);

px2=ValueWhen(pk,x,2); tx2=ValueWhen(tr,x,2);

ph0=ValueWhen(pk,H,0); tl0=ValueWhen(tr,L,0);

ph1=ValueWhen(pk,H,1); tl1=ValueWhen(tr,L,1);

ph2=ValueWhen(pk,H,2); tl2=ValueWhen(tr,L,2);

pk=IIf(pk AND px1>tx1 AND px2>tx1 AND ph1<ph2,False,pk);

tr=IIf(tr AND tx1>px1 AND tx2>px1 AND tl1>tl2,False,tr);

}

pkh=IIf(pk,H,Null);

trl=IIf(tr,L,Null);

TimeFrameRestore();

fact=Max(tfrm/60,Interval()/60)/(Interval()/60);

Lkbk=tfrm/Interval();

if(Lkbk>1)

{

	pk=TimeFrameExpand(pk,tfrm,expandFirst); 

	pkh=TimeFrameExpand(pkh,tfrm,expandFirst);

	pkhs=IIf(!IsEmpty(pkh),1,0);pkhs=pkhs-Ref(pkhs,-1);

pk=pk AND H==pkh;

	cond1=Sum(pk,BarsSince(pkhs==1)+1)==1 AND pk;

pk=pk AND cond1;



	tr=TimeFrameExpand(tr,tfrm,expandFirst); 

	trl=TimeFrameExpand(trl,tfrm,expandFirst);

	trls=IIf(!IsEmpty(trl),1,0);trls=trls-Ref(trls,-1);

tr=tr AND L==trl;

	cond1=Sum(tr,BarsSince(trls==1)+1)==1 AND tr;

tr=tr AND cond1;



	px0=ValueWhen(pk,x,0); tx0=ValueWhen(tr,x,0);

	px1=ValueWhen(pk,x,1); tx1=ValueWhen(tr,x,1);

	px2=ValueWhen(pk,x,2); tx2=ValueWhen(tr,x,2);

	ph0=ValueWhen(pk,H,0); tl0=ValueWhen(tr,L,0);

	ph1=ValueWhen(pk,H,1); tl1=ValueWhen(tr,L,1);

	ph2=ValueWhen(pk,H,2); tl2=ValueWhen(tr,L,2);

}

y0=ValueWhen(tr,trl,0); 

y1=ValueWhen(tr,trl,1);

y2=ValueWhen(tr,trl,2);

y3=ValueWhen(tr,trl,3);

x0=ValueWhen(tr,xx,0);

x1=ValueWhen(tr,xx,1);

x2=ValueWhen(tr,xx,2);

x3=ValueWhen(tr,xx,3);

aa=(Y0-Y1)/(X0-X1);

ls1=aa*(xx-X1)+Y1;

dls1=ls1-Ref(ls1,-1);

aa=(Y1-Y2)/(X1-X2);

ls2=aa*(xx-X1)+Y1;

dls2=ls2-Ref(ls2,-1);

dls2=IIf(tr,Ref(dls1,-1),dls2);

aa=(Y2-Y3)/(X2-X3);

ls3=aa*(xx-X2)+Y2;

dls3=ls3-Ref(ls3,-1);

dls3=IIf(tr,Ref(dls2,-1),dls3);

y0=ValueWhen(pk,pkh,0); 

y1=ValueWhen(pk,pkh,1);

y2=ValueWhen(pk,pkh,2);

y3=ValueWhen(pk,pkh,3);

x0=ValueWhen(pk,xx,0);

x1=ValueWhen(pk,xx,1);

x2=ValueWhen(pk,xx,2);

x3=ValueWhen(pk,xx,3);

aa=(Y0-Y1)/(X0-X1);

hs1=aa*(xx-X1)+Y1;

dhs1=hs1-Ref(hs1,-1);

aa=(Y1-Y2)/(X1-X2);

hs2=aa*(xx-X1)+Y1;

dhs2=hs2-Ref(hs2,-1);

dhs2=IIf(pk,Ref(dhs1,-1),dhs2);

aa=(Y2-Y3)/(X2-X3);

hs3=aa*(xx-X2)+Y2;

dhs3=hs3-Ref(hs3,-1);

dhs3=IIf(pk,Ref(dhs2,-1),dhs3);

if (tld)

{

	dd=0.0;

	Vh=dd*(ValueWhen(pk,C)-ValueWhen(pk,Ref(C,-1)))/ValueWhen(pk,C);

	Vl=dd*(ValueWhen(tr,C)-ValueWhen(tr,Ref(C,-1)))/ValueWhen(tr,C);

	ls1=IIf(dls1>=Vl,ls1,Null);

	ls2=IIf(dls2>=Vl,ls2,Null);

	ls3=IIf(dls3>=Vl,ls3,Null);

	hs1=IIf(dhs1<=Vh,hs1,Null);

	hs2=IIf(dhs2<=Vh,hs2,Null);

	hs3=IIf(dhs3<=Vh,hs3,Null);

}

ls2a=IIf(BarsSince(tr)<=nbar*fact,ls2,Null);

ls2b=IIf(BarsSince(tr)>nbar*fact,ls2,Null);

ls3=IIf(BarsSince(tr)<=nbar*fact,ls3,Null);

hs2a=IIf(BarsSince(pk)<=nbar*fact,hs2,Null);

hs2b=IIf(BarsSince(pk)>nbar*fact,hs2,Null);

hs3=IIf(BarsSince(pk)<=nbar*fact,hs3,Null);

_SECTION_END();

_SECTION_BEGIN("Chart Colors");

SetChartBkColor(ParamColor("Background Color",ColorRGB(0,0,0)));

SetChartOptions(0,chartShowDates);

SetBarFillColor(IIf(C>O,ParamColor("Candle UP Color", colorGreen),IIf(C<=O,ParamColor("Candle Down Color", colorRed),colorLightGrey)));

Plot(C,"Price",IIf(C>O,ParamColor("Wick UP Color", colorDarkGreen),IIf(C<=O,ParamColor("Wick Down Color", colorDarkRed),colorLightGrey)),64,0,0,0,0);

Plot(pkh,"",colorRed,styleThick,0,0,0,-1);

Plot(trl,"",colorBrightGreen,styleThick,0,0,0,-1); 

PlotShapes(shapeSmallCircle*tr,IIf(Lx-ValueWhen(tr,x)>nbar*fact,ColorRGB(0,100,0),colorWhite),0,L,-10);

PlotShapes(shapeSmallCircle*pk,IIf(Lx-ValueWhen(pk,x)>nbar*fact,ColorRGB(255,0,0),colorWhite),0,H,10);

Plot(ls1,"\nLower Trendline",colorBrightGreen,styleLine|styleNoRescale,0,0,0,-1);

 

 

 

 

 

 

 

 

Buy1 = trl ;

Sell1 = pkh ;



PlotShapes(IIf(Buy1, shapeUpArrow, shapeNone),colorGreen, 0,L, Offset=-45); 

PlotShapes(IIf(Sell1 , shapeDownArrow, shapeNone),colorRed, 0,H, Offset=-45); 

 

 

 

OPBUYA = ValueWhen( Buy1 , C * (100/100)) ; 

OPSELLA = ValueWhen( Sell1 , C * (100/100)) ; 

 

BUYO = OPBUYA > O OR OPBUYA < O OR OPBUYA == O ;

SELLO = OPSELLA > O OR OPSELLA < O OR OPSELLA == O ;

BUYO = ExRem ( BUYO , Buy1 ) ;

SELLO = ExRem ( SELLO , Sell1 );

 

PlotShapes(BUYO * shapeCircle, colorGreen ,0 ,L , OFFSET= -45);

PlotShapes(SELLO * shapeCircle, colorRed , 0 , H , OFFSET = 45);

 

Buyt=ValueWhen(Buyo ,H,1);

Sellt=ValueWhen(Sello ,L,1);

 

Buy=Cross(H,Buyt);

Short=Cross(Sellt,L);

 

Buy = ExRem(Buy , BUYO );

Short = ExRem(Short, SELLO );

 

 

 

 

Buyexit = ValueWhen( Buy1 ,L / (99.95/100)) ; 

Plot( Buyexit ,"", colorBlueGrey ,styleLine,styleNoLabel );

Shortexit = ValueWhen( Sell1 , H * (99.95/100)) ; 

Plot( Shortexit ,"", ColorRGB(200,150,200),styleLine,styleNoLabel );

 

Sell = Cross ( Buyexit , L ) ;

Cover = Cross ( H ,Shortexit) ;

Sell = ExRem(Sell , Buy );

Cover = ExRem(Cover , Short);

 

 

 

 

BuyTGT = ValueWhen( BUYO ,H/ (99/100)) ; 

//Plot( BuyTGT ,"", colorBlueGrey ,styleThick );
 
ShortTGT = ValueWhen( SELLO , L* (99/100)) ; 

//Plot( ShortTGT ,"", ColorRGB(200,150,200),styleThick );
 
 

Plot(BuyTGT ,"",colorCustom7,styleNoLabel|8); //styleNoRescale|

Plot(ShortTGT ,"",colorCustom12,styleNoLabel|8);

BuyTGTDONE = Cross(H,BuyTGT );

ShortTGTDONE = Cross(ShortTGT ,L);

 

BuyTGTDONE = ExRem(BuyTGTDONE , Buy );

ShortTGTDONE = ExRem(ShortTGTDONE , Short );

 

PlotShapes(BuyTGTDONE * shapeHollowCircle, colorBlue ,0 ,H , OFFSET= 15);

PlotShapes(ShortTGTDONE * shapeHollowCircle, colorRed , 0 , L , OFFSET = -15);

 

 

 

PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);

PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50); 

PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45); 

PlotShapes(IIf(Short , shapeSquare, shapeNone),colorRed, 0, H, Offset=40);

PlotShapes(IIf(Short , shapeSquare, shapeNone),colorOrange, 0,H, Offset=50); 

PlotShapes(IIf(Short , shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);

 

 

 

Filter= Buy OR Short ; 

SetSortColumns(- 2 ) ;

AddColumn( IIf(Buy , 66,IIf (Short ,83,660000)),"INTRA", formatChar ,colorBlue,colorWhite);

AddColumn(Close,"Close",1.2);

_SECTION_BEGIN("Sound Alert");

AlertIf( Buy, "SOUND C:\\Windows\\Media\\Chord.wav", "Sell " + C,2,1+2,1);

AlertIf( Short , "SOUND C:\\Windows\\Media\\tada.wav","Buy " + C,1,1+2,1);
Back