Auto Envelopes |
Post Reply |
Author | |
Bana
Regular Joined: 02 Jan 2007 Location: Australia Posts: 46 |
Post Options
Quote Reply
Topic: Auto Envelopes Posted: 11 Apr 2009 at 9:35am |
Hi All
Below is formula in Metastock for Autoenvelopes as discussed in Alexander Elder's books. Is it possible to convert them to bullscript? thanks {user inputs} pds:=input("EMA
periods", 21,
1, 252); pdsBak:=input("lookback
periods", 42,
1, 252); x:=input("use: Open=1,
High=2, Low=3, Close=4, WClose=5", 4, 1,
5); plot:=input("[1]AutoEnvelope,
[2]Long signals, [3]All signals", 1, 1,
3); delay:=input("Entry/Exit
signals delay", 0, 0, 5); x:=If(x=1,O,If(x=2,H,If(x=3,L,If(x=5,WC(),C)))); shift:= ma(If(hiAvg>Avg,hiAvg-Avg,Avg-loAvg),pds,E); <BarsSince(Init OR
Out)+InInit; signals:=Ref((InInit AND
Alert(InInit=0,2) -(flag=0 AND
Alert(flag,2)),-delay); { Plot envelope on price
chart } If(plot=1,UpperBand,If(plot=2,signals,In-Out)); If(plot=1,Avg,If(plot=2,0,0)); If(plot=1,LowerBand,If(plot=2,signals,In-Out)); Edited by Bana - 11 Apr 2009 at 9:36am |
|
Bana
Regular Joined: 02 Jan 2007 Location: Australia Posts: 46 |
Post Options Quote Reply Posted: 12 Apr 2009 at 4:52pm |
Got this MS formula for the same thing from another web source. The parameters of this
look more closer to description in the book, as compared to the previous formula so please ignore it. EMA:=input("Base EMA", 22, 1, 100); Factor:=input("Factor", 27, 1, 50); avg:=ma(C,EMA,E); csize:= Stdev(2*Max(Abs(H-avg) ,Abs(L-avg)) / avg,100)*Factor/10; {Use 100 days for stable channel size - default is 2.7 std} Csize:= ValueWhen(1, DayOfWeek()<Ref(DayOfWeek() ,-1) OR ( DayOfWeek()=Ref(DayOfWeek(),-1) AND DayOfMonth() <> Ref(DayOfMonth(),-1)) ,Ref(csize,-1)); { This pegs the Stdev to last bar of week and only changes once per week} csize:=LastValue(csize); {fix to constant using last value} channel:=csize*avg; avg+channel/2; avg-channel/2; avg; |
|
maximo
BullCharts Guru Joined: 02 Sep 2006 Location: Australia Posts: 232 |
Post Options Quote Reply Posted: 12 Apr 2009 at 11:46pm |
Okay, there you go, looks okay for testing a breakout strategy. [target =price]EMA:= input("Base EMA",22,1);Factor:= input("Factor",27,1);avg:= ma(C,EMA,E);asize:= Stdev(2*Max(Abs(H-avg) ,Abs(L-avg)) / avg,100)*Factor/10; {Use 100 days for stable channel size - default is 2.7 std}bsize:= ValueWhen(1, DayOfWeek()<Ref(DayOfWeek() ,-1) OR ( DayOfWeek()=Ref(DayOfWeek(),-1) AND DayOfMonth() <> Ref(DayOfMonth(),-1)) ,Ref(asize,-1)); { This pegs the Stdev to last bar of week and only changes once per week}csize:= LastValue(bsize); {fix to constant using last value}channel:=csize*avg; avg+channel/2; avg-channel/2; avg;
|
|
Bana
Regular Joined: 02 Jan 2007 Location: Australia Posts: 46 |
Post Options Quote Reply Posted: 13 Apr 2009 at 12:28pm |
Thanks Maximo. You are a genius with Bullscript.
I am trying to follow Dr Alexander Elder's short term trading within the channels, as described in 'Come into my Trading Room. |
|
maximo
BullCharts Guru Joined: 02 Sep 2006 Location: Australia Posts: 232 |
Post Options Quote Reply Posted: 18 Apr 2009 at 7:46pm |
I will have a read of his book :)
Here's a link to a report & a couple of videos which present the idea of combining all 3 market conditions into 1 trading plan using a channel.
Actually there's also a few mechanical systems that have been using this idea for over 15 years in the live market. eg. R-breaker + R-Levels by Richard Saidenberg and Cyclone system by Clayburg.
Edited by maximo - 18 Apr 2009 at 11:39pm |
|
Bana
Regular Joined: 02 Jan 2007 Location: Australia Posts: 46 |
Post Options Quote Reply Posted: 01 Sep 2010 at 9:51pm |
Hi Maximo
The formula in your post 159 above --- is it possible to fill the channel with any color? cheers Bana |
|
maximo
BullCharts Guru Joined: 02 Sep 2006 Location: Australia Posts: 232 |
Post Options Quote Reply Posted: 03 Sep 2010 at 10:21pm |
Yes, just add these 2 lines onto the end of that code.
[name =Envelope Fill; linestyle=fill; color=blue]avg+channel/2; avg-channel/2; |
|
Bana
Regular Joined: 02 Jan 2007 Location: Australia Posts: 46 |
Post Options Quote Reply Posted: 06 Sep 2010 at 9:57am |
Thanks........it works great.
|
|
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 |