Don't use -1. Current close has to be compared with last n bar range including current bar else in BO /BD it will go out of range
One more query (to finish my Stochs learning - as I value its divergences):
How to incorporate IFF or IF statement properly here:
y0=LastValue( Trough(StochD( periods , Ksmooth, DSmooth ),1,2));
y1=LastValue( Trough(StochD( periods , Ksmooth, DSmooth ),1,1));
x0=BarCount - 1 - LastValue(TroughBars(StochD( periods , Ksmooth, DSmooth ),1,2));
price_start= Close[x0] ;
x1=BarCount - 1 - LastValue(TroughBars(StochD( periods , Ksmooth, DSmooth ),1,1));
price_end=Close[ x1];
Line = LineArray( x0, y0, x1, y1, 0 );
If y1>y0 AND price_end<price_start ...............
Plot( Line, "Support line", ParamColor( "BullD Color", colorGreen ), ParamStyle( "BullD Style", styleLine ) );
Thanks & Regards