NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > Application Technical Support > Automated Trading

Automated Trading Support for automated trading systems using NinjaScript. Support for our ATI (Automated Trading Interface) used to link an external application such as TradeStation and eSignal to NinjaTrader.

Reply
 
Thread Tools Display Modes
Old 09-20-2011, 10:27 AM   #1
jesshon
Junior Member
 
Join Date: Jun 2009
Posts: 21
Thanks: 3
Thanked 0 times in 0 posts
Default Round up or down

Hi,

Please help. I would like to check what is the function to perform the round up or down for a double value. Below is the formula I use. I want to submit the MidValue as a market order, which need to be a integer.

private
double MidValue = 0;
MidValue = (High[
1]+Low[1])/2;

Thanks,
Jess
jesshon is offline  
Reply With Quote
Old 09-20-2011, 10:30 AM   #2
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

Hi Jess,

You can cast a value as integer by putting (int) before the value. You may also get use of Math.Round() or Round2TickSize().

I did not follow your request though, as market orders do not allow for specifying a price. Can you please clarify?
Last edited by NinjaTrader_RyanM; 09-20-2011 at 10:33 AM.
NinjaTrader_RyanM is offline  
Reply With Quote
The following user says thank you to NinjaTrader_RyanM for this post:
Old 09-20-2011, 10:45 AM   #3
jesshon
Junior Member
 
Join Date: Jun 2009
Posts: 21
Thanks: 3
Thanked 0 times in 0 posts
Thumbs up

Hi Ryan,

Yes, you're right. That should be a stop order.

Thanks,
Jess
jesshon is offline  
Reply With Quote
Old 09-20-2011, 10:57 AM   #4
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

OK, I would not think that integer is used for the price, as these should always be doubles. You can use Round2TickSize like in example below:

Code:
double myStopPrice = Instrument.MasterInstrument.Round2TickSize(MidValue);
Last edited by NinjaTrader_RyanM; 09-23-2011 at 08:02 AM.
NinjaTrader_RyanM is offline  
Reply With Quote
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
Round-the-clock-logic ? Harry Version 7 Beta General Questions & Bug Reports 2 07-28-2010 07:47 AM
Is there a function that calculates round numers? "CJS" Strategy Development 3 07-08-2010 09:34 AM
Strategy wizard, and round number. johnlucas Strategy Development 1 10-13-2009 03:32 AM
Round an integer to nearest 10 kcsystemtrader General Programming 8 03-22-2009 11:59 AM
Round to Nearest Tick tquinn General Programming 2 01-30-2007 07:20 AM


All times are GMT -6. The time now is 11:31 PM.