Supertrend |
Post Reply |
Author | ||
SayaPolo
Newbie Joined: 19 Nov 2018 Location: Sydney Posts: 10 |
Post Options
Quote Reply
Topic: Supertrend 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
|
||
maximo
BullCharts Guru Joined: 02 Sep 2006 Location: Australia Posts: 232 |
Post Options Quote Reply 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); |
||
davidr
Newbie Joined: 19 Oct 2004 Location: Australia Posts: 13 |
Post Options Quote Reply 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
|
||
SayaPolo
Newbie Joined: 19 Nov 2018 Location: Sydney Posts: 10 |
Post Options Quote Reply Posted: 08 Jul 2019 at 12:54pm | |
|
||
Post Reply |
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |