inputs:
LeftStrength( 10 ) ,
RightStrength( 10 ),
LookBackLength( 100 );
variable:
ID(1),
Offset( 0 ) ,
HighValue1(0),
HighValue2(0),
LowValue1(0),
LowValue2(0),
DownStartPrice(0),
DownStartBar(0),
DownSecondPrice(0),
DownTrendConfirmBar(0),
DownTrendConfirm(0),
DownSecondStartBar(0),
DownLineCurrentPrice(0),
UpStartPrice(0),
UpStartBar(0),
UpSecondPrice(0),
UpTrendConfirmBar(0),
UpTrendConfirm(0),
UpSecondStartBar(0),
UpLineCurrentPrice(0);
if Date <> Date[1] then begin
HighValue1 = 0;
HighValue2 = 0;
LowValue1 = 0;
LowValue2 = 0;
DownStartPrice = 0;
DownStartBar = 0;
DownSecondPrice = 0;
DownTrendConfirmBar = 0;
DownTrendConfirm = 0;
DownSecondStartBar = 0;
DownLineCurrentPrice = 0;
UpStartPrice = 0;
UpStartBar = 0;
UpSecondPrice = 0;
UpTrendConfirmBar = 0;
UpTrendConfirm = 0;
UpSecondStartBar = 0;
UpLineCurrentPrice = 0;
end;
Offset = .15 * Average( Range, 5 ) ;
if PivotHighVSBar( 1, High, LeftStrength, RightStrength, RightStrength + 1 ) <> 1 then
begin
HighValue1 = PivotHighVS(1, High, Leftstrength, RightStrength, LookBackLength );
HighValue2 = PivotHighVS(2, High, Leftstrength, RightStrength, LookBackLength );
if HighValue2 <> 1 and ( ( HighValue1 >= HighValue2  Offset ) and ( HighValue1 <= HighValue2 + Offset ) ) then
begin
//ID = Text_New(Date[RightStrength], Time[RightStrength], High[RightStrength] + Offset, "DT");
//Text_SetStyle(ID, 2, 1 ) ;
//Text_SetColor(ID, yellow);
if DownTrendConfirm = 0 then begin
DownSecondPrice = High[RightStrength];
DownTrendConfirmBar = DownStartBar;
DownSecondStartBar = RightStrength  1;
end
else if DownTrendConfirm = 1 and High[RightStrength] > DownLineCurrentPrice then begin
DownSecondPrice = High[RightStrength];
DownTrendConfirmBar = DownStartBar;
DownSecondStartBar = RightStrength  1;
end;
Value1 = 1;
end ;
if HighValue2 <> 1 and HighValue1 > HighValue2 and value1 = 0 then
begin
//ID = Text_New(Date[RightStrength], Time[RightStrength], High[RightStrength] + Offset, "HH");
//Text_SetStyle(ID, 2, 1 ) ;
//Text_SetColor(ID, darkgreen);
DownStartPrice = High[RightStrength];
DownStartBar = RightStrength  1;
end
else
if HighValue2 <> 1 and HighValue1 < HighValue2 and value1 = 0 then
begin
//ID = Text_New(Date[RightStrength], Time[Rightstrength], High[RightStrength] + Offset, "(LH)");
//Text_SetStyle(ID, 2, 1 ) ;
//Text_SetColor(ID, Red);
if DownTrendConfirm = 0 then begin
DownSecondPrice = High[RightStrength];
DownTrendConfirmBar = DownStartBar;
DownSecondStartBar = RightStrength  1;
end
else if DownTrendConfirm = 1 and High[RightStrength] > DownLineCurrentPrice then begin
DownSecondPrice = High[RightStrength];
DownTrendConfirmBar = DownStartBar;
DownSecondStartBar = RightStrength  1;
end;
Value1 = 1;
end ;
Value1 = 0;
end ;
if PivotLowVSBar( 1, Low, LeftStrength, RightStrength, RightStrength + 1 ) <> 1 then
begin
LowValue1 = PivotLowVS(1, Low, Leftstrength, RightStrength, LookBackLength );
LowValue2 = PivotLowVS(2, Low, Leftstrength, RightStrength, LookBackLength );
if LowValue2 <> 1 and ( ( LowValue1 >= LowValue2  Offset ) and ( LowValue1 <= LowValue2 + Offset ) ) then
begin
//ID = Text_New(Date[RightStrength], Time[RightStrength], Low[RightStrength]  Offset, "DB");
//Text_SetStyle(ID, 2, 0 ) ;
//Text_SetColor(ID, yellow);
if UpTrendConfirm = 0 then begin
UpSecondPrice = Low[RightStrength];
UpTrendConfirmBar = UpStartBar;
UpSecondStartBar = RightStrength  1;
End
else if UpTrendConfirm = 1 and Low[RightStrength] < UpLineCurrentPrice then Begin
UpSecondPrice = Low[RightStrength];
UpTrendConfirmBar = UpStartBar;
UpSecondStartBar = RightStrength  1;
End;
Value1 = 1;
end;
if LowValue2 <> 1 and LowValue1 < LowValue2 and Value1 = 0 then
begin
//ID = Text_New(Date[RightStrength], Time[RightStrength], Low[RightStrength]  Offset, "LL");
//Text_SetStyle(ID, 2, 0 ) ;
//Text_SetColor(ID, Red);
UpStartPrice = Low[RightStrength];
UpStartBar = RightStrength  1;
end
else
if LowValue2 <> 1 and LowValue1 > LowValue2 and Value1 = 0 then
begin
//ID = Text_New(Date[RightStrength], Time[RightStrength], Low[RightStrength]  Offset, "(HL)");
//Text_SetStyle(ID, 2, 0 ) ;
//Text_SetColor(ID, darkgreen);
if UpTrendConfirm = 0 then begin
UpSecondPrice = Low[RightStrength];
UpTrendConfirmBar = UpStartBar;
UpSecondStartBar = RightStrength  1;
End
else if UpTrendConfirm = 1 and Low[RightStrength] < UpLineCurrentPrice then Begin
UpSecondPrice = Low[RightStrength];
UpTrendConfirmBar = UpStartBar;
UpSecondStartBar = RightStrength  1;
End;
end;
Value1 = 0;
end ;
//Down Trend
If DownStartBar >= RightStrength  1
Then DownStartBar = DownStartBar + 1;
If DownTrendConfirmBar >= RightStrength  1
Then DownTrendConfirmBar = DownTrendConfirmBar + 1;
If DownSecondStartBar >= RightStrength  1
Then DownSecondStartBar = DownSecondStartBar + 1;
If DownStartBar = DownTrendConfirmBar Then
DownTrendConfirm = 1
Else DownTrendConfirm = 0;
If DownTrendConfirm = 1 Then
DownLineCurrentPrice = DownSecondPrice  (DownStartPrice  DownSecondPrice)
/ (IFF(DownStartBar  DownSecondStartBar <> 0,DownStartBar  DownSecondStartBar, 1))
* DownSecondStartBar
Else begin
DownLineCurrentPrice = 0;
SetPlotColor[1]( 1, Transparent );
end;
//UpTrend
If UpStartBar >= RightStrength  1
Then UpStartBar = UpStartBar + 1;
If UpTrendConfirmBar >= RightStrength  1
Then UpTrendConfirmBar = UpTrendConfirmBar + 1;
If UpSecondStartBar >= RightStrength  1
Then UpSecondStartBar = UpSecondStartBar + 1;
If UpStartBar = UpTrendConfirmBar Then
UpTrendConfirm = 1
Else UpTrendConfirm = 0;
If UpTrendConfirm = 1 Then
UpLineCurrentPrice = UpSecondPrice  (UpStartPrice  UpSecondPrice)
/ (IFF(UpStartBar  UpSecondStartBar <> 0,UpStartBar  UpSecondStartBar, 1))
* UpSecondStartBar
Else begin
UpLineCurrentPrice = 0;
SetPlotColor[1]( 2, Transparent );
end;
If DownTrendConfirm = 1 Then
Plot1(DownLineCurrentPrice, !("Down Trend Price") );
If UpTrendConfirm = 1 Then
Plot2(UpLineCurrentPrice, !("Up Trend Price") );
