Try/Catch Method Challenge/Mistery - EasyLanguage Programming | futures io social day trading
futures io futures trading


Notices

Try/Catch Method Challenge/Mistery
Updated: Views / Replies:157 / 6
Created: by eronyx Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 100,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

Try/Catch Method Challenge/Mistery

  #1 (permalink)
Trading Apprentice
Moldova
 
Futures Experience: Intermediate
Platform: TradeStation
Favorite Futures: Emini ES
 
Posts: 8 since Nov 2017
Thanks: 5 given, 0 received

Try/Catch Method Challenge/Mistery

Hi guys

I am trying to write/delete a file couple of times per minute. I have try/catch inside code but my strategy keeps getting stopped with the following error:

 
Code
Error:elsystem.NullObjectException: Object Reference not set to an instance of an object. Call Stack: MyStrat.myf_writetofile()
The strategy runs couple of days, then suddenly shuts down
can anyone spot what is the issue here? Been trying for couple of months to figure it out. It usually stop at elsystem.io.StreamWriter.Create step. The file it tried to create could be accessed by other software.

BUT - the MAIN question here is why Try Catch not working? it just avoids it and stops the strategy, Really getting crazy here

 
Code
Try	
Begin
    			file = elsystem.io.StreamWriter.Create("C:\........\Files\Final.csv");    			
    	End;	
    Catch (elsystem.NullObjectException ex)	Begin						 
				Print(" File Create +" + ex.ToString()+" MSG: "+ex.Message.ToString()+" Type "+ex.InnerException.ToString());						
			End;
	Catch (elsystem.io.IOException ex1)	Begin						 
				Print(" File Create IO Except +" + ex1.ToString()+" MSG: "+ex1.Message.ToString()+" Type "+ex1.InnerException.ToString());						
			End;			
    End;
    
    
    Try	Begin
    			file.Write(NewGDtoFile);    			
    	End;	
    Catch (elsystem.NullObjectException ex)	Begin						 
				Print(" File Write +" + ex.ToString()+" MSG: "+ex.Message.ToString()+" Type "+ex.InnerException.ToString());						
			End;
	Catch (elsystem.io.IOException ex1)	Begin						 
				Print(" File Write IO Except +" + ex1.ToString()+" MSG: "+ex1.Message.ToString()+" Type "+ex1.InnerException.ToString());							
			End;			
    End;
    
   
    Try	Begin
    			file.Close();    			
    	End;
    Catch (elsystem.NullObjectException ex)	Begin						 
				Print(" File Close NULL +" + ex.ToString()+" MSG: "+ex.Message.ToString()+" Type "+ex.InnerException.ToString());						
			End;		
    Catch (elsystem.io.IOException ex1)	Begin						 
				Print(" File Close IO Except " + ex1.ToString()+" MSG: "+ex1.Message.ToString()+" Type "+ex1.InnerException.ToString());						
			End;	
    End;
Thank You

Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Elite Member
charlotte nc
 
Futures Experience: Master
Platform: ninjatrader
Broker/Data: NinjaTrader
Favorite Futures: Emini (ES, YM, NQ, ect.)
 
Posts: 341 since Jan 2015
Thanks: 61 given, 721 received


Very generically I can tell you that you are hitting a null value error. So you need to check and make sure your variable / object is not null before you call it.

For example this throws an error:

double testvariable = 0;

testvariable = null;

if (testvarialbe > 1)
{
// do something
}


So you have to check if it is null first before you evaluate it.

I am not sure where you are hitting your error in your code:
"Error:elsystem.NullObjectException: Object Reference not set to an instance of an object." But whatever line is throwing this error, just check your variable to make sure it is not null and you should be fine.

Happy Coding!

Ian








eronyx View Post
Hi guys

I am trying to write/delete a file couple of times per minute. I have try/catch inside code but my strategy keeps getting stopped with the following error:

 
Code
Error:elsystem.NullObjectException: Object Reference not set to an instance of an object. Call Stack: MyStrat.myf_writetofile()
The strategy runs couple of days, then suddenly shuts down
can anyone spot what is the issue here? Been trying for couple of months to figure it out. It usually stop at elsystem.io.StreamWriter.Create step. The file it tried to create could be accessed by other software.

