Hi, thanks for your help. But I'd already found it in google search and it is not working. Some variables are not accepted by easylanguage . e.g,c6ackp said:Here's a link to the SUPERTREND algorithm written in easylanguage...
http://www.sierrachart.com/discus/messages/2/3081.html?1114470511
Does that help?
c6
Hi Sandeep,Option1 said:LeoVirgo
The line:
if HBKTypPrxCentr =1 then HBKPrxCentr=cc;
is a simple IF statement: it sets cc to 1
I read the code from the url and cc (not a defined variable) is set to 1 at the start of the flow
You will need to create the cc in EL thats why you are getting the errormsg
Does anyone know the Metastock variation ?
INPUT: HBKTypPrxCentr(1),HBKTypPrxSort(2),HBKintrvp(1),klargeurSup(1.8),klargeurInf(-1.8),HBKLisp(10),GapJcumu(0); 
Input:typeCalcul(6); 
var: HBKPrxCentr(C),HBKPrxSort(C),HBKPlusH(0),HBKPlusB( 0),HB(0),AmplitudVrGIntHBK(0),HBKAtr(0), 
HBKMoy(0),HBKH(0),HBKB(0),HBKHMoy(0),HBKBMoy(0),HBKtendance(0), 
HBKLisIntrvp(HBKLisp*HBKintrvp),Maxccant(HBKLisIntrvp); 
 
 
 
HBKPlusH=HighestFC(HIGH,HBKintrvp); 
HBKPlusB=LowestFC(LOW,HBKintrvp); 
if HBKTypPrxCentr =1 then HBKPrxCentr=CLOSE; 
if HBKTypPrxCentr =2 then HBKPrxCentr=(HBKPlusH+HBKPlusB)*0.5; 
if HBKTypPrxCentr =3 then HBKPrxCentr=(HBKPlusH+HBKPlusB+CLOSE)/3; 
if HBKTypPrxCentr =4 then HBKPrxCentr=(HBKPlusH+HBKPlusB+CLOSE+OPEN[HBKintrvp-1]) *0.25; 
if HBKTypPrxCentr =5 then HBKPrxCentr=(HBKPlusH+HBKPlusB+CLOSE[HBKintrvp])/3 ; 
if HBKTypPrxCentr =6 then HBKPrxCentr=(HBKPlusH+HBKPlusB+CLOSE[HBKintrvp]+OPEN[HBKintrvp-1])*0.25; 
 
if HBKTypPrxSort =1 then HBKPrxSort=CLOSE; 
if HBKTypPrxSort =2 then HBKPrxSort=(HBKPlusH+HBKPlusB)*0.5; 
if HBKTypPrxSort =3 then HBKPrxSort=(HBKPlusH+HBKPlusB+CLOSE)/3; 
if HBKTypPrxSort =4 then HBKPrxSort=(HBKPlusH+HBKPlusB+CLOSE+OPEN[HBKintrvp -1])* 0.25; 
if HBKTypPrxSort =5 then HBKPrxSort=(HBKPlusH+HBKPlusB+CLOSE[HBKintrvp])/3; 
if HBKTypPrxSort =6 then HBKPrxSort=(HBKPlusH+HBKPlusB+CLOSE[HBKintrvp]+OPEN[HBKintrvp-1])*0.25; 
 
