Hi,
From the article “Relative Strength Moving Averages ” in the latest issue of Stocks & Commodities Jan 2022 there is an interessting indicator called RS EMA. But it is written in METASTOCK code and look as follow:
Periods:=50;
Pds:=50;
Mltp:=10;
Mltp1:=2/(Periods+1);
Cup:=If(C>Ref(C,-1),C-Ref(C,-1),0);
Cdwn:=If(C<Ref(C,-1),Ref(C,-1)-C,0);
RS:=Abs(Mov(CUP,Pds,E)-Mov(Cdwn,Pds,E))/(Mov(CUP,Pds,E)+Mov(Cdwn,Pds,E)+0.00001);
RS:=RS*Mltp;
Rate:=Mltp1*(1+RS);
If(Cum(1)=Periods+1,C,PREV+Rate*(C-PREV));
It said this in RS EMA has less lags than the normal EMA (see attached png).
I have problem to translate the last line (line 11) to prorealcode. It seems a recusive. Can someone help?
Here is my code:
// From S&C Jan. 2022 "Relative Strength Moving Averages" - Vitali Apirine
Periods = 50
Pds = 50
Mltp = 10
Mltp1 = 2/(Periods+1)
if close >close[1] then
Cup = close - close[1]
else
Cup = 0
endif
if close < close[1] then
Cdwn = close[1] - close
else
Cdwn = 0
endif
EMAup = ExponentialAverage[Pds](Cup)
EMAdwn = ExponentialAverage[Pds](Cdwn)
RS1 = abs((EMAup - EMAdwn)/(EMAup + EMAdwn + 0.00001))
RS = RS1 * Mltp
Rate = Mltp1 * (1 + RS)
RETURN ???
This should be complete:
// From S&C Jan. 2022 "Relative Strength Moving Averages" - Vitali Apirine
Periods = 50
Pds = 50
Mltp = 10
Mltp1 = 2/(Periods+1)
if close >close[1] then
Cup = close - close[1]
else
Cup = 0
endif
if close < close[1] then
Cdwn = close[1] - close
else
Cdwn = 0
endif
EMAup = ExponentialAverage[Pds](Cup)
EMAdwn = ExponentialAverage[Pds](Cdwn)
RS1 = abs((EMAup - EMAdwn)/(EMAup + EMAdwn + 0.00001))
RS = RS1 * Mltp
Rate = Mltp1 * (1 + RS)
IF BarIndex <= (Periods + 1) THEN
ReturnedDatum = close
ELSE
ReturnedDatum = ReturnedDatum[1] + Rate * (close - ReturnedDatum[1])
ENDIF
RETURN ReturnDatum AS "RS Moving Average"
it s better like that
RETURN ReturnedDatum AS “RS Moving Average”
Hi,
Happy new Year 2022.
Sorry but for me i have this result.
What can i do ?
Thanks.
It was written incorrectly, this is the correct line:
RETURN ReturnedDatum AS “RS Moving Average”
Hi Roberto,
It’s what i wrote line 26 on my picture.
But not ok finally. Any solution ? 😉
Hi Choliver, you forgot one d when applying your correction in your line 26, this one in red: returnedDatum
Hello you 2,
I’m really sorry.
I am ashamed.
Thank you for the indication. 🙂
It’s ok now
Great day.