NexusFi: Find Your Edge


Home Menu

 





Exception Handling??


Discussion in NinjaTrader

Updated
    1. trending_up 1,513 views
    2. thumb_up 2 thanks given
    3. group 2 followers
    1. forum 2 posts
    2. attach_file 0 attachments




 
Search this Thread

Exception Handling??

  #1 (permalink)
 tornadoatc 
Ft. Lauderdale Florida
 
Experience: Intermediate
Platform: Tradestation
Posts: 17 since Apr 2010
Thanks Given: 31
Thanks Received: 3

I am wondering what is the best way to throw exception in code when a variable is outside range that code is expecting.

For example:
 
Code
switch (v_LTPeriodType)	
{
		case 1 :
			Add(PeriodType.Day, v_LTPeriods) ; 
			break; 
		case 2 : 
			Add(PeriodType.Minute, v_LTPeriods) ; 
			break; 
	        default: 
			throw new System.ArgumentOutOfRangeException("v_LTPeriodType", "v_LTPeriodType is out of range"); 
}
Is this sufficient? In TS I would have used RAISERUNTIMEERROR("Error Message").

Thank You for all your assistance!

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
ZombieSqueeze
Platforms and Indicators
How to apply profiles
Traders Hideout
REcommedations for programming help
Sierra Chart
Trade idea based off three indicators.
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
35 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
19 thanks
GFIs1 1 DAX trade per day journal
16 thanks
Spoo-nalysis ES e-mini futures S&P 500
14 thanks
  #3 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


I just use
 
Code
try
{
       /// enter code here
}
catch{}

When using catch{} without arguments it should catch all types of exceptions and write them to the logs.

Reply With Quote
Thanked by:




Last Updated on April 11, 2013


© 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