NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 03-14-2012, 08:22 AM   #1
cfree5119
Senior Member
 
Join Date: Dec 2011
Posts: 121
Thanks: 23
Thanked 0 times in 0 posts
Default If else statement

Instead of using a variable to set the value to x if a certain condition is met, can you put in say the number 1? I can't seem to get it to work for my statement. See the following code. Thank you.

Code:
			oneUnit 			= 	if(Math.Floor(((AccountRiskPercent/100) * currentAccountSize)/Close[0]) < 1)
									1
									else Math.Floor(((AccountRiskPercent/100) * currentAccountSize)/Close[0]);
cfree5119 is offline  
Reply With Quote
Old 03-14-2012, 08:33 AM   #2
NinjaTrader_Joydeep
NinjaTrader Customer Service
 
NinjaTrader_Joydeep's Avatar
 
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
Default

Hello cfree5119,
Thanks for writing in and I am happy to assist you.

To do a quick if check please use the following code

Code:
oneUnit   =  Math.Floor(((AccountRiskPercent/100) * currentAccountSize)/Close[0]) < 1 ? 1.0 : Math.Floor(((AccountRiskPercent/100) * currentAccountSize)/Close[0]);
http://msdn.microsoft.com/en-us/library/ty67wk28.aspx

Please let me know if I can assist you any further.
Last edited by NinjaTrader_Joydeep; 03-14-2012 at 08:35 AM.
NinjaTrader_Joydeep is offline  
Reply With Quote
The following user says thank you to NinjaTrader_Joydeep for this post:
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
multiple if statement ionaz General Programming 1 11-27-2011 11:50 PM
Basic Or Statement? dirygoatee Strategy Development 1 11-10-2011 02:51 AM
Help with IF Statement Taddypole Indicator Development 2 04-25-2010 07:54 AM
if statement velocity General Programming 3 02-20-2009 08:12 AM
Goto statement? Burga1 General Programming 3 12-28-2007 09:37 AM


All times are GMT -6. The time now is 09:19 PM.