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
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); } } }
Paul H.NinjaTrader Customer Service
-
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
-
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 andrewtrades, Today, 04:57 PM
|
1 response
5 views
0 likes
|
Last Post Today, 05:02 PM | ||
Started by chbruno, Today, 04:10 PM
|
0 responses
3 views
0 likes
|
Last Post
by chbruno
Today, 04:10 PM
|
||
Started by josh18955, 03-25-2023, 11:16 AM
|
6 responses
436 views
0 likes
|
Last Post
by Delerium
Today, 03:42 PM
|
||
Started by FAQtrader, Today, 03:35 PM
|
0 responses
7 views
0 likes
|
Last Post
by FAQtrader
Today, 03:35 PM
|
||
Started by rocketman7, Today, 09:41 AM
|
5 responses
19 views
0 likes
|
Last Post Today, 03:33 PM |
Comment