How can I find where "Error in Study..." occurs?

Questions about MultiCharts and user contributed studies.
RWDickinson
Posts: 43
Joined: 01 Dec 2008
Has thanked: 2 times
Been thanked: 2 times

How can I find where "Error in Study..." occurs?

Postby RWDickinson » 28 Jan 2009

This question has probably been asked before, but I couldn't find it. I am getting an error message occasionally when I run [Optimize], but never when I put specific values into [Format]. Error is: "Error in study <study_name>: {EXCEPTION} Floating-point invalid operation". I assume this is a divide-by-zero error, but I can't find any place in my code that does that (I always use "if denominator<>0...." guard code).

My question: how can I find out where (which function, what line of code) the error occurs so that I can fix this?

User avatar
Marina Pashkova
Posts: 2758
Joined: 27 Jul 2007

Postby Marina Pashkova » 29 Jan 2009

Hi Rob,

Some of your input values are causing this error. To find out which particular values result in the floating point error, please insert the following lines into your code:

Code: Select all

if currentbar=1 then
begin
Print(input values)
end;
This will allow you to find out what input values result in the floating point error when your indicator is calculated.

RWDickinson
Posts: 43
Joined: 01 Dec 2008
Has thanked: 2 times
Been thanked: 2 times

Postby RWDickinson » 29 Jan 2009

OK, knowing the parameters that are triggering the error, I guess I need to use the print-statement method to find out where that error is occurring? Wow, I guess I've been spoiled by real languages (you know, the kind that give you real error messages). Oh, well.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Postby TJ » 29 Jan 2009

you can always post your code.

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Postby bowlesj3 » 30 Jan 2009

You could wish upon a star that some day (maybe 15 years from now) MC will have a debugger with break and step functions (only available during off-line mode so that at the end of the code it would get the next tick to execute the next cycle through the code). Now that would be really cool. Gee, I might actually be able to fully automate my discretionary trading system with that one.

Tip. If you want it within 10 years you need to wish upon the biggest star you can find. :-)

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Postby TJ » 30 Jan 2009

I have a 3,500 line indicator, and I have no problem debugging.
It all starts with good programming habits,
including...
traceable structure,
variable capture at all junctures,
re-test variables at all junctures.



p.s. this is not to say a debugger is useless or not desirable.

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Postby bowlesj3 » 30 Jan 2009

It is all a matter of speed and actually nothing more. If one has used a print statement one has used a debugger (a very crude debugger). Everyone has had many bugs and had to use a debugger many times. I have had to work with programs with over 10,000 lines of code with management breathing down my back, no documentation at all, and a need to get it fixed in 1 hour and it is not my program. One needs a lot of speed in that situation. It can let you know that you have chosen the wrong 10,000 line program to find the bug. Speed is good.

Here is a great example. The MicroFocus cobol debugger can run at 10 speeds. From step to fast to full speed (no debugger). You just hit the number 1 to 0 for these speeds. One of the best programmers could not figure out why her program was locking up. The manager knew I took the time to learn the debugger well. He asked me to help her. I had her run her program on the debugger at full speed until she thought it was locked. We changed the speed and she could see the infinit loop right there in front of her. Total time to find it was about 5 minutes when she had spent hours before that. It is silly to not use a tool like that when it is available.

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Postby bowlesj3 » 30 Jan 2009

So come to think of it, if TS-Support could ever get a debugger as good as the MicroFocus Cobol debugger in their product (for off line debugging) and TS does not have a debugger like that you can sure guess where the traders are going to start moving to. Of course if TS-Support can ever do that MC is already going to be an amazing program.
Last edited by bowlesj3 on 30 Jan 2009, edited 1 time in total.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Postby TJ » 30 Jan 2009

yeah!

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Postby bowlesj3 » 30 Jan 2009

I agree. It will never happen but it is nice to dream. I think IBM's money was behind that debugger.

brodnicki steven
Posts: 407
Joined: 01 Jan 2008
Been thanked: 3 times

Postby brodnicki steven » 30 Jan 2009

+1 on the debugger

janus
Posts: 835
Joined: 25 May 2009
Has thanked: 63 times
Been thanked: 104 times

Postby janus » 10 Sep 2009

+1 on the debugger
+1million for even a simple debugger. I'd be happy with just a run time error that display the line number of the code where the error occurred. Would have saved me many hours of time. I too used debuggers in many languages (Fortran, C, C++, VB, VC++, java, perl; some with the Eclipse IDE), and now use FreeBasic a lot with FBIde for the IDE. Interesting to note that array bounds checking is always on - most compilers have an option to turn it off to speed things up; that would be a useful feature too.


Return to “MultiCharts”