I want to plot up and down arrow on buy and sell signal.
I had written below code
for(i = 0;i < BarCount; i++)
_TRACE(“Buy is True” + i);
PlotShapes(shapeSquare,colorWhite, 0, L, Offset=40);
PlotShapes(shapeSquare,colorWhite, 0,L, Offset=50);
PlotShapes(shapeSquare,colorWhite, 0,L, Offset=60);
PlotShapes(shapeDownArrow,colorGreen, 0,L, Offset=-50);
I can see the shapes are getting plotted on all the bar.
Can someone please explain what is happening?
secondly is there any way by which we can get the co-ordinates of current bar
You are using it wrong. Read the manual http://www.amibroker.com/f?plotshapes
There are correct usage examples in the manual
PlotShapes is ARRAY function and its first argument is ARRAY. If you pass scalar as you do you tell it “plot shape EVERY BAR”.
PlotShapes plots shapes FOR ALL BARS in single call.
Correct usage is without the loop:
PlotShapes(Buy * shapeSquare,colorWhite, 0, L, Offset=40);
PlotShapes(Buy * shapeSquare,colorWhite, 0,L, Offset=50);
PlotShapes(Buy * shapeSquare,colorWhite, 0,L, Offset=60);
PlotShapes(Buy * shapeDownArrow,colorGreen, 0,L, Offset=-50);
As instructed in the manual.
Did you notice PLURAL form Plot SHAPES. It plots SHAPES, not single shape.
Almost every AFL function works on ARRAY AT ONCE with single call processing EVERY BAR so you do NOT NEED LOOPS. Read this http://www.amibroker.com/guide/h_understandaflhtml
Thanks @Tomasz, it really help.
hello every one
i want to plot shape on candle at particular date and time provided in afl formula I request seniors to help.
@amit05101992 for daily data something like this might help you.
Identify the dates you are interested in,
dn = DateNum();
Condition1 = ( dn == 1150707 ) OR ( dn == 1150730 ) OR ( dn == 1150807 );
Condition2 = ( dn == 1150709 ) OR ( dn == 1150728 ) OR ( dn == 1150811 );
Then plot the shapes and their positions,
PlotShapes(IIf(Condition1, shapeCircle, IIf(Condition2, shapeSquare, shapeNone)),
IIf(Condition1, colorWhite, colorLightBlue), 0,
IIf(Condition1, H, L),
IIf(Condition1, 15, -15));
If you are looking for Intra-day, sorry I do not day-trade so can't help with the different uses of DateTime and it's proper use/formatting.