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
Account PnL
Collapse
X
-
Account PnL
Good afternoon, I have several strategies running at the same time, I would like to get the PnL value of the whole account. I tried using Position Account.Get Unrealized Profit Loss(Performance Unit.Point, Close[0] ), but it returns the PnL value of the strategy. How can I get the PnL value of an entire account? ThanksTags: None
-
Hello Bogdan097,
PositionAccount would be how to do that from a strategy. Are you certain that both strategies placed realtime positions? The account values are only for realtime positions so if one strategy had entered historically and the other in realtime that would be a situation where you would only see the pnl for one strategy.JesseNinjaTrader Customer Service
-
Yes, the two strategies work in real time since I disabled the history in the code. I make a conclusion and get the PnL of each strategy.
double totalUnrealizedProfit = PositionAccount.GetUnrealizedProfitLoss(Performanc eUnit.Points, Close[0]);
Print(totalUnrealizedProfit);
Comment
-
Hello Bogdan097,
Did the two strategies enter at about the same price point? The account positions average price is used to calculate the unrealized, if both strategies entered near the same price then the unrealized may match one of the strategies directly.
You should see that the value you get back is the same value as the control center positions tab unrealized pnl for the position on the instrument. Are you seeing that match?
JesseNinjaTrader Customer Service
Comment
-
Hello Bogdan097,
If you are buying and selling on the same account and instrument that would make the account flat but each strategy would think it was in a position. Two strategies cannot trade opposite from each other on the same account. Are you trying to get PnL from multiple accounts?
JesseNinjaTrader Customer Service
Comment
-
Hello Bogdan097,
A position is your current buy or sell into a single market, if you are using multiple currencies you have multiple positions. Each strategy would have a unique position that is not shared with the other strategy because it is running on a different instrument. If you want the overall accounts unrealized PnL that you see in the account tab you need to use the addon framework to find an account and then use the Account.Get method.
JesseNinjaTrader Customer Service
Comment
-
Hello Bogdan097,
I would suggest to have the strategies close their own positions using exit orders so the strategies individualized performance can collect the exit and maintain the strategies logic. Closing positions from outside the strategies using the addon approach will prevent them from knowing that happened and could allow them to still exit the non existing positions.
JesseNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by poplagelu, Today, 05:00 AM
|
0 responses
0 views
0 likes
|
Last Post
by poplagelu
Today, 05:00 AM
|
||
Started by fx.practic, 10-15-2013, 12:53 AM
|
5 responses
5,406 views
0 likes
|
Last Post
by Bidder
Today, 12:22 AM
|
||
Started by Shai Samuel, 07-02-2022, 02:46 PM
|
4 responses
98 views
0 likes
|
Last Post
by Bidder
Today, 12:11 AM
|
||
Started by DJ888, Yesterday, 10:57 PM
|
0 responses
8 views
0 likes
|
Last Post
by DJ888
Yesterday, 10:57 PM
|
||
Started by MacDad, 02-25-2024, 11:48 PM
|
7 responses
160 views
0 likes
|
Last Post Yesterday, 10:23 PM |
Comment