WilderAverage Calculation
Forums › ProRealTime English forum › ProBuilder support › WilderAverage Calculation
- This topic has 9 replies, 1 voice, and was last updated 3 years ago by Daniele Maddaluno.
-
-
11/27/2016 at 7:12 PM #17320
Hello,
i want to rebuild the RSI Indikator of ProRealtime in Java. The ProRealtime Example is very helpful:
1234567891011121314151617181920REM Computes the daily variationsUP = MAX(0, close - close[1])DOWN = MAX(0, close[1] - close)REM Computes the moving average of gains on positive daysREM and losses on negative daysupMA = wilderAverage[p](UP)downMA = wilderAverage[p](DOWN)REM Now we can compute the RSRS = upMA / downMAREM And finally the RSImyRSI = 100 - 100 / (1 + RS)RETURN myRSI AS "Relative Strength Index"But i dont know how to calculate the wilderAverage. What code/formula belongs to the wilderAverage?
Thank you for help!
11/27/2016 at 7:30 PM #17321Found this formula on Internet :
EMA formula = price today * K + EMA yesterday * (1-K) where K = 2 / (N+1)
Wilder EMA formula = price today * K + EMA yesterday (1-K) where K =1/N
Where N = the number of periods.
Hope it helps you.
11/28/2016 at 10:14 PM #17421Not really 🙁
Easy Example with 3 Candles:
Candle1: Close 4897
Candle2: Close 4934
Candle3: Close 4951Value for Candle3
UP = MAX(0, close – close[1]) –> 4951 – 4934 –> 17
DOWN = MAX(0, close[1] – close) –> 4934 – 4951 –> -17upMA = wilderAverage[p](UP) –> wilderAverage[1](17) –> 17
downMA = wilderAverage[p](DOWN) –> wilderAverage[1](-17) –> 0upMA = wilderAverage[p](UP) –> wilderAverage[2](17) –> 20,87160 ???
downMA = wilderAverage[p](DOWN) –> wilderAverage[2](-17) –> 0,20206 ???upMA = wilderAverage[p](UP) –> wilderAverage[3](17) –> 19,65567 ???
downMA = wilderAverage[p](DOWN) –> wilderAverage[3](-17) –> 0,71841 ???I don’t get it…
The difference of the last two candle’s I have to put in the wilderAverage?
Maybe I can get the Code from ProRealtime as the RSI Example?
11/28/2016 at 10:19 PM #1742411/28/2016 at 11:03 PM #17430I’m a customer of IG Markets. I trade with the java api from IG Markets. But i get the signals manually from ProRealtime (with IG Data). The IG api has the possibility to get candle Stick data. Therefore i want to automate the generation of signals.
Thats the reason why i need the correct calculation of RSI from ProRealtime in my java application. Specially the calculation of the wilderaverage…the rest calculation of RSI is easy and clear.
I hope you understand…if not i have to post it in German.
11/29/2016 at 9:11 AM #17447That’s ok, I finally found the good formula and successfully recoded the same formula as the PRT one, here is the code:
12345678910111213141516171819//WilderMA is calculated for periods "n" as follows:////Wilder MA = ( Previous Wilder MA * ( n - 1 ) + DataSeries Value ) / n//////where,////n = number of periods//DataSeries Value = data you wish to averageonce WEMA = closeprice = closeN = 20if barindex>N THENWEMA = (WEMA[1]*(N-1)+price)/NendifRETURN WEMA11/29/2016 at 6:25 PM #17498I dont get it 🙁
here is my code to check the wilderAverage (its form the RSI example)
123456789101112REM Computes the daily variationsUP = MAX(0, close - close[1])DOWN = MAX(0, close[1] - close)REM Computes the moving average of gains on positive daysREM and losses on negative daysupMA = wilderAverage[p](UP)downMA = wilderAverage[p](DOWN)RETURN upMA,downMAYour code returns different values. I think the wilderAverage of ProRealtime returns the differents between the close prices, but i dont know how they are calculate…
Thanks for help!
11/29/2016 at 8:14 PM #1751411/29/2016 at 10:02 PM #1751803/15/2021 at 10:49 AM #164205I know it’s a really old post.
Anyway I’ll add the RSI with wilderAverage recoded here for people who will need that:RSI with wilderaverage recoded inside12345678910111213141516up = max(0, close - close[1])dn = max(0, close[1] - close)once mmUp = 0once mmDn = 0if barindex>1 then// wilderAverage formulasmmUp = mmUp[1] + (up - mmUp[1])/pmmDn = mmDn[1] + (dn - mmDn[1])/pendifrs = mmUp / mmDnrsindex = 100 - 100 / (1 + rs)return rsindex as "Relative Strength Index"It needs some bars to converge to the PRT RSI indicator.
1 user thanked author for this post.
-
AuthorPosts