7

« Last post by **cdg ** on* December 13, 2016, 01:30:13 am* »
please help to change the below code for using in MT4? thanks a lot!

`_SECTION_BEGIN("Fibosher");`

SetBarsRequired(200, 0);

// Ehlers formulas modified by Danny Suwardhani 2008

// from Ehlers, John F. Cybernetic Analysis for Stocks and Futures. Wiley. 2004.

// Chapter 1, p. 1. Code on p. 7.

function InverseFisher(array)

{

e2y = exp(2 * array);

return (e2y - 1)/(e2y + 1);

}

function Normalize(array, arraylen)

// Figure 1.7 on p. 7

{

MaxH = HHV(array, arraylen);

MinL = LLV(array, arraylen);

Value1[0] = array[0]; // Initialize as array

for(i = 1; i < BarCount; i++)

{

Value1[i]=.5*2*((array[i]-MinL[i])/IIf(MaxH[i]-MinL[i]==0,1,MaxH[i]-MinL[i])-.5)+.5*Value1[i-1];

if (Value1[i] > .9999) Value1[i] = .9999;

if (Value1[i] < -.9999) Value1[i] = -.9999;

}

return Value1;

}

function Fisher(array)

// Figure 1.7 on p. 7

{

F = array;

F = .25 * log((1+ array)/(1 - array)) + .5 * Ref(F, -1);

return F;

}

Med = (H+L)/2;

MidPoint=0;

// Fisher Transform

FisherXform = Fisher(Normalize(Med, 10));

FisherColor = colorYellow;

FisherColor = IIf(LinRegSlope(FisherXform,2) == 0,colorBlue,FisherColor );

FisherColor = IIf(LinRegSlope(FisherXform,2) < 0,colorRed,FisherColor );

Sell1 = LinRegSlope(FisherXform,2) <= 0 AND Ref(LinRegSlope(FisherXform,2),-1) > 0;

Buy1 = LinRegSlope(FisherXform,2) >= 0 AND Ref(LinRegSlope(FisherXform,2),-1) < 0;

Plot(FisherXform, "Fibosher", FisherColor , styleLine|styleThick);

barvisible = Status("barvisible");

maxr = LastValue( Highest( IIf( barvisible, FisherXform, 0 ) ) );

minr = LastValue( Lowest( IIf( barvisible, FisherXform, 100 ) ) );

ranr = maxr - minr;

Plot( maxr , "0%", colorGrey50 );

Plot( maxr - 0.236 * ranr, "-23.6%", colorPaleGreen );

Plot( maxr - 0.382 * ranr, "-38.2%", colorPaleBlue );

Plot( maxr - 0.50 * ranr, "-50.0%", colorOrange );

Plot( maxr - 0.618 * ranr, "-61.8%", colorPaleBlue );

Plot( maxr - 0.786 * ranr, "-78.6%", colorPaleGreen );

Plot( minr , "-100%", colorGrey50 );

GraphXSpace = 3;

_SECTION_END();