SuperTrend formula

leovirgo

Senior member
Messages
3,161
Likes
156
Does anybody know the formula of SuperTrend? It is used in ProRealtime's Probuilder software. I think it is developed by O Seban. I need the codes for TradeStation. thanks..
 
cc

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
 
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
Hi Sandeep,

Shall I create cc as a variable ( numeric) ..?
Like that?
Var: cc ( 0 )

And My TradeStation (v.8.1) does not understand HC, BC and OC. Are they user functions or abbreviated EL terms such as Highest Close ??? thanks.
 
Pro Realtime Super Trend

Hi everyone,

Does anyone have the Pro Realtime Super Trend coded for excel. I have seen versions coded for Metastock, but I would like to do some bulk backtesting on historic tick data.

Thanks
 
this is the real supertrend.

REM this is the supertrend found in pro realstation ... YOU CAN COPY THIS AS NEW INDIACTOR AND CHECK IT OUT. IT IS EXACTLY THE SAME.

rem the periode is set to 3 but you can make a parameter of it see a= ...
rem the factor is set to 1.1 but you can make a parameter of it see b= ...



a = AverageTrueRange[3](close)
b = 1.1
if barindex < 3 then
T = 1
L1 = low
H1 = high

else
if T[1] = 1 then
if close > L1[1] then
L1 = MAX(L1[1],medianprice - a*b)
ST = L1
else
H1 = medianprice + a*b
ST = H1
T = -1
endif
else
if close <H1[1] then
H1 = MIN(H1[1],medianprice + a*b)
ST = H1
else
L1 = medianprice - a* b
ST = L1
T = 1
endif
endif
endif
return st
 
what doess T stand for? can someone convert this to TradeStation codes? thanks
 
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));
 
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));

O Seban version doesn't seem to be the one I find on Prorealtime & CMC MMsoftware!
It plots three lines in stead of just one that switches as the price breaks out up or down.
 
hi cooldent, the link shouldn´t be broken, it works for me. otherwise try the search on mql4.com, you´ll find it then.
 
I'm with you Genics, also have Tradestation, and would like to know the best working version in Easy Language. Thanks in advance for any help with it.

Curtis
 
Top