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 Belfortbucks, Today, 09:29 PM
|
0 responses
6 views
0 likes
|
Last Post
by Belfortbucks
Today, 09:29 PM
|
||
Started by zstheorist, Today, 07:52 PM
|
0 responses
7 views
0 likes
|
Last Post
by zstheorist
Today, 07:52 PM
|
||
Started by pmachiraju, 11-01-2023, 04:46 AM
|
8 responses
151 views
0 likes
|
Last Post
by rehmans
Today, 06:44 PM
|
||
Started by mattbsea, Today, 05:44 PM
|
0 responses
6 views
0 likes
|
Last Post
by mattbsea
Today, 05:44 PM
|
||
Started by RideMe, 04-07-2024, 04:54 PM
|
6 responses
33 views
0 likes
|
Last Post
by RideMe
Today, 05:31 PM
|
Comment