Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Get P/L for the day in ninjascript
Collapse
X
-
Bertrand,
Please forgive my ignorance, and I have not programmed a strategy before. I have CalculateOnClose set to false, and my OnBarUpdate() is a single line:
I have the strategy loaded, connection is established, market is ticking. Yet, I see no output in the output window. What am I missing?Code:protected override void OnBarUpdate() { Print("account value is: " + GetAccountValue(AccountItem.CashValue)); }
Comment
-
I am running this off my IQFeed connection, simulation account for testing. Regardless of what's in the account tab, I should see something print, and it's not printing anything. But yes, it's showing the expected value.Originally posted by NinjaTrader_Bertrand View PostWhat connection / account are you running the strategy off? Does the CashValue show as expected in your Accounts tab in the Control Center?
Thanks,
By the way, my broker uses TT -- this feed does not allow me to see cash value, etc., so does that mean that even if I get this working that it will not be usable with TT?
Comment
-
Correct for TT, you can only access value offered through the connected API with this method. Your strategy though could keep track itself of per session PnL then, but this would only reflect PnL for this very strategy instance :
For your print - are you sure the strategy is enabled? So showing 'green' in your Strategies tab in the Control Center?
Comment
-
Ok Bertrand, I will give this a look. And it was not enabled in the Strategies tab. I did not know there was a strategies tab, sorry.. as I said, I have never used a strategy before and didn't know they had to be "turned on"Originally posted by NinjaTrader_Bertrand View PostCorrect for TT, you can only access value offered through the connected API with this method. Your strategy though could keep track itself of per session PnL then, but this would only reflect PnL for this very strategy instance :
For your print - are you sure the strategy is enabled? So showing 'green' in your Strategies tab in the Control Center?
Comment
-
So, just to be clear, I don't have a programmatic trading strategy. I only want, in some way, to be able to determine my day's P/L. I am going to be placing orders through ATM strategies on the DOM, or perhaps no ATMs at all. I want to check my daily P/L, and ensure that it does not fall below some threshold. It seems that the Performance.AllTrades, etc., only applies for the strategy that is code is running from--is that correct? In my case, this will not work, as I may not even be running a strategy. I just want to find out my daily P/L. Is this possible?Originally posted by NinjaTrader_Bertrand View PostYour strategy though could keep track itself of per session PnL then, but this would only reflect PnL for this very strategy instance :
Comment
-
So, knowing everything you know about the NT code, can you help me find a way to do what I'm looking to do? I don't mind even manually entering an account balance into an indicator every day if it can't be retrieved programatically. How about reading the log file? Anything to get this working... there's always a way, and this seems not too far out of the box.
Comment
-
Ok, this is probably the value I was looking for. Now, when I place a trade and close it, my strategy disables itself. Is this some setting I need to be overriding?Originally posted by NinjaTrader_Bertrand View PostJoshDance, an untested approach would be - enter start account balance as input to calculate with and add your RealizedPnl that NT would calculate for a TT based account, this would be 'gettable' as well via GetAccountValue.
Comment
-
lol, let me get this right -- the "Close" button disables all running strategies? And there is not an option to change this behavior?Originally posted by NinjaTrader_Bertrand View PostDon't close the trade with the 'Close' button on ChartTrader or DOM. This would cancel working orders and close the position and running strategies on that instrument / account.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
574 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
332 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