Many thanks Vonasi and Nicolas. I define Trend Lines in 3 different categories: 1. Invalid Trend Line, 2. Tentative Trend Line and 3. Valid Trend Line.
I join 2 Swing Lows (2nd swing low higher than 1st) with an Up Trend line, provided there is a Swing High (SH) in-between those 2 swing lows. This is a Valid Up trend line.
If there is no in-between swing high, we can not join 2 Swing Lows (2nd swing low higher than the 1st) with an up trend line. This will be an INVALID up trend line.
Similarly, I join 2 Swing highs (2nd swing high lower than the 1st) with an Down Trend line, provided there is a Swing Low (SL) in-between those 2 swing highs. This is a Valid Down trend line.
If there is no in-between swing low, we can not join 2 Swing highs (2nd swing high lower than the 1st) with an down trend line. This will be an INVALID down trend line. These are all shown in the 2 enclosed chart.
Now the question is how to incorporate this concept of valid Trend Line in our previous program as attached please.
Many thanks for your would be response.
//90000 160000 205 0 0 0 151 51 for ASX
//90000 240000 205 0 0 0 151 51 for GBP
H2=high[2]
H1=HIGH[1]
H0=HIGH[0]
L2=LOW[2]
L1=LOW[1]
L0=LOW[0]
A=H2
B=H1
C=H0
D=L2
E=L1
F=L0
iF B>=A AND B>C THEN
T=-3
else
t=0
endif
IF E<=D AND E<F THEN
T1=3
ELSE
T1=0
ENDIF
if t=-3 AND T1=0 then
sh=b
ELSif t=-3 AND T1=8 then
sh=b
ELSE
SH=0
ENDIF
If t1=3 AND T=0 then
sl=e
elsif t1=3 AND T=3 then
sl=e
else
sl=0
endif
//PEAK or Swing High
iF SH=B THEN//H1>=H2 and L1>=L2 and H0<H1 AND L0<=L1 THEN//AND CLOSE<H1 then
IF TIME>ST AND TIME<ET and date=today THEN
lasthtt = htt
lasthttbar = httbar
htt=H1
httbar = barindex[1]
if lasthttbar <> lasthttbar[1] then
IF TIME>ST AND TIME<ET and date=today THEN
IF htt<Htt[1] THEN
DRAWLINE(lasthttbar,lasthtt,httbar,htt) COLOURED(X,Y,Z)//(205,0,0)
endif
ENDIF
endif
ENDIF
ENDIF
//TROUGH or Swing Low
iF SL=E THEN //H1<H2 and L1<L2 and H0>=H1 AND L0>=L1 THEN//anD CLOSE>L1 then
IF TIME>ST AND TIME<ET and date=today THEN
lastltt = ltt
lastlttbar = lttbar
ltt=L1
lttbar = barindex[1]
if lastlttbar <> lastlttbar[1] then
IF TIME>ST AND TIME<ET and date=today THEN
IF Ltt>Ltt[1] THEN
DRAWLINE(lastlttbar,lastltt,lttbar,ltt) COLOURED(U,V,W)//(0,205,0)
endif
ENDIF
endif
ENDIF
ENDIF
return