BUT - the MAIN question here is why Try Catch not working? it just avoids it and stops the strategy, Really getting crazy here

 
Code
Try	
Begin
    			file = elsystem.io.StreamWriter.Create("C:\........\Files\Final.csv");    			
    	End;	
    Catch (elsystem.NullObjectException ex)	Begin						 
				Print(" File Create +" + ex.ToString()+" MSG: "+ex.Message.ToString()+" Type "+ex.InnerException.ToString());						
			End;
	Catch (elsystem.io.IOException ex1)	Begin						 
				Print(" File Create IO Except +" + ex1.ToString()+" MSG: "+ex1.Message.ToString()+" Type "+ex1.InnerException.ToString());						
			End;			
    End;
    
    
    Try	Begin
    			file.Write(NewGDtoFile);    			
    	End;	
    Catch (elsystem.NullObjectException ex)	Begin						 
				Print(" File Write +" + ex.ToString()+" MSG: "+ex.Message.ToString()+" Type "+ex.InnerException.ToString());						
			End;
	Catch (elsystem.io.IOException ex1)	Begin						 
				Print(" File Write IO Except +" + ex1.ToString()+" MSG: "+ex1.Message.ToString()+" Type "+ex1.InnerException.ToString());							
			End;			
    End;
    
   
    Try	Begin
    			file.Close();    			
    	End;
    Catch (elsystem.NullObjectException ex)	Begin						 
				Print(" File Close NULL +" + ex.ToString()+" MSG: "+ex.Message.ToString()+" Type "+ex.InnerException.ToString());						
			End;		
    Catch (elsystem.io.IOException ex1)	Begin						 
				Print(" File Close IO Except " + ex1.ToString()+" MSG: "+ex1.Message.ToString()+" Type "+ex1.InnerException.ToString());						
			End;	
    End;
Thank You


In the analytical world there is no such thing as art, there is only the science you know and the science you don't know. Characterizing the science you don't know as "art" is a fools game.
Reply With Quote
The following user says Thank You to iantg for this post:
 
  #4 (permalink)
 Vendor: www.abctradinggroup.com 
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,846 since Apr 2013
Thanks: 301 given, 1,130 received
Forum Reputation: Legendary

eronyx,

did you post the entire method code? What happens if you place your method call inside a try catch statement, without trying to catch a specific exception?
 
Code
try
 myf_writetofile() ; //your method in here
catch (elsystem.exception ex)
   Print("ex = " + ex.ToString());
end ;
Regards,

ABCTG




eronyx View Post
Hi guys

I am trying to write/delete a file couple of times per minute. I have try/catch inside code but my strategy keeps getting stopped with the following error:

 
Code
Error:elsystem.NullObjectException: Object Reference not set to an instance of an object. Call Stack: MyStrat.myf_writetofile()
The strategy runs couple of days, then suddenly shuts down
can anyone spot what is the issue here? Been trying for couple of months to figure it out. It usually stop at elsystem.io.StreamWriter.Create step. The file it tried to create could be accessed by other software.

BUT - the MAIN question here is why Try Catch not working? it just avoids it and stops the strategy, Really getting crazy here

 
Code
Try	
Begin
    			file = elsystem.io.StreamWriter.Create("C:\........\Files\Final.csv");    			
    	End;	
    Catch (elsystem.NullObjectException ex)	Begin						 
				Print(" File Create +" + ex.ToString()+" MSG: "+ex.Message.ToString()+" Type "+ex.InnerException.ToString());						
			End;
	Catch (elsystem.io.IOException ex1)	Begin						 
				Print(" File Create IO Except +" + ex1.ToString()+" MSG: "+ex1.Message.ToString()+" Type "+ex1.InnerException.ToString());						
			End;			
    End;
    
    
    Try	Begin
    			file.Write(NewGDtoFile);    			
    	End;	
    Catch (elsystem.NullObjectException ex)	Begin						 
				Print(" File Write +" + ex.ToString()+" MSG: "+ex.Message.ToString()+" Type "+ex.InnerException.ToString());						
			End;
	Catch (elsystem.io.IOException ex1)	Begin						 
				Print(" File Write IO Except +" + ex1.ToString()+" MSG: "+ex1.Message.ToString()+" Type "+ex1.InnerException.ToString());							
			End;			
    End;
    
   
    Try	Begin
    			file.Close();    			
    	End;
    Catch (elsystem.NullObjectException ex)	Begin						 
				Print(" File Close NULL +" + ex.ToString()+" MSG: "+ex.Message.ToString()+" Type "+ex.InnerException.ToString());						
			End;		
    Catch (elsystem.io.IOException ex1)	Begin						 
				Print(" File Close IO Except " + ex1.ToString()+" MSG: "+ex1.Message.ToString()+" Type "+ex1.InnerException.ToString());						
			End;	
    End;
Thank You


Reply With Quote
The following user says Thank You to ABCTG for this post:
 
  #5 (permalink)
 Vendor: www.abctradinggroup.com 
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,846 since Apr 2013
Thanks: 301 given, 1,130 received
Forum Reputation: Legendary


