Hi Stuart
I meant to reply to your post earlier but other tasks have had to take
priority. A little while ago I did some work on Connors RSI for a client, and
while I'm not sure that my code is correct either, there are a couple of things
here that might be useful to yourself or other readers.
My initial Connors RSI code use PREV to avoid the long-winded method of
producing the ranking component, but when asked to make a non-PREV version I
found that it could all be contained within the one indicator. I also managed
to incorporate an adjustable lookback range, but more on that in a minute.
I'm guessing that the biggest obstacle you ran into was MetaStock's limit of 40
constants, and I have to admit that this is a real pain. Nevertheless it is
possible to get around that obstacle. The code below is a reworked version of
your "Connors RSI Working 1" and does away with the need for the #2 and #3
indicators.
As an example notice that the expression "-50-9" can be used as a substitute
for the constant "-59". As a rule I usually limit the number of constants about
30 and then use 40, 50, 60 and so on with an appropriate modifying constant to
generate all the values required. I'm quite sure that the rest of the indicator
can also be squeezed into less than 2500 characters so that the entire "Connors
RSI" is held in just one formula.
I notice that your three "Working" indicators only add up to 99 comparisons
against the current ROC value. For the code below I've added a 100th
comparison, and with that both our formulas produce the same result from this
element.
As regards adjusting the lookback range, each element can be included or
excluded from the total by multiplying each element by lookback range component.
For example, this section of code could be changed to accommodate a lookback
extreme of between 90 and 100.
(ox>Ref(x,-80-9))+(x>Ref(x,-90))+
(x>Ref(x,-90-1))+(x>Ref(x,-90-2))+
(x>Ref(x,-90-3))+(x>Ref(x,-90-4))+
(x>Ref(x,-90-5))+(x>Ref(x,-90-6))+
(x>Ref(x,-90-7))+(x>Ref(x,-90-8))+
(x>Ref(x,-90-9))+(x>Ref(x,-100));
And here's how it might look after adding the lookback control. Applying that
method to all 100 comparisons will force the use of a second indicator simply
because of limited space.
(x>Ref(x,-80-9))+ (N80+9)*(x>Ref(x,-90))+
(N>90)*(x>Ref(x,-90-1))+ (N>90+1)*(x>Ref(x,-90-2))+
(N>90+2)*(x>Ref(x,-90-3))+ (N>90+3)*(x>Ref(x,-90-4))+
(N>90+4)*(x>Ref(x,-90-5))+ (N>90+5)*(x>Ref(x,-90-6))+
(N>90+6)*(x>Ref(x,-90-7))+ (N>90+7)*(x>Ref(x,-90-8))+
(N>90+8)*(x>Ref(x,-90-9))+ (N>90+9)*(x>Ref(x,-100));
Well, that's my two pennyworth; I hope it helps someone :-)
Regards
Roy
{Connors RSI Working 1}
x:=ROC(C,1,%);
(x>Ref(x,-1))+(x>Ref(x,-2))+(x>Ref(x,-3))+
(x>Ref(x,-4))+(x>Ref(x,-5))+(x>Ref(x,-6))+
(x>Ref(x,-7))+(x>Ref(x,-8))+(x>Ref(x,-9))+
(x>Ref(x,-10))+(x>Ref(x,-11))+(x>Ref(x,-12))+
(x>Ref(x,-13))+(x>Ref(x,-14))+(x>Ref(x,-15))+
(x>Ref(x,-16))+(x>Ref(x,-17))+(x>Ref(x,-18))+
(x>Ref(x,-19))+(x>Ref(x,-20))+(x>Ref(x,-21))+
(x>Ref(x,-22))+(x>Ref(x,-23))+(x>Ref(x,-24))+
(x>Ref(x,-25))+(x>Ref(x,-26))+(x>Ref(x,-27))+
(x>Ref(x,-28))+(x>Ref(x,-29))+(x>Ref(x,-30))+
(x>Ref(x,-30-1))+(x>Ref(x,-30-2))+
(x>Ref(x,-30-3))+(x>Ref(x,-30-4))+
(x>Ref(x,-30-5))+(x>Ref(x,-30-6))+
(x>Ref(x,-30-7))+(x>Ref(x,-30-8))+
(x>Ref(x,-30-9))+(x>Ref(x,-40))+
(x>Ref(x,-40-1))+(x>Ref(x,-40-2))+
(x>Ref(x,-40-3))+(x>Ref(x,-40-4))+
(x>Ref(x,-40-5))+(x>Ref(x,-40-6))+
(x>Ref(x,-40-7))+(x>Ref(x,-40-8))+
(x>Ref(x,-40-9))+(x>Ref(x,-50-0))+
(x>Ref(x,-50-1))+(x>Ref(x,-50-2))+
(x>Ref(x,-50-3))+(x>Ref(x,-50-4))+
(x>Ref(x,-50-5))+(x>Ref(x,-50-6))+
(x>Ref(x,-50-7))+(x>Ref(x,-50-8))+
(x>Ref(x,-50-9))+(x>Ref(x,-60))+
(x>Ref(x,-60-1))+(x>Ref(x,-60-2))+
(x>Ref(x,-60-3))+(x>Ref(x,-60-4))+
(x>Ref(x,-60-5))+(x>Ref(x,-60-6))+
(x>Ref(x,-60-7))+(x>Ref(x,-60-8))+
(x>Ref(x,-60-9))+(x>Ref(x,-70-0))+
(x>Ref(x,-70-1))+(x>Ref(x,-70-2))+
(x>Ref(x,-70-3))+(x>Ref(x,-70-4))+
(x>Ref(x,-70-5))+(x>Ref(x,-70-6))+
(x>Ref(x,-70-7))+(x>Ref(x,-70-8))+
(x>Ref(x,-70-9))+(x>Ref(x,-80))+
(x>Ref(x,-80-1))+(x>Ref(x,-80-2))+
(x>Ref(x,-80-3))+(x>Ref(x,-80-4))+
(x>Ref(x,-80-5))+(x>Ref(x,-80-6))+
(x>Ref(x,-80-7))+(x>Ref(x,-80-8))+
(x>Ref(x,-80-9))+(x>Ref(x,-90))+
(x>Ref(x,-90-1))+(x>Ref(x,-90-2))+
(x>Ref(x,-90-3))+(x>Ref(x,-90-4))+
(x>Ref(x,-90-5))+(x>Ref(x,-90-6))+
(x>Ref(x,-90-7))+(x>Ref(x,-90-8))+
(x>Ref(x,-90-9))+(x>Ref(x,-100));
----- Original Message -----
From: stuart_yg123
To: [email protected]
Sent: Friday, March 08, 2013 2:02 AM
Subject: [EquisMetaStock Group] Re: ConnorsRSI
I converted the Amibroker code ex
http://www.marketcalls.in/amibroker/larry-connors-rsi-amibroker-afl-code.html
I made a change to the upDays and downDays lines by commenting out the equals
sign. I don't think the equals is correct based on reading the guide from
http://analytics.tradingmarkets.com/ConnorsRSI/
I required 4 indicators for the calculations. Hope my coding is correct.
Regards
Stuart
{Connors RSI Working 1}
x:=ROC(C,1,%);
If(x>Ref(x,-1),1,0)+
If(x>Ref(x,-2),1,0)+
If(x>Ref(x,-3),1,0)+
If(x>Ref(x,-4),1,0)+
If(x>Ref(x,-5),1,0)+
If(x>Ref(x,-6),1,0)+
If(x>Ref(x,-7),1,0)+
If(x>Ref(x,-8),1,0)+
If(x>Ref(x,-9),1,0)+
If(x>Ref(x,-10),1,0)+
If(x>Ref(x,-11),1,0)+
If(x>Ref(x,-12),1,0)+
If(x>Ref(x,-13),1,0)+
If(x>Ref(x,-14),1,0)+
If(x>Ref(x,-15),1,0)+
If(x>Ref(x,-16),1,0)+
If(x>Ref(x,-17),1,0)+
If(x>Ref(x,-18),1,0)+
If(x>Ref(x,-19),1,0)+
If(x>Ref(x,-20),1,0)+
If(x>Ref(x,-21),1,0)+
If(x>Ref(x,-22),1,0)+
If(x>Ref(x,-23),1,0)+
If(x>Ref(x,-24),1,0)+
If(x>Ref(x,-25),1,0)+
If(x>Ref(x,-26),1,0)+
If(x>Ref(x,-27),1,0)+
If(x>Ref(x,-28),1,0)+
If(x>Ref(x,-29),1,0)+
If(x>Ref(x,-30),1,0)+
If(x>Ref(x,-31),1,0)+
If(x>Ref(x,-32),1,0)+
If(x>Ref(x,-33),1,0)
{Connors RSI Working 2}
x:=ROC(C,1,%);
If(x>Ref(x,-34),1,0)+
If(x>Ref(x,-35),1,0)+
If(x>Ref(x,-36),1,0)+
If(x>Ref(x,-37),1,0)+
If(x>Ref(x,-38),1,0)+
If(x>Ref(x,-39),1,0)+
If(x>Ref(x,-40),1,0)+
If(x>Ref(x,-41),1,0)+
If(x>Ref(x,-42),1,0)+
If(x>Ref(x,-43),1,0)+
If(x>Ref(x,-44),1,0)+
If(x>Ref(x,-45),1,0)+
If(x>Ref(x,-46),1,0)+
If(x>Ref(x,-47),1,0)+
If(x>Ref(x,-48),1,0)+
If(x>Ref(x,-49),1,0)+
If(x>Ref(x,-50),1,0)+
If(x>Ref(x,-51),1,0)+
If(x>Ref(x,-52),1,0)+
If(x>Ref(x,-53),1,0)+
If(x>Ref(x,-54),1,0)+
If(x>Ref(x,-55),1,0)+
If(x>Ref(x,-56),1,0)+
If(x>Ref(x,-57),1,0)+
If(x>Ref(x,-58),1,0)+
If(x>Ref(x,-59),1,0)+
If(x>Ref(x,-60),1,0)+
If(x>Ref(x,-61),1,0)+
If(x>Ref(x,-62),1,0)+
If(x>Ref(x,-63),1,0)+
If(x>Ref(x,-64),1,0)+
If(x>Ref(x,-65),1,0)+
If(x>Ref(x,-66),1,0)
{Connors RSI Working 3}
x:=ROC(C,1,%);
If(x>Ref(x,-67),1,0)+
If(x>Ref(x,-68),1,0)+
If(x>Ref(x,-69),1,0)+
If(x>Ref(x,-70),1,0)+
If(x>Ref(x,-71),1,0)+
If(x>Ref(x,-72),1,0)+
If(x>Ref(x,-73),1,0)+
If(x>Ref(x,-74),1,0)+
If(x>Ref(x,-75),1,0)+
If(x>Ref(x,-76),1,0)+
If(x>Ref(x,-77),1,0)+
If(x>Ref(x,-78),1,0)+
If(x>Ref(x,-79),1,0)+
If(x>Ref(x,-80),1,0)+
If(x>Ref(x,-81),1,0)+
If(x>Ref(x,-82),1,0)+
If(x>Ref(x,-83),1,0)+
If(x>Ref(x,-84),1,0)+
If(x>Ref(x,-85),1,0)+
If(x>Ref(x,-86),1,0)+
If(x>Ref(x,-87),1,0)+
If(x>Ref(x,-88),1,0)+
If(x>Ref(x,-89),1,0)+
If(x>Ref(x,-90),1,0)+
If(x>Ref(x,-91),1,0)+
If(x>Ref(x,-92),1,0)+
If(x>Ref(x,-93),1,0)+
If(x>Ref(x,-94),1,0)+
If(x>Ref(x,-95),1,0)+
If(x>Ref(x,-96),1,0)+
If(x>Ref(x,-97),1,0)+
If(x>Ref(x,-98),1,0)+
If(x>Ref(x,-99),1,0)
{Connors RSI}
PdsRSI:=Input("RSI Close Length",1,100,3);
PdsUD:=Input("RSI UpDown Length",1,100,2);
PdsRank:=100;
UpDays:=BarsSince(C<{=}Ref(C,-1));
DownDays:=BarsSince(C>{=}Ref(C,-1));
UpDownDays:=If(upDays>0,upDays,If(downDays>0,-downDays,0));
cRSI:=(
(Fml("Connors RSI Working 1")+
Fml("Connors RSI Working 2")+
Fml("Connors RSI Working 3"))/100+
ExtFml("Forum.RSI",UpDownDays,PdsUD)+
ExtFml("Forum.RSI",C,PdsRSI))/3;
cRSI;
--- In [email protected], "distinque" <distinque@...> wrote:
>
> Has anyone worked up ConnorsRSI in MS and be willing to share?
>
> Thanks
>
Reply via web post Reply to sender Reply to group Start a New Topic
Messages in this topic (3)
Recent
__________ Information from ESET NOD32 Antivirus, version of virus signature
database 8118 (20130314) __________
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com