Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Position.MarketPosition from an indicator -> doesn't work

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

    Position.MarketPosition from an indicator -> doesn't work

    Hi,

    I'm trying to obtain information about a running strategy and the account.
    I have a strategy running, and in paralell I put an indicator sending messages to me when a new order is sent.
    I do get the information from the strategy (direction, volume and position of the strategy), but when I try to get the information from the account it doesn't work to me.

    Is because I'm doing it from an indicator?, should I do it from a strategy?

    I'm running the strategy on the main instrument (YM) in SIM, and sending the real orders to MYM..., because of that I have to check both the strategy and the real account.

    Thanks!

    #2
    Hello artson,

    Thank you for your note.

    Position.MarketPosition would only work within a Strategy as it specifically is referencing the strategy position. From within an indicator to get the account position you'd need to look through the collection of accounts and positions using Add-on code:

    private Account myAccount;

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    // Find our Sim101 account
    lock (Account.All)
    myAccount = Account.All.FirstOrDefault(a => a.Name == "Sim101");
    }

    if (State == State.DataLoaded)
    {
    lock (myAccount.Positions)
    {
    Print("Positions in State.DataLoaded:");

    foreach (Position position in myAccount.Positions)
    {
    Print(String.Format("Position: {0} at {1}", position.MarketPosition, position.AveragePrice));
    }
    }
    }
    }





    Please let us know if we may be of further assistance to you.

    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 Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    332 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    553 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    551 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X