Type : Indicator, Name : Phase Calculation
inputs:
DomCycle(15);
vars:
RealPart(0),
ImagPart(0),
Weight(0),
Phase(0),
J(0);
for J = 0 to DomCycle -1 Begin
weight = close[J];
If DomCycle <>0 then Begin
RealPart = RealPart + Cosine(360 * J / DomCycle) * Weight;
ImagPart = ImagPart + Sine(360 * J / DomCycle) * Weight;
end;
end;
If AbsValue(RealPart) > .001 Then Begin
Phase = ArcTangent(ImagPart/RealPart);
end
else Begin
Phase = 90 * Sign(ImagPart);
end;
If RealPart < 0 then Phase = Phase +180;
Phase = Phase + 90;
If Phase < 0 then Phase = Phase + 360;
If Phase > 360 then Phase = Phase — 360;
plot1(Phase, «Phase»);