BullCharts Forum Homepage
Forum Home Forum Home > BullCharts > BullCharts discussion
  New Posts New Posts RSS Feed: Supertrend
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Supertrend

 Post Reply Post Reply
Author
Message / View First Unread Post
SayaPolo View Drop Down
Newbie
Newbie


Joined: 19 Nov 2018
Location: Sydney
Posts: 10
Post Options Post Options   Quote SayaPolo Quote  Post ReplyReply Direct Link To This Post Topic: Supertrend
    Posted: 08 Jul 2019 at 12:54pm
Hi all,

Has anyone coded into BullChart the Supertrend indicator? I would like to use it as either as a Trend trading indicator or as a stop, similar to the Parabolic SAR. I found this in the internet but not sure how to code this into BullChart.

The supertrend indicator calculation goes as stated below-

 

Up = (high + low / 2 + multiplier  x  ATR

Down = (high + low) / 2 – multiplier x ATR

 

Calculation of Average True Range –

[(Prior ATR x 13) + Current TR] / 14

 

Here, 14 indicates a period. Hence, the ATR is derived by multiplying the previous ATR with 13. Add the latest TR and divide it by period.


Greatful for any assistance.

Cheers,

SayaPolo


Back to Top
davidr View Drop Down
Newbie
Newbie


Joined: 19 Oct 2004
Location: Australia
Posts: 13
Post Options Post Options   Quote davidr Quote  Post ReplyReply Direct Link To This Post Posted: 10 Jul 2019 at 12:24pm
Hi SayaPolo,

There is a discussion of the supertrend indicator in a J B Volatility profit taker thread from sometime back, which can be found here:

http://www.bullcharts.com.au/forum/forum_posts.asp?TID=433&PN=4&title=j-b-volatility-profit-taker

and Maximo coded it up as an indicator for bullcharts like this:

>G'day Jeremy,
 
>I've updated the code, more accurate and simplified, no repaint. 
 
 

[Description="SuperTrend - Max"]

[target=price]

Mult:=Input("ATR Multiplier",3,1);

Nb:=Input("Nb Periods",8,1);

method:=inputma("Method",Wilders);

price:=Input("1=Median, 2=Close",1,1);

TruRan:=ma(ATR(1),Nb,method)*Mult;

HiLimit:=if(price=1,(H+L)/2-TruRan,C-TruRan);

LoLimit:=if(price=1,(H+L)/2+TruRan,C+TruRan);

LB:=If(HiLimit>=PREV and HiLimit<C,HiLimit,If(C<PREV,HiLimit-0.1,PREV));

UB:=If(LoLimit<PREV and LoLimit>C,LoLimit,If(C>PREV,LoLimit+0.1,PREV));

Trend:=if(UB>ref(UB,-1),1,if(LB<ref(LB,-1),-1,prev));

[drawundefined=gap]

[Color=lime green]

if(Trend=1 and hist(Trend,1)=-1,LB,if(Trend=-1,UB,undefined));

[Color=red]

if(Trend=-1 ,UB,if(hist(Trend,1)=1 ,LB,undefined));

[Color=lime green]

if(Trend=1 or Trend=0,LB,undefined);

{ Paint bars}

Flag:=input("PaintBars On=1, Off=0",0,0,1);

[linestyle=pricecolor; color=rgb(98,217,98)]

If(Trend=1 and Flag=1,1,if(Flag=0 and C>O,1,undefined));

[color=rgb(226,118,118)] {red}

If(Trend=-1 and Flag=1,1,if(Flag=0 and C<=O,1,undefined));


>Edited by maximo - 09 Feb 2011 at 2:04am

Regards
davidr


davidr
Back to Top
maximo View Drop Down
BullCharts Guru
BullCharts Guru
Avatar

Joined: 02 Sep 2006
Location: Australia
Posts: 232
Post Options Post Options   Quote maximo Quote  Post ReplyReply Direct Link To This Post Posted: 19 Jul 2019 at 7:08pm
This is a simplified version that may work better.

{ Stop Trail ATR }
[Target=price]
atrper :=Input("ATR period: ",14);
atrfact:=Input("ATR multiplier: ",2);
loss:=atrfact*ATR(atrper);
trail:=
If(C>PREV and Ref(C,-1)>PREV, Max(PREV,C-loss),
If(C<PREV and Ref(C,-1)<PREV, Min(PREV,C+loss),
If(C>PREV, C-loss, C+loss)));
Trail;
[linestyle=pricecolor]
[color=rgb(0,174,0)] if(C>=Trail,1,0);
[color=rgb(255,85,85)] if(C<Trail,1,0);


----------------------------------------------------------------

Also Wilder had a volatility stop which includes highs and lows.

{ Wilder Volatility Stop Trail }
[Target=price]
Mult:=Input("ATR Multiplier",2.2,1);
Nb:=if(Mult<3,7,Int(Mult*2+1));
Long :=Ref(HHV(C,Nb),-1) - (Ref(ATR(Nb),-1)*Mult);
Short:=Ref(LLV(C,Nb),-1) + (Ref(ATR(Nb),-1)*Mult);
trail:=
If(C>PREV and Ref(C,-1)>PREV, Max(PREV,Long),
If(C<PREV and Ref(C,-1)<PREV, Min(PREV,Short),
If(C>PREV, Long, Short)));
Trail;
[linestyle=pricecolor]
[color=rgb(0,174,0)] if(C>=Trail,1,0);
[color=rgb(255,85,85)] if(C<Trail,1,0);
 
Back to Top
SayaPolo View Drop Down
Newbie
Newbie


Joined: 19 Nov 2018
Location: Sydney
Posts: 10
Post Options Post Options   Quote SayaPolo Quote  Post ReplyReply Direct Link To This Post Posted: 20 Jul 2019 at 8:33am
Hi Davidr and Maximo,

Thank you both so much for your replies.

Maximo, Thanks again for your coding. You are a true Guru and really appreciate your time and effort in assisting the community of traders.

Cheers,
SayaPolo
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.69
Copyright ©2001-2010 Web Wiz