I am testing the function GetProfitLoss. The number reported makes sense to me for 1 contract. But if I add another contract, the number doesn't make sense. How do I get the function to work with position sizing?
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
GetProfitLoss
Collapse
X
-
GetProfitLoss
I am using the example found at:
I am testing the function GetProfitLoss. The number reported makes sense to me for 1 contract. But if I add another contract, the number doesn't make sense. How do I get the function to work with position sizing?Tags: None
-
I am entering at 2 different prices for a total of 2 contracts. This seems to work for the first contract but after the second contract is entered, the unrealized doesn't makes sense:
Code:DrawTextFixed("UnPNL", string.Format("Unrealized: {0}", Math.Round(Position.GetProfitLoss(Close[0], PerformanceUnit.Points), 2)), TextPosition.TopRight, Color.Green, new Font("Arial",16), Color.Blue, Color.DarkGray, 10);
Comment
-
Hello,
Thank you for the question.
There is not a supported way to access specifically that field in the control center.
I can provide a forum post with a script example on how to calculate the Unrealized PnL for an order. http://ninjatrader.com/support/forum...1&postcount=19
In this example, in the OnBarUpdate there are a few Prints that show how to calculate the Unrealized PnL for given orders.
I look forward to being of further assistance.JesseNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Rapine Heihei, Today, 08:19 PM
|
1 response
6 views
0 likes
|
Last Post Today, 08:30 PM | ||
Started by Rapine Heihei, Today, 08:25 PM
|
0 responses
5 views
0 likes
|
Last Post Today, 08:25 PM | ||
Started by f.saeidi, Today, 08:01 PM
|
1 response
4 views
0 likes
|
Last Post Today, 08:17 PM | ||
Change colour of Stop market and limit orders to red and green via indicator script
by Rapine Heihei
Started by Rapine Heihei, Today, 07:51 PM
|
0 responses
6 views
0 likes
|
Last Post Today, 07:51 PM | ||
Started by frslvr, 04-11-2024, 07:26 AM
|
5 responses
97 views
1 like
|
Last Post
by caryc123
Today, 07:47 PM
|
Comment