Plotting LineArray to draw trend lines - Help.

#1
Hi all, I got a reference code for drawing trend lines.

Can somebody help draw line ('LineArray' function) by joining the recent 2 points of HHs (as well as HHs, LLs, HLs, LHs by individual lines).

Also requirement is to join 2 points alone and not to extend more than recent 2 points. The line needs to get extended left and right until today. And also the extended line's value (ie., today's value of the extended line) is expected to display.

Here is the code:
HTML:
Q = Param( "% Change", 2, 0.1, 10, 0.1 );
Z = Zig( C , q ) ;
HH = ( ( Z < Ref( Z, -1 ) AND Ref( Z, -1 ) > Ref( Z, -2 ) ) AND (Peak( z, q, 1 ) > Peak( Z, q, 2 ) ) );
LH = ( ( Z < Ref( Z, -1 ) AND Ref( Z, -1 ) > Ref( Z, -2 ) ) AND (Peak( Z, q, 1 ) < Peak( Z, q, 2 ) ) );
HL = ( ( Z > Ref( Z, -1 ) AND Ref( Z, -1 ) < Ref( Z, -2 ) ) AND (Trough( Z, q, 1 ) > Trough( Z, q, 2 ) ) );
LL = ( ( Z > Ref( Z, -1 ) AND Ref( Z, -1 ) < Ref( Z, -2 ) ) AND (Trough( Z, q, 1 ) < Trough( Z, q, 2 ) ) );
GraphXSpace = 5;
dist = 0.5 * ATR( 20 );
 
for ( i = 0; i < BarCount; i++ )
{
    if ( HH[i] )
        PlotText( "HH", i, H[ i ] + dist[i], colorYellow );
 
    if ( LH[i] )
        PlotText( "LH", i, H[ i ] + dist[i], colorYellow );
 
    if ( HL[i] )
        PlotText( "HL", i, L[ i ] - dist[i], colorPink );
 
    if ( LL[i] )
        PlotText( "LL", i, L[ i ] - dist[i], colorPink );
 
}
 

Similar threads

Zerodha – Open Paperless Account

Open online account with Zerodha. Free delivery trading and Max Rs 20 for Intraday, F&O, Currency and Commodity Trading. Intraday High leverage with MIS, CO and BO.

Name:Phone:
Email:City:
State:
Are you a day trader?