Code: Select all
Express TMS_TDI
Vars
series line, line_hi, line_lo, mpl, msl, mbl, tp, sd, vbup, vbdown;
series u, d, au, ad, mbl2, EcartType;
numeric dif, i, hi_baseline, lo_baseline;
Numeric Periode_mbl2, somme, compteur, Diffrentiel, carre, Total;
input $period(1, 100, 10);
input $mpl(1,10,3);
input $msl(3,10,7);
input $mbl(20,40,34);
//-------function MMA--------
series res, res1;
Calculation
tp = (h + l + o + c) / 4;
hi_baseline = 68;
lo_baseline = 32;
if IsFirstBar() then
begin
CalculateAtEveryTick(false);
SetYscaleFormat(GetPriceFormat());
u = 0;
d = 0;
end
if CurrentBarIndex() >= 1 then
begin
dif = tp - tp[1];
if dif > 0 then begin
u[i] = dif;
d[i] = 0;
end
else
begin
u[i] = 0;
d[i] = -dif;
end
end
//---------------function MMA---------------
if CurrentBarIndex() = $period then
res = u;
if CurrentBarIndex() > $period then
res = res[1] + (u - res[1]) /$period;
au = res;
//---------------function MMA---------------
if CurrentBarIndex() = $period then
res1 = d;
if CurrentBarIndex() > $period then
res1 = res1[1] + (d - res1[1]) /$period;
ad = res1;
line = void;
line_hi = void;
line_lo = void;
if CurrentBarIndex() > $period then
line = 100 * au / (au + ad);
line_hi = hi_baseline;
line_lo = lo_baseline;
if IsFinalBar() then
begin
Calculateateverytick(true);
ExpMovingAverage(line, mpl, $mpl);
MovingAverage(line, msl, $msl);
MovingAverage(line, mbl, $mbl);
StdDev(mbl, sd, $mbl);
End
Periode_mbl2= 34;
Somme = Sum(line,Periode_mbl2);
Mbl2 = somme / Periode_mbl2;
Somme = 0;
For compteur = 0 to (Periode_mbl2-1)
Begin
Diffrentiel = line[compteur] - mbl2;
Carre = power(Diffrentiel,2) ;
Somme = Somme + Carre ;
End
Total = somme / Periode_mbl2 ;
EcartType = SquareRoot(Total) ;
vbup = mbl2 + EcartType;
vbdown = mbl2 - EcartType;
Interpretation
begin
end
plot (mpl, 0,255,0, 2);
plot (msl, 255,0,0, 2);
plot (mbl, 255,192,0, 2);
plotline (lo_baseline, black, 1);
plotline (hi_baseline, black, 1);
plot (sd, blue,2);
plot (vbup, blue, 2);
plot (vbdown, blue, 2);
plot (EcartType, black,2);