Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
Henry,
First:
If my code is correct the values should be between 0-100 (inclusive). If not then something is wrong! Try, with some more modifications, the following code for the indicator.
Secondly:
I am curious to find out how you use this indicator?
You cannot just set a 'threshold level' at which to trigger buys and sells. As the stock price rises over time, the value of the indicator gets smaller (numerator/CLOSE) and vice versa for when the stock price gets progressively lower, the indicator gets larger.
The only real way I see to use this indicator is to track it over time and see how it is 'performing' against "recent" history, either through the use of moving average bands or standard error bands. A buy signal could be generated when the indicator breaks through the top of the band, and sell if breaks down through the bottom of the band. The length and width of the bands may need some careful consideration.
If you could shed some light, I would be interested.
--8<---------------------------------------
{Modified Ulcer Index, with channels}
{Original code from Henry1224}
{Modified by wabbit 06 April 2005}
pds1:= Input("Ulcer ATR Periods",1,100,10);
pds2:= Input("Ulcer MA periods",1,2550,200);
{removed redundant '000s from the Henry1224 formula}
a:=Mov(ATR(pds1),pds2,S)/C;
b:=a-LastValue(Lowest(a));
x:=100*b/LastValue(Highest(b));
pds3:=Input("Channel MA periods:",1,2560,100);
ma:=Input("Channel MA type: 1-EMA 2-SMA",1,2,2);
ma:=If(ma=1,Mov(x,pds3,E),Mov(x,pds3,S));
lookback:=Input("Channel SD lookback: 0-All History, User",0,252,0);
pds4:=LastValue(If(lookback=0,1,lookback));
SD:=If(lookback=0,Sqrt(Cum(Power(x-ma,2))/Cum(1)),Sqrt(Sum(Power(x-ma,2),pds4)/pds4));
UL2:=If(ma+(2*SD)>100,100,ma+(2*SD));
LL2:=If(ma-(2*SD)<=0,0,ma-(2*SD));
UL3:=If(ma+(3*SD)>100,100,ma+(3*SD));
LL3:=If(ma-(3*SD)<=0,0,ma-(3*SD));
{Plot indicators}
x;
LastValue(Highest(x));
LastValue(Lowest(x));
ma;
UL2;LL2;
UL3;LL3;
--8<---------------------------------------
Hope this helps
wabbit :D
|
1 user thanked wabbit for this useful post.
|
|