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

Notification

Icon
Error

2 Pages12>
Options
Go to last post Go to first unread
wowaske  
#1 Posted : Tuesday, December 4, 2012 7:28:10 AM(UTC)
wowaske

Rank: Newbie

Groups: Registered, Registered Users
Joined: 12/4/2012(UTC)
Posts: 8

Could anyone please help me to solve the problem with the following code:
Code:

f1:=Mov((C-Ref(C,-1))*V,2,E);

f2:=Ref(Mov((C-Ref(C,-1))*V,2,E),-1);

f3:=(f1-f2);

f4:=Abs(f3);

f5:=If(f4=0, 0, If(f4<1,0,Log(f4)));


f6:=If(f3>=0, f5, -f5);

f6
I have tried many times on this exploration and found that if both f1 and f2 are zero, then this exploration will get into the problem with overflow in log() function. Could anyone please kindly help me to solve the problem? Many thanks wowaske
wowaske  
#2 Posted : Tuesday, December 4, 2012 7:38:48 AM(UTC)
wowaske

Rank: Newbie

Groups: Registered, Registered Users
Joined: 12/4/2012(UTC)
Posts: 8

I am sorry but I don't know why a part of my code disappeared in the post. Original code is: [code]f1:=Mov((C-Ref(C,-1))*V,2,E); f2:=Ref(Mov((C-Ref(C,-1))*V,2,E),-1); f3:=(f1-f2); f4:=Abs(f3); f5:=If(f4=0, 0, If(f4<1, 0, Log(f4))); f6:=If(f3>=0, f5, -f5); f6/[code]
wowaske  
#3 Posted : Tuesday, December 4, 2012 7:44:05 AM(UTC)
wowaske

Rank: Newbie

Groups: Registered, Registered Users
Joined: 12/4/2012(UTC)
Posts: 8

hmm... still missing a part f5:=if(f4=0,0,if(f4<1,0,Log(f4))); thanks
wowaske  
#4 Posted : Tuesday, December 4, 2012 8:22:26 AM(UTC)
wowaske

Rank: Newbie

Groups: Registered, Registered Users
Joined: 12/4/2012(UTC)
Posts: 8

called metastock online help why missing characters in post....and they said we are fixing it...
jjstein  
#5 Posted : Tuesday, December 4, 2012 10:23:24 AM(UTC)
jjstein

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 5/13/2005(UTC)
Posts: 715
Location: Midwest, USA

Was thanked: 1 time(s) in 1 post(s)
You need to use "tags" around any code; see below.
wowaske  
#6 Posted : Tuesday, December 4, 2012 10:45:39 AM(UTC)
wowaske

Rank: Newbie

Groups: Registered, Registered Users
Joined: 12/4/2012(UTC)
Posts: 8

Thanks but still missing characters
John S  
#7 Posted : Tuesday, December 4, 2012 11:39:40 AM(UTC)
John S

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 11/9/2012(UTC)
Posts: 169

We are working on a fix for the dropped character (less than sign) issue. I expect it to be fixed pretty soon.
wabbit  
#8 Posted : Tuesday, December 4, 2012 4:29:17 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)
MS is a fully evaluated scripting language, which means every part of every expression will be evaluated, which is why code like this fails:

Code:

num:=10;
den:=0;

result:=if(den<>0,num/den,0); {still produces DBZ errors!}

{plot}
result;


In your case, at some point you are passing zero to the Log() function, so check for the zero value BEFORE passing this value as the argument:

Code:

x:=0;
y:=if(x<=0,1,x); {y is never zero [edit] and always positive);

result:=if(x<=0,0,log(y)); {avoids attempting Log(0) overflow error}

{plot}
result;




wabbit [:D]

