Trend Lines . Help me to edit a little to use both over 5m and 15m

#1
Hi everybody.
I have this code "Parallel Trend Lines". But it was only usable on chart D.
Can anybody help me to be able to use both on 5m and 15m chart with.
Thanks very much!!!

Code:
// Parallel lines defined by the automatic support and the HighestBetween point
x = Cum(1);per = 3;s1=L;s11=H;
pS = TroughBars( s1, per, 1 ) == 0;
endt= LastValue(ValueWhen( pS, x, 1 ));
startt=LastValue(ValueWhen( pS, x, 2 ));
dtS =endt-startt;
endS = LastValue(ValueWhen( pS, s1, 1 ) );
startS = LastValue( ValueWhen( pS, s1, 2 ));
aS = (endS-startS)/dtS;bS = endS;
trendlineS = aS * ( x -endt ) + bS;
Plot(IIf(x>startt-10,trendlineS,-1e10),"",colorYellow,styleThick|styleNoRescale);
H1=LastValue(Highest((Cum(1)>startt AND Cum(1)<endt)*H));
tH1=LastValue(ValueWhen(H==H1,Cum(1)));
Color=IIf((Cum(1)==startt OR Cum(1)==endt),colorYellow,IIf(Cum(1)==tH1,colorOrange,colorBlack));

UpperParallel=aS*(x-tH1)+H1;Plot(IIf(x>startt-10,UpperParallel,-1e10),"UpperLine",colorOrange,styleThick|styleNoRescale);

// Parallel lines defined by the automatic resistance and the LowestBetween point
x = Cum(1);per = 3;s1=L;s11=H;
pR = PeakBars( s11, per, 1 ) == 0;
endt1= LastValue(ValueWhen( pR, x, 1 ));
startt1=LastValue(ValueWhen( pR, x, 2 ));
dtR =endt1-startt1;
endR = LastValue(ValueWhen( pR, s11, 1 ) );
startR = LastValue( ValueWhen( pR, s11, 2 ));
aR = (endR-startR)/dtR;
bR = endR;
trendlineR = aR * ( x -endt1 ) + bR;
Plot(IIf(x>startt1-10,trendlineR,-1e10),"",colorYellow,styleThick|styleNoRescale);
L1=LastValue(Lowest(IIf(Cum(1)>startt1 AND Cum(1)<endt1,L,10^10)));
tL1=LastValue(ValueWhen(L==L1,Cum(1)));
Color=IIf((Cum(1)==startt1 OR Cum(1)==endt1),colorYellow,IIf(Cum(1)==tL1,colorOrange,colorBlack));

LowerParallel=aR*(x-tL1)+L1;Plot(IIf(x>startt1-10,LowerParallel,-1e10),"LowerLine",colorOrange,styleThick|styleNoRescale);
 

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?