NexusFi: Find Your Edge


Home Menu

 





Division by Zero, how to debug


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one arjfca with 3 posts (1 thanks)
    2. looks_two RJay with 1 posts (1 thanks)
    3. looks_3 Big Mike with 1 posts (1 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
      Best Posters
    1. looks_one Big Mike with 1 thanks per post
    2. looks_two RJay with 1 thanks per post
    3. looks_3 tarantino with 1 thanks per post
    4. looks_4 arjfca with 0.3 thanks per post
    1. trending_up 9,022 views
    2. thumb_up 4 thanks given
    3. group 2 followers
    1. forum 6 posts
    2. attach_file 0 attachments




 
Search this Thread

Division by Zero, how to debug

  #1 (permalink)
 arjfca 
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

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
About a successful futures trader who didn´t know anyth …
Psychology and Money Management
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
How to apply profiles
Traders Hideout
Cheap historycal L1 data for stocks
Stocks and ETFs
 
  #3 (permalink)
 
Big Mike's Avatar
 Big Mike 
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 View Post
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

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #4 (permalink)
 
RJay's Avatar
 RJay 
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 View Post
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".

Reply With Quote
Thanked by:
  #5 (permalink)
 arjfca 
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:DoubleLength(0),DoubleBody(0),DoubleTail(0);
Variables:DoubleLBody(0),DoubleHBody(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

Started this thread Reply With Quote
  #6 (permalink)
 arjfca 
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

Started this thread Reply With Quote
Thanked by:
  #7 (permalink)
tarantino
Willowbrook, IL
 
Posts: 32 since Sep 2010
Thanks Given: 71
Thanks Received: 39


arjfca View Post
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

Reply With Quote




Last Updated on September 30, 2010


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts