logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
alexk01  
#1 Posted : Friday, April 20, 2012 2:47:58 PM(UTC)
alexk01

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 4/20/2012(UTC)
Posts: 1

I have been trying to code the Ulcer Ratio in Metastock. Here is the pseudo-code for it: SumSq = 0 MaxValue = 0 for T = 1 to NumOfPeriods do if Value[T] > MaxValue then MaxValue = Value[T] else SumSq = SumSq + sqr(100 * ((Value[T] / MaxValue) - 1)) UI = sqrt(SumSq / NumOfPeriods) Is it possible to code this in Metastock? If not, any guidance on what I would need to do to get this to work using a DLL would be greatly appreciated. Thank you!
wabbit  
#2 Posted : Friday, April 20, 2012 6:42:51 PM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
Rewriting between proper code tags and formatting, we get:
Code:

SumSq = 0;
MaxValue = 0;

for T = 1 to NumOfPeriods
{
 if Value[T] > MaxValue
 MaxValue = Value[T]
 else
 SumSq = SumSq + sqr(100 * ((Value[T] / MaxValue) - 1))

 UI = sqrt(SumSq / NumOfPeriods)
}


You've got several problems, the main one is with the 'else' condition, which you should want to evaluate on every pass.

Anyway, does this help?

http://srsc.com.vn/metastock-codes/e-w-Ulcer_Index.html
Users browsing this topic
Guest (Hidden)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.