Henry

SuperTrend

Category: Indicators By: Henry Created: May 13, 2016, 10:04 AM
May 13, 2016, 10:04 AM
Indicators
4 Comments
SuperTrend

This indicator is the ProBuilder version of the SuperTrend Indicator. SuperTrend is available by default in the ProRealTime workstation but this ProBuilder version can be useful to create custom versions of the indicator.

If you want to use the standard SuperTrend indicator in Market Scan (ProScreener) or a Trading system, it’s easier to just use the ProBuilder function.

You can download the code directly at the bottom of the page.

If you prefer to add it manually to your workstation, here is the code.

For v10.3 and above:

//This indicator contains functions that can only be used with ProRealTime v10.3 and above.
//If you use a previous version of ProRealTime, use the other version of the Indicators. multiplier=3 period=10 moy=averagetruerange[period](close) price=medianprice up=price+multiplier*moy dn=price-multiplier*moy once trend=1 if close>up[1] then trend=1 elsif close<dn[1] then trend=-1 endif if trend<0 and trend[1]>0 then flag=1 else flag=0 endif if trend>0 and trend[1]<0 then flagh=1 else flagh=0 endif if trend>0 and dn<dn[1] then dn=dn[1] endif if trend<0 and up>up[1] then up=up[1] endif if flag=1 then up=price+multiplier*moy endif if flagh=1 then dn=price-multiplier*moy endif if trend=1 then mysupertrend=dn else mysupertrend=up endif if mysupertrend > mysupertrend[1] then color1=0 color2=255 color3=0 elsif mysupertrend < mysupertrend[1] then color1=255 color2=0 color3=0 endif return mysupertrend coloured (color1,color2,color3) as "SuperTrend"

For v10.2 and below:

//This indicator is for ProRealTime v10.2 and previous versions.
//If you use version 10.3 or above, use the other indicator that includes the color or the SuperTrend
multiplier=3
period=10

moy=averagetruerange[period](close)
price=medianprice
up=price+multiplier*moy
dn=price-multiplier*moy
once trend=1
if close>up[1] then
trend=1
elsif close<dn[1] then
trend=-1
endif
if trend<0 and trend[1]>0 then
flag=1
else
flag=0
endif
if trend>0 and trend[1]<0 then
flagh=1
else
flagh=0
endif
if trend>0 and dn<dn[1] then
dn=dn[1]
endif
if trend<0 and up>up[1] then
up=up[1]
endif
if flag=1 then
up=price+multiplier*moy
endif
if flagh=1 then
dn=price-multiplier*moy
endif
if trend=1 then
mysupertrend=dn
else
mysupertrend=up
endif

return mysupertrend coloured by (trend) as "SuperTrend"

Download
Filename: SupreTrend-v10.1-and-v10.2.itf
Downloads: 86
Download
Filename: SuprerTrend-v10.3-and-above.itf
Downloads: 425
Henry
Henry Average
Hi! I'm moderating the English speaking forum on my free time. I'll try to answer your questions as good as I can and I also post the answers to code requests that were addressed directly to ProRealTime.
Author’s Profile

Comments

verdi55
10 years ago
#

Thank you. After a restart, it is somewhat faster; however, it still takes about 3 minutes to load for the full DAX 1 min chart. Here is my own version of the supertrend that loads about 6-7 faster. Still, in a backtest, using this manual code for supertrend instead of the built-in version increases calculation time of the backtest by a factor of 20. So, this is not very advisable and suitable only for testing custom supertrends, not so much for parameter optimization. 

ONCE Richtung = 1
ONCE STlongalt = 0
ONCE STshortalt = 1000000000000

per = 10
Faktor = 3

indicator1 = medianprice

indicator2 = averagetruerange[per] * Faktor

STlong = indicator1 - indicator2

STshort = indicator1 + indicator2

If Richtung = 1 and STlong < STlongalt then
STlong = STlongalt
endif

If Richtung = -1 and STshort > STshortalt then
STshort = STshortalt
endif

If barindex > 2 and Richtung = 1 and close crosses under STlong then
Richtung = -1
endif

If barindex > 2 and Richtung = -1 and close crosses over STshort then
Richtung = 1
endif

STlongalt = STlong

STshortalt = STshort

If Richtung = 1 then
ST = STlong
endif

If Richtung = -1 then
ST = STshort
endif

Return ST coloured by (Richtung) as "Supertrend"

 

Nicolas
10 years ago
#

Good! thanks for sharing your own code! Please do so with other ones if you think you can improve them ;)

verdi55
10 years ago
#

This indicator is exteremly slow. In a full DAX 1 min chart (~ 8 months), calculation takes more than 10 minutes, whereas the normal built-in supertrend is immediately there. What is the reason ? Too many if-then-else loops ? In a trading strategy, it would be almost impossible to use. 

Nicolas
10 years ago
#

Exit and relaunch PRT should fix this behavior.

ProRealCode ProRealCode
Loading...