![]() |
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
|
|||||||
| 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 |
|
Member
Join Date: Oct 2011
Posts: 70
Thanks: 2
Thanked 1 time in 1 post
|
Hello,
I am wondering if there is a way to change the number of contracts traded by a strategy in an automated way. Eg. I'd like my strategy to buy one contract for every $10000 of balance that I have in my account. So, if the balance goes up to $20000, it will place trade for 2 contracts for $30000 it will place 3 contracts. But if the balance comes down to $20000 for some reason, it will automatically place trade for only 2 contracts. Is there a way to accomplish this in NT? Thanks. |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
Hi pandyav,
Yes, this is possible. You can have a variable for order quantity that is calculated any way you like. If you wanted access to the real time account values, there is method GetAccountValue() http://www.ninjatrader.com/support/h...countvalue.htm Code:
double orderQuantity = GetAccountValue(AccountItem.CashValue) / 10000; EnterLong(Math.Min((int)orderQuantity, 1)); //Math.Min used in case you get below 10000.
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Oct 2012
Posts: 24
Thanks: 0
Thanked 1 time in 1 post
|
Hi,
I am new to NinjaTrader, and am just starting to evaluate the software and trying to set up some of my strategies to trade automatically. I am having a similar problem to pandyav, but when I inserted the lines of code into my program, it still only trades one contract, while back testing; regardless of what I set the starting account value at. Any help on this matter would be appreciated. Thank You |
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
|
Welcome to our forums - the GetAccountValue call would only work in real-time simulated / live trading, it would not work on historical data.
http://www.ninjatrader.com/support/h...countvalue.htm For backtesting, to use the entered AccountSize parameter please ensure your order qty for the strategy is driven ByAccount - http://www.ninjatrader.com/support/h...a_strategy.htm
Bertrand
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Number of contracts with ATM | ssg10 | Strategy Development | 1 | 06-17-2009 05:58 AM |
| Number of lots traded in a session | John833 | Strategy Development | 2 | 01-09-2009 05:49 AM |
| Total Number of Contracts Trades | pivot44 | Miscellaneous Support | 4 | 05-23-2007 03:53 PM |
| Number of contracts is bumped up | deanldavis475 | SuperDOM and other Order Entry Windows | 2 | 05-14-2007 09:17 PM |
| Total Contracts Traded | pivot44 | Miscellaneous Support | 1 | 03-26-2006 05:40 AM |