I am drawing 4 year High / Low Lines. When all the the candle fits the screen i am able to see high and low Line. But as soon as i zoom and the even few candle goes out of the amibroker screen, it gives error " Array Subscript out of Range " .
Is there any other way to view High / Low Lines with getting above error.
Thanks.
My code is
// Locate Highest HIGH and Lowest LOW in last N days
N = Param("Days to go back(Excl today)", 1060, 1060, 2000, 1);
PriceStyle = ParamStyle("Chart Type", styleCandle, maskPrice);
LineStyle = ParamStyle("Line Style");
NDayHi = H[BarCount - 1 - N];
NDayLo = L[BarCount - 1 - N];
XH = XL = BarCount - 1 - N;
NDayHi_vol = V[BarCount - 1 - N];
NDayLo_vol = V[BarCount - 1 - N];
for(i = BarCount - 1 - N; i < BarCount - 1; i++)
{
if(H[i] > NDayHi)
{
NDayHi = H[i];
NDayHi_vol = V[i];
XH = i;
}
if(L[i] < NDayLo)
{
NDayLo = L[i];
NDayLo_vol = V[i];
XL = i;
}
}
// Define the Lines to be drawn
HLine = LineArray(BarCount - 1 - N, NDayHi, BarCount - 2, NDayHi);
LLine = LineArray(BarCount - 1 - N, NDayLo, BarCount - 2, NDayLo);
// Plot chart
_N(Title = StrFormat("{{NAME}} ({{INTERVAL}}) {{DATE}} {{OHLCX}} Vol=%1.0f\n{{VALUES}}", V));
Plot(C, "", colorGrey50, PriceStyle);
Plot(Hline, WriteVal(N, 1.0) + " Day Hi", colorBrightGreen, LineStyle);
Plot(LLine, WriteVal(N, 1.0) + " Day Lo", colorWhite, LineStyle);