Trend or support lines that end when breached

Hi, trying to Get Trend lines that Stop after they get breached.
Here's about what it should look like ( I drew these in )...
idea

and the code so far...

Body =  abs(O-C) ;
range = H-L ;    // Range
Third = range*.33 ; // lower price
L33 = L+third; // Low  + 33% range , mid 50%
L67 = H-third; // High - 33% range ,  top 67 %
Top_candle = O<L33 AND C<L33 ;
Bot_candle = O>l67 AND C>L67 ;

LV = IIf(O<C,O,C) ; // Bottom Trigger to cancel Line
HV = IIf(O>C,O,C) ; // Top Trigger to cancel Line

GfxSetOverlayMode( 1 ); 
GfxSetCoordsMode( 1 ); 

COLOR = IIf(Top_candle,colorred,IIf(Bot_candle,colorgreen,colorGrey40) ) ;
Plot(C,"",color,styleCandle);

bi=BarIndex() ;
FVB = FirstVisibleValue(bi);
LVB = LastVisibleValue(bi);

/// Top Lines START///
for ( b = FVB; b <= LVB; b++ )

{
    if ( Top_candle[b]==1 )
    {
    
	T0 = BarsSinceCompare(Top_candle,"<",H) ;
	
top= LineArray(b,h[b],LVB,H[b] ) ;
bot= LineArray(b,LV[b],LVB,LV[b] ) ;			
Plot( top,"",colorred,styleLine |styleNoLabel);
Plot( bot,"",colorred,styleLine |styleNoLabel);
//Plot( x1,"",colorYellow,styleLine |styleNoLabel);
//Plot( LastValue(x[b]),"",colorYellow,styleLine |stylenolabel);
GfxSelectSolidBrush( colorDarkRed );
GfxRectangle( b, h[b], LVB, LV[b]) ;

	}

}
/// Top Lines END///

Here;s what it looks like, ( just working on the top resistance atm.)
idea2

I tried using Line arrays and also GFX Rectangle and having trouble trying to figure out when ( in this example ) LVB gets touched the rectangle should end. I've messed around with Lastvalue, valuewhen ,valuewhencompare , but just can't get it.

Any suggestions would be greatly appreciated.
Thankyou

I meant to say LV breached not LVB sorry my bad
LV = IIf(O<C,O,C) ; // Bottom Trigger to cancel Line or drawing
LVB = last visible bar

Here's another view of approximately what the above pic should look like .
(Haven't coded the green trend stuff so that can be ignored )
idea3

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