![]() |
|
|||||||
| 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. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Jun 2009
Posts: 21
Thanks: 3
Thanked 0 times in 0 posts
|
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. privatedouble MidValue = 0; MidValue = (High[1]+Low[1])/2; Thanks, Jess |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
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?
Ryan M
NinjaTrader Customer Service
Last edited by NinjaTrader_RyanM; 09-20-2011 at 10:33 AM.
|
|
|
|
|
The following user says thank you to NinjaTrader_RyanM for this post: |
|
|
|
#3 |
|
Junior Member
Join Date: Jun 2009
Posts: 21
Thanks: 3
Thanked 0 times in 0 posts
|
Hi Ryan,
Yes, you're right. That should be a stop order. ![]() Thanks, Jess |
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
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);
Ryan M
NinjaTrader Customer Service
Last edited by NinjaTrader_RyanM; 09-23-2011 at 08:02 AM.
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |