how to draw a vertical line . for example i want to draw vertical line after 10 trading days from 1-jan -2017 .
please guide
@adimehta One partial solution already posted on this forum,
///@link http://forum.amibroker.com/t/how-to-draw-or-plot-vertical-line-grid-x-to-right-of-specified-bar-example-highest-bar/600/2
// vertical line at all time high
AllTimeHigh = High == LastValue( Highest( High ) );
Plot( C, "Price", colorDefault, styleCandle );
Plot( AllTimeHigh, "", colorBlue, styleHistogram | styleOwnScale, 0, 1 );
Another possible method to get you started,
// Vertical Line 2
bars = Param( "Bars since last day ", 10, 0, 50, 1 );
// Define Vertical line
Line1 = Cum( 1 ) == LastValue( Cum( 1 ) ) - bars;
Plot( C, "close", colorAqua, styleCandle );
Plot( Line1, "Line is ( " + WriteVal( bars, 1 ) + " ) bars back", colorLightBlue, styleHistogram | styleThick | styleOwnScale );
That produces a chart like this with a Parameter that can allow you to choose the number of bars back from last bar.
@adimehta Why not use the forum search option first? You can find some ready to use examples here: How do I plot a vertical line on an intraday chart at the open?
Sir I want to draw a vertical line at every peak and trough . I tried to code it like ..
pr = Param( "ZigZag change amount", 2.618, 0.05, 20, 0.05 );
pk = PeakBars( H, pr ) == 0;
tr = TroughBars( L, pr ) == 0;
Plot( pk, "", colorBlue, styleHistogram | styleOwnScale, 0, 1 );
Plot( tr, "", colorBlue, styleHistogram | styleOwnScale, 0, 1 );
but its plotting small histogram on every bar at the bottom of the chart.
What mistake i am doing? please help
Create a fresh Blank chart and add code with the Default Price.afl and check.
Its supposed to draw full vertical lines, maybe other code in the afl is interfering.
I'm getting full vertical lines.
thanks for the reply. yes some of my code was interfering. solved it. thanks
Your code is incomplete or incorrect. It needs at least one Plot()
without styleOwnScale
.
styleOwnScale
should only be used when there are other normal charts.
So if there are no other normal Plot()
s use this:
pr = Param( "ZigZag change amount", 2.618, 0.05, 20, 0.05 );
pk = PeakBars( H, pr ) == 0;
tr = TroughBars( L, pr ) == 0;
Plot( pk, "", colorBlue, styleHistogram ); // without styleOwnScale
Plot( tr, "", colorBlue, styleHistogram);
or if you want to use styleOwnScale
there must be other chart that does NOT use that.
Plot( C, "Price", colorDefault, styleCandle ); // NORMAL chart without styleOwnScale !
pr = Param( "ZigZag change amount", 2.618, 0.05, 20, 0.05 );
pk = PeakBars( H, pr ) == 0;
tr = TroughBars( L, pr ) == 0;
Plot( pk, "", colorBlue, styleHistogram | styleOwnScale, 0, 1 );
Plot( tr, "", colorBlue, styleHistogram | styleOwnScale, 0, 1 );
I'd say every time, every problem is more complicated with the case of posting partial code