eronyx View Post
BUT - the MAIN question here is why Try Catch not working? it just avoids it and stops the strategy, Really getting crazy here

Hi eronyx,

the error is most likely not caused due to the try statement failing here, but due to ex.InnerException or ex1.InnerException causing the error in your print statement. When you check the below code, you will find it raises a similar error message:

 
Code
once
begin
	try
  	
  	Value2 = 2 ;
  	Value3 = 1 ;
  	
  	Value1 = 1 / ( Value2 - Value3 - 1 ) ;
	
	catch (elsystem.exception ex)
		Print( "ex = " + ex.ToString() + "; ex.Message = " + ex.Message + "; InnerException = ", ex.InnerException.ToString() ) ;
	end ;
end ;
Removing ex.InnerException from the print will result in the code getting executed without the error message i.e. the DivideByZeroException getting caught and the print out to appear. The same is probably true for your code, too.
The fix for your code should be to check that the InnerException is not null before you print it. So something along the lines of
 
Code
if ex.InnerException <> null then
	Print( "ex = " + ex.ToString() + "; ex.Message = " + ex.Message + "; InnerException = " + ex.InnerException.ToString() ) 
else
	Print( "ex = " + ex.ToString() + "; ex.Message = " + ex.Message + "; InnerException = null" ) ;
should prevent the error.

Regards,

ABCTG

Reply With Quote
The following user says Thank You to ABCTG for this post:
 
  #6 (permalink)
Trading Apprentice
Moldova
 
Futures Experience: Intermediate
Platform: TradeStation
Favorite Futures: Emini ES
 
Posts: 8 since Nov 2017
Thanks: 5 given, 0 received

This is the line where it stops

file = elsystem.io.StreamWriter.Create("C:\........\Files\Final.csv");

it's like at some point it can't delete/create file again and gives this error, then works fine 3-5 days(writing this file few times per minute) then again stops here.

I am not even able to do the if (file> 1) as you suggested or something because it stops right there.



iantg View Post
Very generically I can tell you that you are hitting a null value error. So you need to check and make sure your variable / object is not null before you call it.

For example this throws an error:

double testvariable = 0;

testvariable = null;

if (testvarialbe > 1)
{
// do something
}


So you have to check if it is null first before you evaluate it.

I am not sure where you are hitting your error in your code:
"Error:elsystem.NullObjectException: Object Reference not set to an instance of an object." But whatever line is throwing this error, just check your variable to make sure it is not null and you should be fine.

Happy Coding!

Ian


Reply With Quote
 
  #7 (permalink)
Trading Apprentice
Moldova
 
Futures Experience: Intermediate
Platform: TradeStation
Favorite Futures: Emini ES
 
Posts: 8 since Nov 2017
Thanks: 5 given, 0 received

Thank You ABCTG, that indeed could be issue, is like it is not stopping at the try catch, but at that print method alone.

tricky tricky. Good catch !!!

Thanks again, I will also try placing the entire method in try catch if this does not work.


ABCTG View Post
Hi eronyx,

the error is most likely not caused due to the try statement failing here, but due to ex.InnerException or ex1.InnerException causing the error in your print statement. When you check the below code, you will find it raises a similar error message:

Regards,

ABCTG


Reply With Quote

Reply



futures io > > > > > Try/Catch Method Challenge/Mistery

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)
 

How to use the Footprint Tool to Execute Trades w/Brannigan Barrett

Elite only
 

Ask Me Anything (Brokers & Platforms) w/Ilan Levy Mayer @ Cannon Trading

Dec 13
 

Battlestations! Show us your trading desks w/GFF Brokers ($750 in Prizes)

January
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
try and catch changes strategy outcome stearno NinjaTrader Programming 6 December 29th, 2014 11:28 AM
try catch in easy language avivi TradeStation 5 October 28th, 2014 03:37 PM
Refreshed Bull May Catch its Breath Before Moving Higher Quick Summary News and Current Events 0 March 24th, 2011 11:10 PM
Ninja can't catch limit orders through TWS trigon IB Trader Workstation 18 January 13th, 2011 10:40 AM
Ball Girl makes catch David_R Jokes 5 August 5th, 2010 04:21 AM


Tags
abc, code, delete, dow, easylanguage, es, information, multicharts, neoticker, object reference, strategy, think or swim, tos, tradestation, type, variable

All times are GMT -4. The time now is 10:08 PM. (this page content is cached, log in for real-time version)

Copyright © 2018 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts
Page generated 2018-12-09 in 0.13 seconds with 15 queries on phoenix