Bonjour,
quelqu'un aurait-il un peu de temps pour programmer l'indic appelé supertrend chez whs ? si en plus on pouvait avoir un signal d'achat sur les croisements se serait top ou me dire à quoi ca pourrait correspondre en MT4 car pour moi c'est du chinois lol
voici le code
__________________________________________________ ______________
indicator Supertrend;
input
CalcPriceType = 1, // type of price calculation over which average will be calculated
TrendPriceType = 2, // type of price calculation over which trend direction will be calculated
VolatPeriod = 1, // period to look for volatility
VolatCoeff = 1.8, // distance from average, multiply of volatility
AvgToVolatRatio = 10, // period to calculate average, multiply of volatility period
UpDnCalcType = 6; // type of calculation for stops
draw
AvgPrice("Average Price"),
Stop("Stop");
vars
i(number),
VolatUpCoeff(number),
VolatDnCoeff(number),
HH(series),
LL(series),
CalcPrice(series),
TrendPrice(series),
Volat(series),
AvgVolat(series),
AvgPeriod(number),
Up(series),
Dn(series),
Trend(series);
begin
VolatUpCoeff := abs(VolatCoeff);
VolatDnCoeff := -abs(VolatCoeff);
AvgPeriod := AvgToVolatRatio*VolatPeriod;
HH := Highest(High, VolatPeriod);
LL := Lowest(Low, VolatPeriod);
if CalcPriceType = 1 then
CalcPrice := Close;
if CalcPriceType = 2 then
CalcPrice := (HH+LL)/2;
if CalcPriceType = 3 then
CalcPrice := (HH+LL+Close)/3;
if CalcPriceType = 4 then begin
CalcPrice := Close;
for i := front(Close)+VolatPeriod-1 to back(Close) do
CalcPrice[i] := (HH[i]+LL[i]+Close[i]+Low[i-VolatPeriod+1])/4;
end;
if CalcPriceType = 5 then begin
CalcPrice := Close;
for i := front(Close)+VolatPeriod to back(Close) do
CalcPrice[i] := (HH[i]+LL[i]+Close[i-VolatPeriod])/3;
end;
if CalcPriceType = 6 then begin
CalcPrice := Close;
for i := front(Close)+VolatPeriod to back(Close) do
CalcPrice[i] := (HH[i]+LL[i]+Close[i-VolatPeriod]+Low[i-VolatPeriod+1])/4;
end;
if TrendPriceType = 1 then
TrendPrice := Close;
if TrendPriceType = 2 then
TrendPrice := (HH+LL)/2;
if TrendPriceType = 3 then
TrendPrice := (HH+LL+Close)/3;
if TrendPriceType = 4 then begin
TrendPrice := Close;
for i := front(Close)+VolatPeriod-1 to back(Close) do
TrendPrice[i] := (HH[i]+LL[i]+Close[i]+Low[i-VolatPeriod+1])/4;
end;
if TrendPriceType = 5 then begin
TrendPrice := Close;
for i := front(Close)+VolatPeriod to back(Close) do
TrendPrice[i] := (HH[i]+LL[i]+Close[i-VolatPeriod])/3;
end;
if TrendPriceType = 6 then begin
TrendPrice := Close;
for i := front(Close)+VolatPeriod to back(Close) do
TrendPrice[i] := (HH[i]+LL[i]+Close[i-VolatPeriod]+Low[i-VolatPeriod+1])/4;
end;
Volat := (HH - LL)/2;
Up := CalcPrice;
Dn := CalcPrice;
if AvgToVolatRatio>1 then begin
if UpDnCalcType=1 or UpDnCalcType=2 then begin
AvgPrice := SMA(CalcPrice, AvgPeriod);
AvgVolat := SMA(Volat, AvgPeriod);
Up := AvgPrice+VolatUpCoeff*AvgVolat;
Dn := AvgPrice+VolatDnCoeff*AvgVolat;
end;
if UpDnCalcType=3 or UpDnCalcType=4 then begin
AvgPrice := EMA(CalcPrice, AvgPeriod);
AvgVolat := EMA(Volat, AvgPeriod);
Up := AvgPrice+VolatUpCoeff*AvgVolat;
Dn := AvgPrice+VolatDnCoeff*AvgVolat;
end;
if UpDnCalcType=5 or UpDnCalcType=6 then begin
AvgPrice := WMA(CalcPrice, AvgPeriod);
AvgVolat := WMA(Volat, AvgPeriod);
Up := AvgPrice+VolatUpCoeff*AvgVolat;
Dn := AvgPrice+VolatDnCoeff*AvgVolat;
end;
end else begin
AvgPrice := CalcPrice;
Up := CalcPrice+VolatUpCoeff*Volat;
Dn := CalcPrice+VolatDnCoeff*Volat;
end;
Trend := makeseries(front(Close), back(Close), 0);
for i := front(Close)+AvgPeriod+1 to back(Close) do begin
if (AvgToVolatRatio>1) and (UpDnCalcType=2 or UpDnCalcType=4 or UpDnCalcType=6) then begin
if Trend[i-1]<0 then begin
if Up[i]>Up[i-1] then
Up[i] := Up[i-1];
end;
if Trend[i-1]>=0 then begin
if Dn[i]<Dn[i-1] then
Dn[i] := Dn[i-1];
end;
end;
Trend[i] := Trend[i-1];
if TrendPrice[i]>Up[i] then
Trend[i] := 1;
if TrendPrice[i]<Dn[i] then
Trend[i] := -1;
end;
for i := front(Close)+AvgPeriod to back(Close) do begin
if Trend[i] >= 0 then
Stop[i] := Dn[i]
else
Stop[i] := Up[i];
end;
end.
__________________________________________________
Un grand merci d'avance
hypatia
![]() |
|


LinkBack URL
About LinkBacks
Répondre avec citation