Hello, I am looking for the PRT Ulcer Index Source Code?
Appreciate any help thanks so much!
Hi,
many thanks for the reply I used your code to build the ulcer index but for some reason I cant get the Ulcer Index to match the PRT one there are slight differences
Here is a pic of the differences any ideas how to get them the same?
Thanks a lot
Try this (I coded this from memory so didn’t check syntax or result in PRT):
N = 14
PD = ((Close - highest[N](close))/highest[N](close))*100
SquaredAverage = sqrt(summation[N](PD)/N)
UlcerIndex = sqrt(SquaredAverage)
@juanj
Line 3 should read:
SquaredAverage = (summation[N](sqr(PD))/N)
to replicate exactly PRT’s.
Thanks Robertogozzi, here is the corrected assembled code @flightclock91 can use:
N = 14
PD = ((Close - highest[N](close))/highest[N](close))*100
SquaredAverage = (summation[N](sqr(PD))/N)
UlcerIndex = sqrt(SquaredAverage)
Thank you so much robertogozzi and juanj
You guys are legends have been stuck on this for a while
When used in a strategy, I couldn’t get this to work, I got error message probacktest.error.’sqr’. It worked fine in an indicator though. However, changing sqr to square did the trick.
SquaredAverage = (summation[N](square(PD))/N)