AmplitudVrGIntHBK=(maxlist(HBKPlusH,CLOSE[HBKintrvp]) -minlist(HBKPlusB,CLOSE[HBKintrvp]))*0.5; 
 
 
if HBKLisp>1 then begin 
if typeCalcul=1 then begin 
HBKMoy=average(HBKPrxCentr,HBKLisIntrvp); 
HBKAtr=average(AmplitudVrGIntHBK,HBKLisIntrvp); 
HBKHMoy=HBkmoy+klargeurSup*HBKAtr; 
HBKBMoy=HBkmoy+klargeurInf*HBKAtr; 
end; 
if typeCalcul=2 then begin 
HBKMoy=average(HBKPrxCentr,HBKLisIntrvp); 
HBKAtr=average(AmplitudVrGIntHBK,HBKLisIntrvp); 
HBKHMoy=HBkmoy+klargeurSup*HBKAtr;IF HBKTendance=-1 then HBKHmoy=minlist(HBKHmoy,HBKHmoy[1]); 
HBKBMoy=HBkmoy+klargeurInf*HBKAtr;;IF HBKTendance=1 then HBKBmoy=maxlist(HBKBmoy,HBKBmoy[1]); 
end; 
if typeCalcul=3 then begin 
HBKMoy=xaverage(HBKPrxCentr,HBKLisIntrvp); 
HBKAtr=xaverage(AmplitudVrGIntHBK,HBKLisIntrvp); 
HBKHMoy=HBkmoy+klargeurSup*HBKAtr; 
HBKBMoy=HBkmoy+klargeurInf*HBKAtr; 
end; 
if typeCalcul=4 then begin 
HBKMoy=Xaverage(HBKPrxCentr,HBKLisIntrvp); 
HBKAtr=Xaverage(AmplitudVrGIntHBK,HBKLisIntrvp); 
HBKHMoy=HBkmoy+klargeurSup*HBKAtr;IF HBKTendance=-1 then HBKHmoy=minlist(HBKHmoy,HBKHmoy[1]); 
HBKBMoy=HBkmoy+klargeurInf*HBKAtr;;IF HBKTendance=1 then HBKBmoy=maxlist(HBKBmoy,HBKBmoy[1]); 
end; 
if typeCalcul=5 then begin 
HBKMoy=Waverage(HBKPrxCentr,HBKLisIntrvp); 
HBKAtr=Waverage(AmplitudVrGIntHBK,HBKLisIntrvp); 
HBKHMoy=HBkmoy+klargeurSup*HBKAtr; 
HBKBMoy=HBkmoy+klargeurInf*HBKAtr; 
end; 
if typeCalcul=6 then begin 
HBKMoy=average(HBKPrxCentr,HBKLisIntrvp); 
HBKAtr=Waverage(AmplitudVrGIntHBK,HBKLisIntrvp); 
HBKHMoy=HBkmoy+klargeurSup*HBKAtr;IF HBKTendance=-1 then HBKHmoy=minlist(HBKHmoy,HBKHmoy[1]); 
HBKBMoy=HBkmoy+klargeurInf*HBKAtr;;IF HBKTendance=1 then HBKBmoy=maxlist(HBKBmoy,HBKBmoy[1]); 
end; 
end else begin 
HBKH=HBKPrxCentr+klargeurSup*AmplitudVrGIntHBK; 
HBKB=HBKPrxCentr+klargeurInf*AmplitudVrGIntHBK; 
HBKMoy=HBKPrxCentr; 
HBKHMoy=HBKH; 
HBKBMoy=HBKB; 
end; 
 
if HBKPrxSort>HBKHMoy then HBKtendance=1; 
if HBKPrxSort<HBKBMoy then HBKtendance=-1; 
 
 
Plot1(HBKMoy+GapJcumu,"Moy HB"); 
Plot2(HBKHMoy+GapJcumu,"Bande Sup"); 
Plot3(HBKBMoy+GapJcumu,"Bande Inf"); 
 
if klargeurSup>0 then begin 
if HBKtendance>0 then setplotcolor(3,blue); 
if HBKtendance>0 then setplotcolor(2,blue); 
if HBKtendance>0 then setplotcolor(1,blue); 
 
end; 
if klargeuriNF<0 then begin 
if HBKtendance<0 then setplotcolor(1,red); 
if HBKtendance<0 then setplotcolor(2,red); 
if HBKtendance<0 then setplotcolor(3,red); 
end;
	// SuperTrend indicator 
inputs: 
ATRLength(10), ATRMult(3), UpColor(green), DnColor(red); 
vars: 
ATR(0), 
avg(0), 
dn(0), 
up(0), 
trend(1), 
flag(0), 
flagh(0), 
SuperTrend(0); 
ATR = AvgTrueRange(ATRLength) * ATRMult; 
avg = (high + low)/2; 
up = avg + ATR; 
dn = avg - ATR; 
if close > up[1] then 
trend = 1 
else if close < dn[1] then 
trend = -1; 
if trend < 0 and trend[1] > 0 then flag=1 else flag=0; 
if trend > 0 and trend[1] < 0 then flagh = 1 else flagh = 0; 
if trend > 0 and dn < dn[1] then dn=dn[1]; 
if trend < 0 and up > up[1] then up=up[1]; 
if flag = 1 then up = avg + ATR; 
if flagh = 1 then dn = avg - ATR; 
if trend = 1 then SuperTrend = dn else SuperTrend = up; 
Plot3(SuperTrend,"SuperTrend",iff(trend = 1, green, red));
	Supertrend on by Oliver Seban :
