Dark Theme
Light Theme
Trading Articles
Article Categories
Article Tools
Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to
register in order to view the content of the threads and start contributing to our community.
It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Division by Zero, how to debug
Updated September 30, 2010
Top Posters
looks_one
arjfca
with 3 posts (1 thanks)
looks_two
RJay
with 1 posts (1 thanks)
looks_3
Big Mike
with 1 posts (1 thanks)
looks_4
Quick Summary
with 1 posts (0 thanks)
Best Posters
looks_one
Big Mike
with 1 thanks per post
looks_two
RJay
with 1 thanks per post
looks_3
tarantino
with 1 thanks per post
looks_4
arjfca
with 0.3 thanks per post
trending_up
9,022 views
thumb_up
4 thanks given
group
2 followers
forum
6 posts
attach_file
0 attachments
Division by Zero, how to debug
September 29th, 2010, 01:44 PM
Montreal, Canada
Experience: Intermediate
Platform: Multicharts
Broker: Interactive Broker
Trading: Forex
Posts: 263 since Sep 2010
Thanks Given: 440
Thanks Received: 91
Hello
I'm writing my first line of codes in Easylanguage . When loading my Signal over the chart, i got an error message: Error in study " Name of my study" Exception Division by Zero)
How do I debug that.
I doid not found any code brake or variables report to help me to go down to the problem.
Any help appreciated
Martin
Can you help answer these questions from other members on NexusFi?
Best Threads (Most Thanked) in the last 7 days on NexusFi
September 29th, 2010, 01:59 PM
Manta, Ecuador
Site Administrator Developer Swing Trader
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,463 since Jun 2009
Thanks Given: 33,239
Thanks Received: 101,662
arjfca
Hello
I'm writing my first line of codes in
Easylanguage . When loading my Signal over the chart, i got an error message: Error in study " Name of my study" Exception Division by Zero)
How do I debug that.
I doid not found any code brake or variables report to help me to go down to the problem.
Any help appreciated
Martin
It would be helpful if you posted the code. But in general, you've probably got a defined var that is zero by default, and you've tried to divide another var into it. One way to debug is to add print statements every few lines in your code, so you can see where it is "making it" and where it stops. The output will be in the PL Editor output window.
Mike
September 29th, 2010, 06:57 PM
Hartford, CT. USA
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG, Kinetick
Trading: RTY
Posts: 683 since Jun 2009
Thanks Given: 758
Thanks Received: 787
arjfca
Hello
I'm writing my first line of codes in
Easylanguage . When loading my Signal over the chart, i got an error message: Error in study " Name of my study" Exception Division by Zero)
How do I debug that.
I doid not found any code brake or variables report to help me to go down to the problem.
Any help appreciated
Martin
Before executing Y/X, I always do a check. If X = 0, then, either set X to 1, or execute a "return".
September 30th, 2010, 05:50 AM
Montreal, Canada
Experience: Intermediate
Platform: Multicharts
Broker: Interactive Broker
Trading: Forex
Posts: 263 since Sep 2010
Thanks Given: 440
Thanks Received: 91
Here is a copy of the faulty function
The chart on the screen is a Forex one. This function is to determine if a bar as a hammer, using my definition. The return is a True Or False value.
The problem occur when i do the division to get the ratio between the tail and the body of the bar.
From my observation on the output windows, Var 's: are rounded to the second decimal, then calculated
So if Real value Displayed Value
High = 1.3672 1.37
Low 1.3651 1.37
Open 1.3657 1.37
Close 1.3664 1.37
If Body = Open - Close (1.37 - 1.37) = 0 instead of 0.0007
Code
{Hammer Fuction Return Hammer =True if all condition is met
Input: RBT: Ratio Bar / Tail // RBT: Ratio Body Tail
Output: Tail
Hammer (True or False) }
variables : RBT ( 0 ); // Ratio Bar tail
Variables : Double Length ( 0 ), Double Body ( 0 ), Double Tail ( 0 );
Variables : Double LBody ( 0 ), Double HBody ( 0 );
_Hammer = true ;
RBT = 0.99 ; // If = 1 then Body and Tail could be of equal length. Other Value may be tested
Body = absvalue ( open - close );
LBody = Minlist ( Close , Open ); // Slect the bottom price of the body
HBody = Maxlist ( close , open ); // Select the upper price of the body
Tail = LBody - Low ; // Tail = Lower part of the body - low of the bar
Print ( value1 , " " , High , " " , Low , " " , Open , " " , Close ); // for debugging only
Value1 = value1 + 1 ; // :: ::
If (( Body / Tail ) < RBT ) and ( close >= medianprice ) then _Hammer = true {The body as to be smaller than the tail by a determined ratio ( RBT)}
else begin
_Hammer = False ; //Actual ratio = Body / Tail. This as to be < then the targeted RBT
Tail = 0 ;
End
Any help appreciated
Martin
September 30th, 2010, 08:15 AM
Montreal, Canada
Experience: Intermediate
Platform: Multicharts
Broker: Interactive Broker
Trading: Forex
Posts: 263 since Sep 2010
Thanks Given: 440
Thanks Received: 91
Did resole this division proble by modifying my approach
Line
If (( Body / Tail ) < RBT ) and ( close >= medianprice ) then _Hammer = true
as been change for
If ( (Body* RBT ) <Tail) and (close >= medianprice) then _Hammer = true
Instead to divise, I multiply my ratio value to the body.
Work this tiime, not error displayed. Still have to work on the format
Martin
September 30th, 2010, 10:04 AM
Willowbrook, IL
Posts: 32 since Sep 2010
Thanks Given: 71
Thanks Received: 39
arjfca
Did resole this division proble by modifying my approach
Line
If (( Body / Tail ) < RBT ) and ( close >= medianprice ) then _Hammer = true
as been change for
If ( (Body* RBT ) <Tail) and (close >= medianprice) then _Hammer = true
Instead to divise, I multiply my ratio value to the body.
Work this tiime, not error displayed. Still have to work on the format
Martin
Mathematically you are incorrect:
Body/Tail < RBT should be changed to Body < Tail * RBT
Last Updated on September 30, 2010