Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Trade existance
Collapse
X
-
Hello FCatan,
Thanks for your post.
While this is unsupported code you could accomplish your goal with modifying this code snippet:
Code:foreach (Account acct in Cbi.Globals.Accounts) { if (acct.Positions != null) { PositionCollection positions = acct.Positions; foreach (Position pos in positions) { Print(pos.Account.Name + " " + pos.Instrument + " " + pos.MarketPosition + " " + pos.Quantity + " " + pos.AvgPrice); } } }
-
Originally posted by FCatan View PostHi, I have an indicator that collects volume data, but I only want to collect this data when in a trade. Is there a way to detect the existence of a trade from within an indicator? thanksCode:if (Position.MarketPosition != MarketPosition.Flat) { //you are in a trade. Do as thou wilt. }
Comment
-
My mistake. You said Indicator. You were talking about being in a position, so my brain pooped and assumed that you were in Strategy land. Indicators cannot natively determine if you are in a position, so the point is moot.Originally posted by FCatan View PostThank you Koganam, but when I run this code I get this message:
An object reference is required for the non-static field, method, or property 'NinjaTrader.Cbi.Position.MarketPosition.get'
One can certainly create code so that a specific Strategy works in tandem with a specific Indicator to pass along that information, but that is a rather limiting option..
There are other deeper approaches to allow an indicator to read a Strategy position. Indeed the code from, NinjaTrader_Paul, in this thread, suitably filtered, could probably get that information.
There is also an indicator, shared in the Forum, that can read Strategy positions, by querying the Strategy event handlers. You may care to search for it.
Addendum: This is the indicator of which I spoke. Whereas it was designed to email executions in an account, It does show you how to access Strategy information from an indicator. http://www.ninjatrader.com/support/f...catid=6&id=533Last edited by koganam; 09-14-2015, 05:21 PM.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
672 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
379 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
111 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
577 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
582 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment