lineArrays saved to static and drawn from static move when scolling

Hello everyone,
currently I am having trouble with drawing some line arrays which I create and save in one formula using:

linePeaksX = LineArray( foundPeakLinesMX[peakLinesCounter][1], H[foundPeakLinesMX[peakLinesCounter][1]], foundPeakLinesMX[peakLinesCounter][2], H[foundPeakLinesMX[peakLinesCounter][2]], 0, True );
            StaticVarSet( "pL" + ( peakLinesCounter + 1 ), linePeaksX, False, cmNever ); // persistent = False, CompressionMode = never

in this formula I use debug mode during which I save the lines with staticVarSet.
then in a second formula which I apply to my only active chart I use the following:

x = 1;

while( x <= 10 )
{
    linePeaksX = StaticVarGet( "pL" + x, False ); // align = False
    Plot( linePeaksX, "pL" + x, ColorRGB(  15*x, 200 - 20*x, 150 ), styleDashed, Null, Null, 0, 0, 1 );
    //Plot( linePeaksX, "pL" + x, ColorRGB(  15*x, 200 - 20*x, 150 ), styleDashed | styleOwnScale, Null, Null, 0, 0, 1 );
    x++;
}

to draw the lines. Now the problem is that they show on the chart ok, but when I move ( scoll back or forth ) the chart or if I zoom into the chart, the lines "wander" forward when I scroll, not staying at the correct x and y points or they don't scale like the price bars when I zoom in. I already played around a lot with the different settings of lineArray ( like turning on/off using absolute BarIndex() ) and turning on/off compression or persist in staticVarSet but the problem always stays the same. I also turned on/off quickData in preferences. I also tried UseOwnScale in Plot() function but nothing solves the problem. Am I doing anything obviously wrong here ?

You didn't post full code but looks like QuickAFL as reason.
Please read here.

Anyway to draw lines from peak to peak you can do like this second code here:
http://www.amibroker.org/userkb/2007/04/20/plotting-trade-zigzag-lines/

So here is modification

/// Original at 
/// @link http://www.amibroker.org/userkb/2007/04/20/plotting-trade-zigzag-lines/
/// Modified at 
/// @link https://forum.amibroker.com/t/linearrays-saved-to-static-and-drawn-from-static-move-when-scolling/26258/2
chg = 2;// percent
pk = H == Peak(H, chg, 1);

// Plot the Trade Lines
Sig = pk;
x1 = 0;
y1 = H[0];
CombinedColor = colorWhite;
CombinedLine = Null;

bi = Barindex();
fvb = FirstVisibleValue( bi );
lvb = LastVisibleValue( bi );
for( b = fvb; b <= lvb; b++ ) 
{
    if ( Sig[b] )
    {      
        x0 = x1;
        y0 = y1;
        x1 = b;
        y1 = H[b];
        La = LineArray( x0, y0, x1, y1 );
        co = IIf(y1 < y0, colorRed, colorBrightGreen);
        CombinedLine = IIf( IsNull( la ), CombinedLine, la );        
        CombinedColor = IIf( IsNull( La ), CombinedColor, co );
    }
}

Plot( C, "", colorDefault, 128 );
Plot( CombinedLine, "", CombinedColor );
PlotShapes( IIf( pk, shapeSmallCircle, shapeNone ), CombinedColor, 0, H, 0 );

26

Do not understand why you need matrix and static vars to draw lines.

Ok, Sorry I just solved it. It was the align option in staticVarGet ((; stupid me

Thanks for the help anyway. Problem is already solved

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.