Autoenvelope

If you need an Indicator or Signal developed or translated from other language, please post all Indicator development REQUESTS to this section here.

Moderator: admin

Autoenvelope

Postby twitjaksono » Sat Jul 24, 2010 2:32 pm

Hi everybody.

I was looking for indicator called "autoenvelope" that automatically adjusts the channel. On other site, I found the formula for it on Metastock:
Code: Select all
---------------------------------------------------------------------------------------------------------------------
{Dr A. Elder's AutoEnvelope interpretation v1.0}

{ User inputs }
pds:=Input("EMA periods",1,252,21);
pdsBak:=Input("lookback periods",1,252,42);
x:=Input("use: Open=1, High=2, Low=3, Close=4, WClose=5",1,5,4);
plot:=Input("[1]AutoEnvelope, [2]Long signals, [3]All signals",1,3,1);
delay:=Input("Entry/Exit signals delay",0,5,0);

{ Price field }
x:=If(x=1,O,If(x=2,H,If(x=3,L,If(x= 5,WC(),C))));

{ Envelope bands }
Avg:=Mov(x,pds,E);
hiAvg:=HHV(H,pdsBak);
loAvg:=LLV(L,pdsBak);
shift:=
Mov(If(hiAvg>Avg,hiAvg-Avg,Avg-loAvg),pds,E);
UpperBand:=Avg+shift;
LowerBand:=Avg-shift;

{ Envelope signals }
In:=Cross(x,LowerBand);
Out:=Cross(x,UpperBand);
Init:=Cum(In+Out>-1)=1;
InInit:=Cum(In)=1;
flag:=BarsSince(Init OR In)
<BarsSince(Init OR Out)+InInit;
signals:=Ref((InInit AND Alert(InInit=0,2)
OR flag AND Alert(flag=0,2))
-(flag=0 AND Alert(flag,2)),-delay);

{ Plot envelope on price chart }
If(plot=1,UpperBand,If(plot=2,signa ls,In-Out));
If(plot=1,Avg,If(plot=2,0,0));
If(plot=1,LowerBand,If(plot=2,signa ls,In-Out))
---------------------------------------------------------------------------------------------------------------------

Also this is the definition:
Envelope channels are set parallel to the moving average (parallel to the slow MA if you
use two MAs). The two channel lines must contain approximately 90-95% of all prices
for the past two or three months between them, with only the extremes protruding
outside. Envelope channels provide attractive profit targets – sell longs near the upper
channel line and cover shorts near the lower channel line.
The AutoEnvelope is a custom indicator - an original tool that automatically sizes
channels by calculating a standard deviation for the last 100 bars. It is designed to
change value at most once a week, making it suitable even for intra-day data.

· Base EMA (22) – This is the number of bars for the Exponential Moving Average plotted in the center of the channel.
· Factor (27) – This is the number of standard deviations (expressed in the tenths)
for creating the channel. Statistically, 2.7 is the proper size to use, but that
assumes a standard distribution, which is not always present in the markets. We
find that 27 works for most stocks using daily data, but you may want to adjust
this Factor to fit your trading vehicle and style.
--------------------------------------------------------------------------------------------------------------------
Perhaps somebody can help developing this indicator for Marketscope?

Thanks a lot beforehand.
twitjaksono
 
Posts: 7
Joined: Wed May 12, 2010 11:17 pm

Re: Autoenvelope

Postby Nikolay.Gekht » Wed Aug 04, 2010 5:02 pm

Sorry, this post somehow was not registered in the development queue. But, ok, now we're working on it.

The first problem I can see that the code shown in the post does not match to the description. I ported the code, without signals, so you can check whether it is the thing you expected to have.

ElderAutoEnv.lua
(3.56 KiB) Downloaded 839 times


Please also check this metastock formula, which, as far as I can see matches your description better:
Code: Select all
EMA:=Input("Base EMA",1,100,22);
Factor:=Input("Factor",1,50,27);
avg:=Mov(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;


I take it here:
http://www.traderji.com/amibroker/7299- ... post141225
Nikolay.Gekht
FXCodeBase: Site Admin
 
Posts: 1235
Joined: Wed Dec 16, 2009 6:39 pm
Location: Cary, NC

Re: Autoenvelope

Postby twitjaksono » Wed Aug 04, 2010 11:39 pm

Thanks for your help. I sure am excited to try it out. :)
twitjaksono
 
Posts: 7
Joined: Wed May 12, 2010 11:17 pm


Return to Indicator and Signal Requests

Who is online

Users browsing this forum: Bing [Bot] and 26 guests