Discussions
»
Product and Service Development
»
Formula Assistance
»
Please need help on solving error:overflow in log() function
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
|
|
|
|
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]
|
|
|
|
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
|
|
|
|
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...
|
|
|
|
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.
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users Joined: 12/4/2012(UTC) Posts: 8
|
Thanks but still missing characters
|
|
|
|
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.
|
|
|
|
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;
|
|
|
|
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.
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users Joined: 12/4/2012(UTC) Posts: 8
|
wow amazing and thanks a lot wabbit
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users Joined: 12/4/2012(UTC) Posts: 8
|
Thanks a lot Administrator for your hard work too
|
|
|
|
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?
|
|
|
|
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)
|
|
|
|
|
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.
|
|
|
|
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!
|
|
|
|
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]
|
|
|
|
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?
|
|
|
|
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 (^^)
|
|
|
|
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]
|
|
|
|
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)
|
Discussions
»
Product and Service Development
»
Formula Assistance
»
Please need help on solving error:overflow in log() function
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.