Code:INPUT: HBKTypPrxCentr(1),HBKTypPrxSort(2),HBKintrvp(1),klargeurSup(1.8),klargeurInf(-1.8),HBKLisp(10),GapJcumu(0); Input:typeCalcul(6); var: HBKPrxCentr(C),HBKPrxSort(C),HBKPlusH(0),HBKPlusB( 0),HB(0),AmplitudVrGIntHBK(0),HBKAtr(0), HBKMoy(0),HBKH(0),HBKB(0),HBKHMoy(0),HBKBMoy(0),HBKtendance(0), HBKLisIntrvp(HBKLisp*HBKintrvp),Maxccant(HBKLisIntrvp); HBKPlusH=HighestFC(HIGH,HBKintrvp); HBKPlusB=LowestFC(LOW,HBKintrvp); if HBKTypPrxCentr =1 then HBKPrxCentr=CLOSE; if HBKTypPrxCentr =2 then HBKPrxCentr=(HBKPlusH+HBKPlusB)*0.5; if HBKTypPrxCentr =3 then HBKPrxCentr=(HBKPlusH+HBKPlusB+CLOSE)/3; if HBKTypPrxCentr =4 then HBKPrxCentr=(HBKPlusH+HBKPlusB+CLOSE+OPEN[HBKintrvp-1]) *0.25; if HBKTypPrxCentr =5 then HBKPrxCentr=(HBKPlusH+HBKPlusB+CLOSE[HBKintrvp])/3 ; if HBKTypPrxCentr =6 then HBKPrxCentr=(HBKPlusH+HBKPlusB+CLOSE[HBKintrvp]+OPEN[HBKintrvp-1])*0.25; if HBKTypPrxSort =1 then HBKPrxSort=CLOSE; if HBKTypPrxSort =2 then HBKPrxSort=(HBKPlusH+HBKPlusB)*0.5; if HBKTypPrxSort =3 then HBKPrxSort=(HBKPlusH+HBKPlusB+CLOSE)/3; if HBKTypPrxSort =4 then HBKPrxSort=(HBKPlusH+HBKPlusB+CLOSE+OPEN[HBKintrvp -1])* 0.25; if HBKTypPrxSort =5 then HBKPrxSort=(HBKPlusH+HBKPlusB+CLOSE[HBKintrvp])/3; if HBKTypPrxSort =6 then HBKPrxSort=(HBKPlusH+HBKPlusB+CLOSE[HBKintrvp]+OPEN[HBKintrvp-1])*0.25; AmplitudVrGIntHBK=(maxlist(HBKPlusH,CLOSE[HBKintrvp]) -minlist(HBKPlusB,CLOSE[HBKintrvp]))*0.5; if HBKLisp>1 then begin if typeCalcul=1 then begin HBKMoy=average(HBKPrxCentr,HBKLisIntrvp); HBKAtr=average(AmplitudVrGIntHBK,HBKLisIntrvp); HBKHMoy=HBkmoy+klargeurSup*HBKAtr; HBKBMoy=HBkmoy+klargeurInf*HBKAtr; end; if typeCalcul=2 then begin HBKMoy=average(HBKPrxCentr,HBKLisIntrvp); HBKAtr=average(AmplitudVrGIntHBK,HBKLisIntrvp); HBKHMoy=HBkmoy+klargeurSup*HBKAtr;IF HBKTendance=-1 then HBKHmoy=minlist(HBKHmoy,HBKHmoy[1]); HBKBMoy=HBkmoy+klargeurInf*HBKAtr;;IF HBKTendance=1 then HBKBmoy=maxlist(HBKBmoy,HBKBmoy[1]); end; if typeCalcul=3 then begin HBKMoy=xaverage(HBKPrxCentr,HBKLisIntrvp); HBKAtr=xaverage(AmplitudVrGIntHBK,HBKLisIntrvp); HBKHMoy=HBkmoy+klargeurSup*HBKAtr; HBKBMoy=HBkmoy+klargeurInf*HBKAtr; end; if typeCalcul=4 then begin HBKMoy=Xaverage(HBKPrxCentr,HBKLisIntrvp); HBKAtr=Xaverage(AmplitudVrGIntHBK,HBKLisIntrvp); HBKHMoy=HBkmoy+klargeurSup*HBKAtr;IF HBKTendance=-1 then HBKHmoy=minlist(HBKHmoy,HBKHmoy[1]); HBKBMoy=HBkmoy+klargeurInf*HBKAtr;;IF HBKTendance=1 then HBKBmoy=maxlist(HBKBmoy,HBKBmoy[1]); end; if typeCalcul=5 then begin HBKMoy=Waverage(HBKPrxCentr,HBKLisIntrvp); HBKAtr=Waverage(AmplitudVrGIntHBK,HBKLisIntrvp); HBKHMoy=HBkmoy+klargeurSup*HBKAtr; HBKBMoy=HBkmoy+klargeurInf*HBKAtr; end; if typeCalcul=6 then begin HBKMoy=average(HBKPrxCentr,HBKLisIntrvp); HBKAtr=Waverage(AmplitudVrGIntHBK,HBKLisIntrvp); HBKHMoy=HBkmoy+klargeurSup*HBKAtr;IF HBKTendance=-1 then HBKHmoy=minlist(HBKHmoy,HBKHmoy[1]); HBKBMoy=HBkmoy+klargeurInf*HBKAtr;;IF HBKTendance=1 then HBKBmoy=maxlist(HBKBmoy,HBKBmoy[1]); end; end else begin HBKH=HBKPrxCentr+klargeurSup*AmplitudVrGIntHBK; HBKB=HBKPrxCentr+klargeurInf*AmplitudVrGIntHBK; HBKMoy=HBKPrxCentr; HBKHMoy=HBKH; HBKBMoy=HBKB; end; if HBKPrxSort>HBKHMoy then HBKtendance=1; if HBKPrxSort<HBKBMoy then HBKtendance=-1; Plot1(HBKMoy+GapJcumu,"Moy HB"); Plot2(HBKHMoy+GapJcumu,"Bande Sup"); Plot3(HBKBMoy+GapJcumu,"Bande Inf"); if klargeurSup>0 then begin if HBKtendance>0 then setplotcolor(3,blue); if HBKtendance>0 then setplotcolor(2,blue); if HBKtendance>0 then setplotcolor(1,blue); end; if klargeuriNF<0 then begin if HBKtendance<0 then setplotcolor(1,red); if HBKtendance<0 then setplotcolor(2,red); if HBKtendance<0 then setplotcolor(3,red); end;
There's another version - looks better, looks poor on choppy days though...
Code:// SuperTrend indicator inputs: ATRLength(10), ATRMult(3), UpColor(green), DnColor(red); vars: ATR(0), avg(0), dn(0), up(0), trend(1), flag(0), flagh(0), SuperTrend(0); ATR = AvgTrueRange(ATRLength) * ATRMult; avg = (high + low)/2; up = avg + ATR; dn = avg - ATR; if close > up[1] then trend = 1 else if close < dn[1] then trend = -1; if trend < 0 and trend[1] > 0 then flag=1 else flag=0; if trend > 0 and trend[1] < 0 then flagh = 1 else flagh = 0; if trend > 0 and dn < dn[1] then dn=dn[1]; if trend < 0 and up > up[1] then up=up[1]; if flag = 1 then up = avg + ATR; if flagh = 1 then dn = avg - ATR; if trend = 1 then SuperTrend = dn else SuperTrend = up; Plot3(SuperTrend,"SuperTrend",iff(trend = 1, green, red));
here´s the mt4 version of supertrend:
Supertrend - MQL4 Code Base
as i understand it, it´s basically a cci-variation, so maybe it´s better to use the cci directly.
but it looks good anyway.