[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] code for pivot points on the selected day -- is there a space forimprovement?



PureBytes Links

Trading Reference Links

hello everyone,

I would like to plot the pivot points on the intraday chart for the day 
which one of the bars is selected. I wrote the following code but it is 
slow. I realise that the lower intraday interval, the slower code works, 
but maybe there is some space for improvement for this AFL code or 
different approach which would fasten its excecution?

any help would be appreciated,
cheers
BM


Plot(C,"",colorBlack,styleCandle);

b = DateNum()!=Ref(DateNum(),-1);
s = SelectedValue(DateNum());
p = SelectedValue(ValueWhen(b,Ref(DateNum(),-1),1));

sd = DateNum() == s;
pd = DateNum() == p;

pdH = LastValue(Highest(pd*H));
pdL = LastValue(Lowest(IIf(pd,pd*L,pdH+1)));
pdC = LastValue(ValueWhen(b,Ref(C,-1),1));

PP = (pdC+pdL+pdH)/3;
R1 = 2*PP-pdL;
S1 = 2*PP-pdH;
R2 = PP+R1-S1;
S2 = PP-R1+S1;
S3 = 2*(PP-pdH)+pdL;
R3 = 2*(PP-pdL)+pdH;

PlotShapes( IIf(sd, shapeSmallCircle, shapeNone), colorBlueGrey,  1, PP, 0);
PlotShapes( IIf(sd, shapeSmallCircle, shapeNone), colorDarkRed,   1, R1, 0);
PlotShapes( IIf(sd, shapeSmallCircle, shapeNone), colorDarkGreen, 1, S1, 0);
PlotShapes( IIf(sd, shapeSmallCircle, shapeNone), colorRed,       1, R2, 0);
PlotShapes( IIf(sd, shapeSmallCircle, shapeNone), colorGreen,     1, S2, 0);
PlotShapes( IIf(sd, shapeSmallCircle, shapeNone), colorOrange,    1, R3, 0);
PlotShapes( IIf(sd, shapeSmallCircle, shapeNone), colorTeal,      1, S3, 0);


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/