Nicolas

Daily timeframe SuperTrend on intraday chart

Category: Indicators By: Nicolas Created: January 19, 2017, 11:21 AM
January 19, 2017, 11:21 AM
Indicators
4 Comments
Daily timeframe SuperTrend on intraday chart

This is an attempt to draw the SuperTrend indicator made of daily OHLC values on inferior timeframe for intraday trading.

The idea came from a recent forum post where someone wanted to draw Average True Range information on intraday charts. Since SuperTrend is mainly made of ATR, here is the final result of my research on this. You already know that multi timeframe support is still not available for ProBuilder, so the result may differ a bit from the true daily timeframe SuperTrend. ATR is normally calculated with a Wilder Average, but I’m using a simple moving average here, that’s why you may notice differences. But, because I found it would be valuable, that’s why I’m sharing the indicator with the community.

If someone has an idea to calculate the real Wilder Average from daily OHLC in an intraday timeframe, I’d be pleased to help 🙂

 

//PRC_Daily SuperTrend | indicator
//19.01.2017
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge

// --- parameters
//multiplier=3
//period=10
// ---

dTR = 0

for i = 0 to period
 dTR=dTR+max(abs(Dhigh(i)-Dlow(i)),max(abs(Dhigh(i)-Dclose(i+1)),abs(Dlow(i)-Dclose(i+1))))
next

moy = dTR/period

price=(dhigh(0)+dlow(0))/2
up=price+multiplier*moy
dn=price-multiplier*moy
once trend=1
if Dclose(0)>up[1] then
 trend=1
elsif Dclose(0)<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: PRC_Daily-SuperTrend.itf
Downloads: 252
Nicolas
Nicolas Legend
I created ProRealCode because I believe in the power of shared knowledge. I spend my time coding new tools and helping members solve complex problems. If you are stuck on a code or need a fresh perspective on a strategy, I am always willing to help. Welcome to the community!
Author’s Profile

Comments

verdi55
10 years ago
#

Working with separately calculated supertrend indicators in backtests is usually somewhat problematic, because calculation times are extremely long compared to the built-in supertrend indicator (something between 10 to 50 times longer, in my experience). It may be more practical to use the built-in supertrend for backtests and to modify buy and sell conditions : For example, set stop buy orders to the value of the last supertrend. Or : exclude buy entries when the supertrend is crossed (at the end of a bar) by a very short amount only, and try to enter later. This saves a lot of calculation time compared to calculating a supertrend oneself.  

 

I have used the DEMA instead of Wilder's average for supertrend calculation (see the separate entry for the supertrend indicator) and got slightly better results in some cases, but this is paid again by a huge increase in calculation time. Also, using the average of the medianprice of the last two bars instead of the medianprice of the last bar only can smooth the supertrend and thus gives less signals. For very simple and short trading systems, this may lead to acceptable calculation time, but not for more complex ones on shorter timescales. 

Nicolas
10 years ago
#

Very interesting Verdi. Would be a great addition to the library, your own modified version of the Super trend! Even if you don't add it, I'll have look myself to this kind of calculation, thanks. 

Lyny
10 years ago
#

something wrong, I import the code file .itf into indicator to load, but there is only 1 straight line at bottom indicator area. It does not look as your picture. Can you check your code or advice me to do correctly. I am using Prorealtime v10.2. Even I tried load the indicator on Price but nothing draw out at all.

Nicolas
10 years ago
#

You need to have enough bars loaded on your chart for the indicator to compute completely the daily timeframe.

ProRealCode ProRealCode
Loading...