I want to code for an indicator that shows how much time has passed since I put a trade. If 5 minutes or more have passed and the unrealized P&L is less than 5 ticks, I want an alert to be posted. The code seems to be okay but for a programming error which seems to have something to do with my use of "PositionAccount". I have checked the NT8 help guide on it and it seems I am using it correctly but for some reason I keep getting the programming error. Could you please have a look at my simple indicator which I have attached for your reference and could you enlighten me on how to use "PositionAccount" appropriately? I have tried my best with the scanty information provided in the help guide to no avail. Thanks.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Problem with PositionAccount
Collapse
X
-
Problem with PositionAccount
Hi
I want to code for an indicator that shows how much time has passed since I put a trade. If 5 minutes or more have passed and the unrealized P&L is less than 5 ticks, I want an alert to be posted. The code seems to be okay but for a programming error which seems to have something to do with my use of "PositionAccount". I have checked the NT8 help guide on it and it seems I am using it correctly but for some reason I keep getting the programming error. Could you please have a look at my simple indicator which I have attached for your reference and could you enlighten me on how to use "PositionAccount" appropriately? I have tried my best with the scanty information provided in the help guide to no avail. Thanks. -
Hello mbesha,
There is not an object in NinjaTrader called PositionAccount. Is this an object or class that you have created? Was this created in a different file? (I'm not seeing that a class or variable named PositionAccount was declared in this strategy)
Are you trying to check the position of the strategy?
if (Position.MarketPosition == MarketPosition.Long)
{
// execute code
}
Below is a link to the help guide on Position.MarketPosition.
http://ninjatrader.com/support/helpG...etposition.htm
Also, below is a link to the section of the forums for NinjaTrader 8 related items.
http://ninjatrader.com/support/forum...splay.php?f=59Chelsea B.NinjaTrader Customer Service
-
Comment
-
Hello mbesha,
I am not able to see this screenshot.
Was this attached as an attachment to your post? (and not as a picture)
Can you provide a link to the page of the help guide you are referring to?
Where you able to find the code you need from the link in the help guide that I have provided you in post #2.
Did you make sure you used a capital P on Position as shown in the help guide link I have provided you?Chelsea B.NinjaTrader Customer Service
Comment
-
Yes, I did attach it as an attachment.
Here is the link : http://ninjatrader.com/support/helpG...ionaccount.htm
I did use a capital P.
Comment
-
Hi mbesha,
Thank you for the link. (This was actually new to me)
I've made a quick test script to test using the PositionAccount object and found that this compiles without issue.
I took a second look at your strategy and found that this is not a strategy, this is an indicator.
The Position and PositionAccount are not available to indicators. This script will need to be re-created as a strategy and not as an indicator.Chelsea B.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
576 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
334 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 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
553 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
551 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment