Indicators: Frama Indicator

 

Frama Indicator:

The fractal dimension value is used to build an EMA-like moving average.

Author: MetaQuotes Software Corp.

 

Hi,

thanks for the indicator.

Would you be interesed in coding the Ehlers sinewave indicator in MQL4?
This is the code in Easylanguage (Tradestation).

Thanks!

--------------------------------------------------------------

Inputs: Price((H+L)/2),
alpha(.07);

Vars: Smooth(0),
Cycle(0),
I1(0),
Q1(0),
I2(0),
Q2(0),
Deltaphase(0),
MedianDelta(0),
Maxhmp(0),
AmpFix(0),
Re(0),
Im(0),
DC(0),
alpha1(0),
InstPeriod(0),
DCPeriod(0),
count(0),
Smoothcycle(0),
Realpart(0),
Imagpart(0),
DCPhase(0);

smooth = (Price + 2*Price[1] + 2*Price[2] + Price[3])/6;

Cycle = (1 - .5*alpha)*(1 - .5*alpha)*(Smooth - 2*Smooth[1] + Smooth[2]) + 2*(1 - alpha)*Cycle[1] - (1 - alpha)*(1 - alpha)*Cycle[2];
If currentbar < 7 then Cycle = (Price - 2*Price[1] + Price[2]) / 4;
{Cycle = Price;}

Q1 = (.0962*Cycle + .5769*Cycle[2] - .5769*Cycle[4] - .0962*Cycle[6])*(.5 + .08*InstPeriod[1]);
I1 = Cycle[3];
If Q1 <> 0 and Q1[1] <> O then Deltaphase = (I1/Q1 - I1[1]/Q1[1]) / (1 + I1*I1[1]/(Q1*Q1[1]));

If Deltaphase < 0.1 then Deltaphase = 0.1;
If Deltaphase > 1.1 then Deltaphase = 1.1;
MedianDelta = Median(Deltaphase, 5);
If MedianDelta = 0 then DC = 15 else DC = 6.28318/MedianDelta + .5;
InstPeriod = .33*DC + .67*InstPeriod[1];
Value1 = .15*InstPeriod + .85*Value1[1];

{Compute Dominant Cycle Phase}
DcPeriod = IntPortion(value1);
RealPart = 0:
ImagPart = 0;
For count = 0 To DcPeriod - 1 begin
RealPart = RealPart + Sine(360 * count/DcPeriod) * (Cycle[count]);
ImagPart = ImagPart + Cosine(360 * count/DcPeriod) * (Cycle[count]);
End;
If AbsValue(ImagPart) > 0.001 then DcPhase = Arctangent(RealPart / ImagPart);
If AbsValue(ImagPart) <= 0.001 then DcPhase = 90 * Sign(RealPart);
DcPhase = DcPhase + 90:
If ImagPart < 0 then DcPhase = DcPhase + 180;
If Dcphase > 315 then DcPhase = DcPhase - 360;
Plot1(Sine(DcPhase), "Sine");
Plot1(Sine(Dcphase + 45), "LeadSine");

Reason: