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 ....
WiseTrader Toolbox
#1 Selling Amibroker Plugin featuring:
Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
pivot code for Amibroker (AFL)
Copy & Paste Friendly
Back
// Amibroker AFL code by Edward Pottasch, Jul 2013 x=BarIndex();Lx=LastValue(x); rightStrength=Param("Fractal Pivot Right side Strength",5,0,50,1); leftStrength=Param("Fractal Pivot Left side Strength",10,0,50,1); pk=H>Ref(HHV(H,leftStrength),-1) AND Ref(HHV(H,rightStrength),rightStrength)<=H; tr=L<Ref(LLV(L,leftStrength),-1) AND Ref(LLV(L,rightStrength),rightStrength)>=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); ll=tr AND tl1<tl2; hl=tr AND tl1>tl2; hh=pk AND ph1>ph2; lh=pk AND ph1<ph2; dt=pk AND ph1==ph2; db=tr AND tl1==tl2; lowLine=ValueWhen(Ref(ll OR hl,-rightStrength),Ref(L,-rightStrength)); highLine=ValueWhen(Ref(hh OR lh,-rightStrength),Ref(H,-rightStrength)); Buy=Cross(C,highLine);BuyPrice=C; Short=Cross(lowLine,C);ShortPrice=C; Buy=ExRem(Buy,Short); Short=ExRem(Short,Buy); Sell=Cover=0; GraphXSpace=5;SetChartBkColor(colorBlack);SetChartOptions(0,chartShowDates); SetBarFillColor(IIf(C>O,colorGreen,IIf(C<=O,colorRed,colorLightGrey))); Plot(C,"Last",IIf(C>O,colorDarkGreen,IIf(C<=O,colorDarkRed,colorLightGrey)),64,0,0,0,0); PlotShapes(shapeSmallCircle*tr,IIf(Lx-ValueWhen(tr,x)>=rightStrength,ColorRGB(0,100,0),colorWhite),0,L,-10); PlotShapes(shapeSmallCircle*pk,IIf(Lx-ValueWhen(pk,x)>=rightStrength,ColorRGB(255,0,0),colorWhite),0,H,10); Plot(lowLine,"",ColorRGB(100,0,0),1); Plot(highLine,"",ColorRGB(0,100,0),1); PlotShapes(IIf(Buy,shapeUpArrow,shapeNone),colorDarkGreen,0,L,-15); PlotShapes(IIf(Buy,shapeSmallCircle,shapeNone),colorWhite,0,BuyPrice,0); PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colorRed,0,H,-15); PlotShapes(IIf(Sell,shapeSmallCircle,shapeNone),colorWhite,0,SellPrice,0); PlotShapes(IIf(Short,shapeSmallDownTriangle,shapeNone),colorRed,0,H,IIf(Short AND Sell,-30,-15)); PlotShapes(IIf(Short,shapeSmallCircle,shapeNone),colorWhite,0,ShortPrice,0); PlotShapes(IIf(Cover,shapeSmallUpTriangle,shapeNone),colorDarkGreen,0,L,IIf(Cover AND Buy,-30,-15)); PlotShapes(IIf(Cover,shapeSmallCircle,shapeNone),colorWhite,0,CoverPrice,0);