Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Limit strategy to a % of an account
Collapse
X
-
Hello stevenev,
You would need to calculate this number either in your strategy code or manually before placing the quantity.
You can check the account balance of a strategy in real time with:
GetAccountValue(AccountItem.CashValue)
http://ninjatrader.com/support/helpG...countvalue.htm
You would then multiply this by a percentage value, convert to an int, then use this for the quantity when placing an order.Chelsea B.NinjaTrader Customer Service
-
On 2nd thought, would this work? If the strategy is running against multiple symbols, then it could trigger multiple orders each as large as the % specified.
I am thinking another way is to have a static (persistent) variable keeping track of what is being bought/sold per strategy. This would work if ninjascript could get hold of order status, i.e. bought or sold.
Comment
-
I see a reference to "Strategy Position" https://ninjatrader.com/support/help..._account_p.htm
That would solve my problem if that could be used in ninjascript.
Comment
-
Hello stevenev,
It would be possible to use a static variable but this would not be something I could assist with.
You could write the value to a file and then read the value from other scripts.
StreamWriter - http://www.ninjatrader.com/support/f...ead.php?t=3475
StreamReader - http://www.ninjatrader.com/support/f...ead.php?t=3476
Regarding the strategies position which is separate from the account position, this can be checked with the Position object. (The Position object refers to the strategy position and not the account position)
Below is a link to the help guide on Position.
http://ninjatrader.com/support/helpG...7/position.htm
For example:
if (Position.MarketPosition == MarketPosition.Long)
{
Print(Position.Quantity);
}Chelsea B.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by cmtjoancolmenero, Yesterday, 03:58 PM
|
11 responses
39 views
0 likes
|
Last Post Today, 11:40 AM | ||
Started by FrazMann, Today, 11:21 AM
|
0 responses
5 views
0 likes
|
Last Post
by FrazMann
Today, 11:21 AM
|
||
Started by geddyisodin, Yesterday, 05:20 AM
|
8 responses
52 views
0 likes
|
Last Post Today, 10:45 AM | ||
Started by DayTradingDEMON, Today, 09:28 AM
|
4 responses
26 views
0 likes
|
Last Post Today, 10:47 AM | ||
Started by George21, Today, 10:07 AM
|
1 response
22 views
0 likes
|
Last Post Today, 10:43 AM |
Comment