Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
MarketPosition
Collapse
X
-
MarketPosition
Does MarketPosition indicate the strategy's current position or the account's current position? Reason being is I'm trying to setup multiple diversified strategies trading the same instrument and want to create a script to check if I'm already long/short in the instrument with another strategy. And if so the strategy wanting an opposing trade would not take the entry. Thanks.Tags: None
-
Hello dirkdiggler,
The MarketPosition will only be the position of the strategy and will not be the account position.
To find the account position or orders this would need undocumented / unsupported code:
Code:foreach (Account acct in Cbi.Globals.Accounts) { if (acct.Positions != null) { // print information about each position PositionCollection positions = acct.Positions; foreach (Position pos in positions) { Print(pos.Account.Name + " " + pos.Instrument + " " + pos.MarketPosition + " " + pos.Quantity + " " + pos.AvgPrice); } // print information about each order OrderCollection orders = acct.Orders; foreach (Order ord in orders) { Print(ord.ToString()); } }
Chelsea B.NinjaTrader Customer Service
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by LawrenHom, Today, 10:45 PM
|
0 responses
4 views
0 likes
|
Last Post
by LawrenHom
Today, 10:45 PM
|
||
Started by love2code2trade, Yesterday, 01:45 PM
|
4 responses
28 views
0 likes
|
Last Post Today, 10:31 PM | ||
Started by funk10101, Today, 09:43 PM
|
0 responses
7 views
0 likes
|
Last Post
by funk10101
Today, 09:43 PM
|
||
Started by pkefal, 04-11-2024, 07:39 AM
|
11 responses
37 views
0 likes
|
Last Post
by jeronymite
Today, 09:37 PM
|
||
Started by bill2023, Yesterday, 08:51 AM
|
8 responses
44 views
0 likes
|
Last Post
by bill2023
Today, 09:27 PM
|
Comment