Bonjour à tous,
Au fil de mes périgrinations sur la toile je suis tombé sur cette moyenne mobile exponentielle qui apparemment serait assez utilisée sur le forex.
Si une bonne âme veut bien convertir ces codes que j’ai trouvé et baptisé V1-V2-V3. afin de vérifier sa pertinence.
Bonnes fêtes de fin d’année.
///////////////////////////////////////////////////////////
// HOLT EMA V1
input: price(close), gmma(40), alpha(20);
vars: mygamma(gmma), myalpha(alpha), b(0);
if alpha > 1 then myalpha = 2.0/(alpha+1.0) else myalpha = alpha;
if gmma > 1 then mygamma = 2.0/(gmma+1) else mygamma = gmma;
If CurrentBar = 1 then begin
value1 = price;
b = 0.0;
end else begin
value1 = (1-myalpha)*(value1[1] + b[1]) + myalpha*price;
b = (1-mygamma)*b[1] + mygamma*(value1 - value1[1]);
end;
Plot1( value1, "Rising" );
Plot2( value1, "Falling" );
Plot3( value1, "Neutral" );
Plot4( value1, "HoltEMA", iff(value1=value1[1], GetPlotColor(3), iff(value1>value1[1], GetPlotColor(1), GetPlotColor(2))));
NoPlot(1);
NoPlot(2);
NoPlot(3);
///////////////////////////////////////////////////////////
// HOLT EMA V2
input: price(NumericSeries), gmma(NumericSimple), alpha(NumericSimple);
vars: mygamma(gmma), myalpha(alpha), b(0);
if alpha > 1 then myalpha = 2.0/(alpha+1.0) else myalpha = alpha;
if gmma > 1 then mygamma = 2.0/(gmma+1) else mygamma = gmma;
If CurrentBar = 1 then begin
value1 = price;
b = 0.0;
end else begin
value1 = (1-myalpha)*(value1[1] + b[1]) + myalpha*price;
b = (1-mygamma)*b[1] + mygamma*(value1 - value1[1]);
end;
HoltEMA = value1;
/////////////////////////////////////////////////////////////
// HOLT EMA V3
input: price(close), gmma(40), alpha(20), angle1(30), angle2(60);
vars: mygamma(gmma), myalpha(alpha), b(0), slope(0), debug(1);
value1 = HoltEMA(price, gmma, alpha);
slope = (arctangent((value1-(value1[1]+value1[2])/2)/1.5/(minmove/pricescale)));
condition1 = value1 > value1[1];
condition2 = slope >= angle2;
condition3 = slope >= angle1;
condition4 = slope <= -1*angle2;
condition5 = slope <= -1*angle1;
Plot1( value1, "FastRising" );
Plot2( value1, "Rising" );
Plot3( value1, "Neutral" );
Plot4( value1, "Falling" );
Plot5( value1, "FastFalling" );
value2 = iff(condition2, GetPlotColor(1), iff(condition3, GetPlotColor(2), GetPlotColor(3)));
value3 = iff(condition4, GetPlotColor(5), iff(condition5, GetPlotColor(4), GetPlotColor(3)));
if debug = 1 then begin
#beginCmtryOrAlert
CommentaryCL(" slope: ", slope);
#End;
end;
Plot6( value1, "HoltEMA", iff(value1 > value1[1], value2, value3));
NoPlot(1);
NoPlot(2);
NoPlot(3);
NoPlot(4);
NoPlot(5);
///////////////////////////////////////////////////////////