I am trying to access all the open positions on my simulator account but unable to get the correct count. I need to get 4 but my script output shows only 3. Attaching screenshots and my script
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Unable to get all the positions in NinjaTrader Script
Collapse
X
-
Unable to get all the positions in NinjaTrader Script
Hello,
I am trying to access all the open positions on my simulator account but unable to get the correct count. I need to get 4 but my script output shows only 3. Attaching screenshots and my script
Tags: None
-
Hello, thanks for writing in. The PositionAccount object will return the total account position quantity:
If it is still returning an incorrect value try resetting the Sim101 account:
Go to the Accounts tab on the Control Center>Right click the Sim101 account>Edit Account>Click Reset. This will set the Sim101 back to "Factory settings".
- Likes 1
-
You may be confused.
I don't think '3 L' or '4 L' mean 3 or 4 total positions.
It means you are 'Long 3 contracts' and 'Long 4 contracts'.
Saying '3 L' is just a shorthand way to state a position.
A 'position' mainly consists of two things, a direction (Long/Short)
and a quantity, and are managed uniquely per instrument and
per account.
If there is no position in a specific instrument for a specific
account, that condition is called Flat, and obviously quantity
is zero when the position is Flat.
Each running strategy knows about it's own position, but no
others -- so the 'strategy position' is unique to each strategy.
Your overall account position takes into consideration everything
happening in your account.
If Strat A is '3 L' in ES and Strat B is '4 L' in ES -- then your
account position at your broker is actually '7 L' in ES.
Your account position is cumulative -- there is only ever one
'account position' per instrument per account.
As soon as Strat A exits its '3 L' position, your overall account
position is adjusted to '4 L', which now happens to exactly match
the Strat B position, which is exactly what you should expect.
(Why? Because Strat A exits its '3 L' position by selling 3
contracts, right? Well, that 'sell' order affects the account
position, so if it was '7 L' before the 'sell 3' order, then after
the 'sell 3' is filled, the account position is '4 L'. See that?)
But suddenly,
if Strat A goes 'short 3 contracts' (aka, '3 S') while Strat B is
still '4 L' your account position becomes '1 L' -- because the
broker sees the request to sell 3 contracts from Strat A and
reduces the '4 L' account position to '1 L' -- because it sold 3
contracts.
It can become wildly confusing when running multiple strategies
on the same account on the same instrument -- that's why it's
highly discouraged.
Make sense?
- Likes 1
Comment
-
The corollary to this is that Account.Positions.Count usually flucuates
between 0 and 1.
Why?
Because most people, even if they trade multiple instruments, only
ever take positions (aka, enter a trade) on 1 instrument at time.
Thus '4 L' does not mean 4 positions, it means 1 position and the
position direction is 'Long' and the position quantity is '4'.
Btw, it is the same nomenclature across all of trading.
In stocks, '1000 L' means you're Long 1000 shares -- obviously,
the instrument you're long in is critical to know.
That's why I said a 'position' always has these 4 things,
Direction
Quantity
Instrument
Account
and is managed uniquely on a per instrument per account basis.
- Likes 1
Comment
-
Thanks David for the insights and education.
NinjaTrader_ChrisL - Your post helped me fix the exact issue I was facing.
Appreciate the quick support !!!
Comment
-
NinjaTrader_ChrisL - Hi Chris, I noticed that the PositionAccount does not work in Backtest mode but works in the live or simulation account in real time. Is there anyway to overcome this as it prevents me from backtesting my strategy..
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
627 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
359 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
105 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
562 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
568 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment