_SECTION_BEGIN("Demark Trend lines");
pc = Param("Perbent", 0.05, 0.01, 10 );
percent = pc * 1; /* Adjust this percent as necessary, I use .01 because FOREX is a 0.0000 number */
ShowTrLines = ParamToggle("Show TrLines", "No|Yes", 1);
firstpointL = 2;
firstpointH = 2;
y0=LastValue(Trough(L,percent,firstpointL));
y1=LastValue(Trough(Ref(L,-1),percent,1));
for( i = 1; i < BarCount AND y0 >= y1; i++ )
{
firstpointL++;
y0=LastValue(Trough(L,percent,firstpointL));
}
if(ShowTrLines)
{
x0=BarCount - 1 - LastValue(TroughBars(L,percent,firstpointL));
x1=BarCount - 1 - LastValue(TroughBars(Ref(L,-1),percent,1));
LineL = LineArray( x0, y0, x1, y1, 1 );
Plot( LineL, " Support", colorBrown,1 +8 + 4096);
yt0=LastValue(Peak(H,percent,firstpointH));
yt1=LastValue(Peak(Ref(H,-1),percent,1));
for(i = 1; i < BarCount AND yt0 <= yt1; i++ )
{
firstpointH++;
yt0=LastValue(Peak(H,percent,firstpointH));
}
xt0=BarCount - 1 - LastValue(PeakBars(H,percent,firstpointH));
xt1=BarCount - 1 - LastValue(PeakBars(Ref(H,-1),percent,1));
LineH = LineArray( xt0, yt0, xt1, yt1, 1 );
Plot( LineH, "Resistance", colorGreen,1 + 8 + 4096);
}
_SECTION_END();