A request that was addressed to ProRealTime:
I have a function ConnorsRSI and would like to convert to ProRealCode
Function:
paramLenRSI = Param(“RSI Closes Length”, 3, 2, 100, 1);
paramLenUD = Param(“RSI UpClose Length”, 2, 2, 100, 1);
paramLenRank = Param(“PerecentRank Length”, 100, 10, 200, 1);
function ConnorsRSI(lenRSI, lenUD, lenROC)
{
upDays = BarsSince(C <= Ref(C,-1));
downDays = BarsSince(C >= Ref(C,-1));
updownDays = IIf(upDays > 0, upDays, IIf(downDays > 0, -downDays, 0));
crsi = ( PercentRank(ROC(C,1), lenROC) + RSIa(updownDays,lenUD) +
RSI(lenRSI))/3;
return crsi;
}
Can you help me?
Suggestion for an anwser:
PeriodRSI=3
PeriodUpdownlength=2
PeriodROC=100
Once UpLenght=0
Once DownLenght=0
Once updownDays=0
MyRSI=RSI[PeriodRSI](close)
MyROC=ROC[PeriodROC](close)
if barindex > 0 then
if close > close[1] then
upDay=1
downDay=0
elsif close < close[1] then
downDay=1
upDay=0
else
downDay=0
upDay=0
endif
if upDay <> 0 then
UpLenght=UpLenght[1] + upDay
else
UpLenght=0
endif
if downDay <> 0 then
DownLenght=DownLenght[1] + downDay
else
DownLenght=0
endif
updownDays = UpLenght + DownLenght
endif
MyRSILenght=RSI[PeriodUpdownlength](updownDays)
ConnorsRSI=(MyRSI+MyROC+MyRSILenght )/3
return ConnorsRSI
On peut rajouter les lignes de surachat / survente préconisées par Larry Connors de 10/90 en plus des traditionnelles 30/70 pour un RSI.
Hi, see below an update to the ConnersRSI version. The MyROC calculation above misses a component. Looking at several sources, the ROC of the current bar needs to be compared to each ROC of each bar in x-period (100 for connors).
PeriodRSI = 3
PeriodStreak = 2
PeriodROC = 100
Once DownBar=0
Once UpBar=0
Once UpDownBars=0
//Part 1 : Calculate RSI
MyRSI=RSI[PeriodRSI](close)
//Part 2 : Determine Streak Values and calculate a RSI over it
if barindex > 0 then
if close > close[1] then
UpBar=UpBar+1
DownBar=0
elsif close < close[1] then
DownBar=DownBar-1
UpBar=0
else
DownBar=0
UpBar=0
endif
UpDownBars = UpBar + DownBar
endif
MyRSILenght=RSI[PeriodStreak](UpDownBars)
//Part 3 : Determine PercentRank by comparing current percentage change to 100(PeriodROC) earlier 1-candle percentage changes
TodayROC = ROC[1](close)
EventTeller = 0
for i=0 to (PeriodROC-1) do
Earlier1DayROC = ROC[1](close[1+i])
if Earlier1DayROC < TodayROC THEN
//Count how many times an earlier 1 candle ROC was smaller then today's
EventTeller = EventTeller + 1
endif
next
PercentRank = (EventTeller / PeriodROC) * 100
//Part 4 : Calculate ConnersRSI
ConnorsRSI=(MyRSI+MyRSILenght+PercentRank )/3
return ConnorsRSI as "RSIConnors"