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
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
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 SnailHorn, Today, 10:49 PM
|
0 responses
7 views
0 likes
|
Last Post
by SnailHorn
Today, 10:49 PM
|
||
Started by naanku, Today, 07:25 PM
|
0 responses
8 views
0 likes
|
Last Post
by naanku
Today, 07:25 PM
|
||
Started by milfocs, Today, 07:23 PM
|
0 responses
6 views
0 likes
|
Last Post
by milfocs
Today, 07:23 PM
|
||
Started by PaulMohn, Today, 06:59 PM
|
0 responses
8 views
0 likes
|
Last Post
by PaulMohn
Today, 06:59 PM
|
||
Started by bortz, 11-06-2023, 08:04 AM
|
48 responses
1,756 views
0 likes
|
Last Post
by carnitron
Today, 06:57 PM
|
Comment