Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MarketPosition

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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.

    #2
    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

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by LawrenHom, Today, 10:45 PM
    0 responses
    4 views
    0 likes
    Last Post LawrenHom  
    Started by love2code2trade, Yesterday, 01:45 PM
    4 responses
    28 views
    0 likes
    Last Post love2code2trade  
    Started by funk10101, Today, 09:43 PM
    0 responses
    7 views
    0 likes
    Last Post funk10101  
    Started by pkefal, 04-11-2024, 07:39 AM
    11 responses
    37 views
    0 likes
    Last Post jeronymite  
    Started by bill2023, Yesterday, 08:51 AM
    8 responses
    44 views
    0 likes
    Last Post bill2023  
    Working...
    X