Vars:
TPCount(0),Direct(0),
HoldPrice(0),BarsBk(0),
Slope1(0),Slope2(0),
ETA1(0),ETA2(0),EPA(0),
NewDate(0),NewTime(0);
Arrays:
TPDate[4](0),TPTime[4](0),TPBar[4](0),TPPrice[4](0),TPDirect[4](0);
Direct=Swing_Lee_Simple(NBars,False);
If Sign(Direct)<>Sign(Direct[1]) then
begin
BarsBk=AbsValue(Direct);
{Found a TurningPoing so
increase count}
TPCount=TPCount+1;
{Save the proper
price}
If Direct<0 then HoldPrice=High[BarsBk]
else
HoldPrice=Low [BarsBk];
{Push the Stack}
For Value1=1 to 3
begin
TPDate[Value1]
=TPDate[Value1+1];
TPTime[Value1]
=TPTime[Value1+1];
TPBar[Value1]
=TPBar[Value1+1];
TPPrice[Value1]
=TPPrice[Value1+1];
TPDirect[Value1]=TPDirect[Value1+1];
End;
{Save Current Data}
TPDate[4]
=Date[BarsBk];
TPTime[4]
=Time[BarsBk];
TPBar[4]
=CurrentBar-BarsBk;
TPPrice[4]
=HoldPrice;
TPDirect[4]=Sign(Direct);
Plot1[BarsBk](HoldPrice,"TP");
If TPCount>3 then begin
{If we have 4 TP's then
we can look for
WW}
Condition1=False;Condition2=False;
Slope1=(TPPrice[3]-TPPrice[1])/(TPBar[1]-TPBar[3]);
Slope2=(TPPrice[4]-TPPrice[2])/(TPBar[2]-TPBar[4]);
If
TPDirect[1]>0 then begin
{Look for Bullish
WW}
Condition1=
TPPrice[4]>TPPrice[3] and
TPPrice[4]<TPPrice[2] and
TPPrice[3]<TPPrice[1] and
TPPrice[4]>TPPrice[1] and
Slope1 <Slope2
;
End
Else Begin
{Look for Bearish
WW}
Condition2=
TPPrice[4]<TPPrice[3] and
TPPrice[4]>TPPrice[2] and
TPPrice[3]>TPPrice[1] and
TPPrice[4]<TPPrice[1]
and
Slope1
>Slope2 ;
End;
{Plot the wave and lines if it exists}
If
Condition1 or Condition2 then begin
ETA1=TL_NEW(TPDate[1],TPTime[1],TPPrice[1],TPDate[3],TPTime[3],TPPrice[3]);
ETA2=TL_NEW(TPDate[2],TPTime[2],TPPrice[2],TPDate[4],TPTime[4],TPPrice[4]);
EPA
=TL_NEW(TPDate[1],TPTime[1],TPPrice[1],TPDate[4],TPTime[4],TPPrice[4]);
Value5=TL_New(Date,Time,TL_GetValue(ETA1,Date,Time),
Date,Time,TL_GetValue(ETA2,Date,Time));
Value1=mod(tpcount,6)+2;
Value1=red;
TL_SetColor(ETA1,VALUE1);
TL_SetColor(ETA2,VALUE1);
TL_SetColor(EPA
,VALUE1);
TL_SetColor(Value5,Red);
TL_SetSize(Value5,3);
Value2=0;
Value1=0;
While Value2=0 and Value1< MaxBars
begin
Value2=BarsToDate_Time(TPBar[4]-TPBar[3],
Value1, NewDate,
NewTime);
Value3=TL_GetValue(ETA2, NewDate,
NewTime)-TL_GetValue(ETA1, NewDate,
NewTime);
If Condition1 and Value3>0 then
Value2=0;
If Condition2 and Value3<0 then
Value2=0;
Value1=Value1+1;
End;
If
Value2<>0 or Value1=MaxBars then
begin
TL_SetEnd(ETA1, NewDate, NewTime,
TL_GetValue(ETA1, NewDate,
NewTime));
Value7=TL_GetValue(ETA2, NewDate,
NewTime);
TL_SetEnd(ETA2, NewDate, NewTime,
Value7);
Value8=Text_New(NewDate,NewTime,Value7,"ETA");
Text_SetStyle(Value8, 0,
2);
Value7=TL_GetValue(EPA , NewDate,
NewTime);
TL_SetEnd(EPA , NewDate, NewTime,
Value7);
Value8=Text_New(NewDate,NewTime,Value7,"EPA");
Text_SetStyle(Value8, 0,
2);
End;
End;
End;
End;