How to translate the metastock code to prorealcode (indicator RS EMA)?
Forums › ProRealTime English forum › ProBuilder support › How to translate the metastock code to prorealcode (indicator RS EMA)?
- This topic has 8 replies, 5 voices, and was last updated 2 years ago by Choliver.
Tagged: average, Moving, relative, Relative strength moving average, strength
-
-
12/23/2021 at 9:22 AM #183798
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:
1234567891011Periods:=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?
12/23/2021 at 4:50 PM #183815Here is my code:
1234567891011121314151617181920212223242526272829// From S&C Jan. 2022 "Relative Strength Moving Averages" - Vitali ApirinePeriods = 50Pds = 50Mltp = 10Mltp1 = 2/(Periods+1)if close >close[1] thenCup = close - close[1]elseCup = 0endifif close < close[1] thenCdwn = close[1] - closeelseCdwn = 0endifEMAup = ExponentialAverage[Pds](Cup)EMAdwn = ExponentialAverage[Pds](Cdwn)RS1 = abs((EMAup - EMAdwn)/(EMAup + EMAdwn + 0.00001))RS = RS1 * MltpRate = Mltp1 * (1 + RS)RETURN ???12/23/2021 at 5:48 PM #183817This should be complete:
1234567891011121314151617181920212223242526// From S&C Jan. 2022 "Relative Strength Moving Averages" - Vitali ApirinePeriods = 50Pds = 50Mltp = 10Mltp1 = 2/(Periods+1)if close >close[1] thenCup = close - close[1]elseCup = 0endifif close < close[1] thenCdwn = close[1] - closeelseCdwn = 0endifEMAup = ExponentialAverage[Pds](Cup)EMAdwn = ExponentialAverage[Pds](Cdwn)RS1 = abs((EMAup - EMAdwn)/(EMAup + EMAdwn + 0.00001))RS = RS1 * MltpRate = Mltp1 * (1 + RS)IF BarIndex <= (Periods + 1) THENReturnedDatum = closeELSEReturnedDatum = ReturnedDatum[1] + Rate * (close - ReturnedDatum[1])ENDIFRETURN ReturnDatum AS "RS Moving Average"1 user thanked author for this post.
12/26/2021 at 1:30 PM #183846it s better like that
RETURN ReturnedDatum AS “RS Moving Average”1 user thanked author for this post.
01/02/2022 at 2:55 PM #18433701/02/2022 at 3:16 PM #184344It was written incorrectly, this is the correct line:
1RETURN ReturnedDatum AS “RS Moving Average”01/03/2022 at 1:20 AM #18437501/03/2022 at 9:11 AM #184382Hi Choliver, you forgot one d when applying your correction in your line 26, this one in red: returnedDatum
1 user thanked author for this post.
01/03/2022 at 1:43 PM #184398 -
AuthorPosts