P.S. The forum reading code as HTML has been borked for years; despite many, many requests to fix it. If someone is actually looking at correcting the issue, they must ensure they fix it for all the different themes and editors which (for some bizarre reason) are included in the Community Server software. It's a one line fix for a phpBB system, but it's taken six years for this CS installation [:(]

P.P.S. Whilst you're at getting things fixed, please. please, please fix the search function and get rid of that pathetic Google implementation which doesn't work!

[edited] x in Log(x): x>0;

Admin  
#9 Posted : Tuesday, December 4, 2012 7:30:44 PM(UTC)
Admin

Rank: Member

Groups: Registered, Registered Users
Joined: 7/31/2006(UTC)
Posts: 15
Location: jack of all trades

I know its hard to believe, but I only heard about this about two months ago! Other duties prevented me from working on it; otherwise, I would have been quicker. It took a long time to find what was causing this, but here is what I know right now: 1. The text box control has to be updated. We have this update, but before I can release it: 2. I have to correct all forum posts that have been polluted by the problem; otherwise, if the new text box is used to edit them, they will be worse off. (this latter step has proven to be quite challenging) However, the new text box does seem to resolve the issue for new posts. This fix works for: IE, Chrome, Firefox, and Safari.
wowaske  
#10 Posted : Tuesday, December 4, 2012 7:44:58 PM(UTC)
wowaske

Rank: Newbie

Groups: Registered, Registered Users
Joined: 12/4/2012(UTC)
Posts: 8

wow amazing and thanks a lot wabbit
wowaske  
#11 Posted : Tuesday, December 4, 2012 7:46:13 PM(UTC)
wowaske

Rank: Newbie

Groups: Registered, Registered Users
Joined: 12/4/2012(UTC)
Posts: 8

Thanks a lot Administrator for your hard work too
Admin  
#12 Posted : Tuesday, December 4, 2012 7:48:25 PM(UTC)
Admin

Rank: Member

Groups: Registered, Registered Users
Joined: 7/31/2006(UTC)
Posts: 15
Location: jack of all trades

Thanks. Do the formulas above looked cleaned up now?
wabbit  
#13 Posted : Tuesday, December 4, 2012 7:55:02 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)
Looks better.


wabbit [:D]


Admin  
#14 Posted : Tuesday, December 4, 2012 8:06:21 PM(UTC)
Admin

Rank: Member

Groups: Registered, Registered Users
Joined: 7/31/2006(UTC)
Posts: 15
Location: jack of all trades

The plan right now is:

1. Clean up all the '<' botched posts I can find
2. Release the new text box editor so all browsers function the same
3. Make another clean up pass

The problem won't stop until #2 is done, but I have to do #1 first to keep the new text box editor from messing up old posts (if they are edited).

Then I will do #3 to catch any that are created before #2 is done.
wabbit  
#15 Posted : Tuesday, December 4, 2012 8:23:01 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)
Whilst there, perhaps you could also run an UPDATE query to find all the "temporary" CODE tags and replace them with "proper" BBcode CODE tags, and correct the formatting of the CODE blocks? Once users feel confident with using the same BBcode tags they have access to on other forums, they will use them here too.

TinyMCE has a "code" button which could be rolled out here, maybe (at least) with the "image" and "link" buttons too (unfortunately, FreeTextBox doesn't have the code button, time to change?)


wabbit [:D]

P.S. Sorry wowaske, for hijacking your thread!
wabbit  
#16 Posted : Tuesday, December 4, 2012 8:35:15 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)
For wowaske...

Code:

f1:=Mov((C-Ref(C,-1))*V,2,E);
f2:=ROC(f1,1,$);
f3:=Log(Max(1,Abs(f2)));

{plot}
If(f2>=0, f3, -f3);


In your code and in my code here, any change in f1 less than 1 (dollar) is ignored. This might be ok if this indicator is to be used on indexes and large value stocks, but it will return zero for every bar on a penny-dreadful; consider changing the ROC() function to % instead?



wabbit [:D]

Admin  
#17 Posted : Wednesday, December 5, 2012 6:19:20 AM(UTC)
Admin

Rank: Member

Groups: Registered, Registered Users
Joined: 7/31/2006(UTC)
Posts: 15
Location: jack of all trades

Actually, I meant the temporary code blocks to be permanent because Community Server's square bracketed code blocks (in this version before they jacked the price up to $40K, and yes, they did), weren't functioning correctly at the time. They didn't have plans to change that either.

Is the issue that people don't know to use the asterisk code blocks vs. the square bracketed version ? Because, I might be able to change that part. I could also make the asterisk code format differently as well.

As for TinyMCE, I know of it, but the CS version we have is strongly paired, I mean welded to, FreeTextBox.

thanks

Sorry for continuing the hijack. Perhaps we could continue over PM? Or another Thread?
wowaske  
#18 Posted : Wednesday, December 5, 2012 7:32:10 AM(UTC)
wowaske

Rank: Newbie

Groups: Registered, Registered Users
Joined: 12/4/2012(UTC)
Posts: 8

Thanks wabbit. I learned much from you (^^) And also thanks Admin too (^^)
wabbit  
#19 Posted : Wednesday, December 5, 2012 5:24:58 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)
wabbit wrote:
In your code and in my code here, any change in f1 less than 1 (dollar) is ignored. This might be ok if this indicator is to be used on indexes and large value stocks, but it will return zero for every bar on a penny-dreadful; consider changing the ROC() function to % instead?

Disregard... numpty alert.

As we're multiplying price by volume, even the smallest price change multiplied by any "reasonable" volume will result in a change of "valume" (price x volume) which will be greater than 1. To have a change in valume greater than one percent will probably be rarer than the one point change; leave ROC() as $, but keep this in the back of your mind if you're intending to use this concept on something like FX or some indexes.


wabbit [:D]

jjstein  
#20 Posted : Wednesday, December 5, 2012 5:25:31 PM(UTC)
jjstein

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 5/13/2005(UTC)
Posts: 715
Location: Midwest, USA

Was thanked: 1 time(s) in 1 post(s)
Admin wrote:
However, the new text box does seem to resolve the issue for new posts. This fix works for: IE, Chrome, Firefox, and Safari.
Will this fix make Message buttons appear for Chrome? I have to switch back to FireFox every time I want to insert a link.
Users browsing this topic
Guest (Hidden)
2 Pages12>
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.