Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Subscribing to account events erroring out

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

    Subscribing to account events erroring out

    I am having an issue subscribing to the events of an account. I have tried to follow the documentation, however it doesn't seem to work for me.



    These are the parts that I am having trouble with:

    Code:
    // Subscribe to static events. Remember to unsubscribe with -= when you are done
    Account.AccountStatusUpdate += OnAccountStatusUpdate;​
    
    // Subscribe to events. Remember to unsubscribe with -= when you are done
    myAccount.AccountItemUpdate += OnAccountItemUpdate;
    myAccount.ExecutionUpdate += OnExecutionUpdate;​
    The handlers that I am trying to subscribe too (OnAccountStatusUpdate, OnAccountItemUpdate, OnExecutionUpdate) don't seem to exist. I just get this error here:

    The name 'OnAccountStatusUpdate' does not exist in the current context
    Am I missing some sort of import maybe? I'm just not sure.


    For Context: I am trying to write an indicator that will record any trades made whilst the indicator is in use and print them into a CSV file for ease of tracking them.

    #2
    Hello greyhour,

    To use the code you linked to you would have to have your code be exactly the same as that sample.

    The error you are seeing is because you did not copy or have renamed the event methods shown in that sample, you need to also copy those event methods which the subscriptions are using for the event subscription.


    Code:
    protected override void OnStateChange()
    {
    ......​
    }
    
    private void OnAccountStatusUpdate(object sender, AccountStatusEventArgs e)
    {
    // Do something with the account status update
    }
    
    private void OnAccountItemUpdate(object sender, AccountItemEventArgs e)
    {
    // Do something with the account item update
    }
    
    private void OnExecutionUpdate(object sender, ExecutionEventArgs e)
    {
    // Do something with the execution update
    }​

    Comment


      #3
      Oh of course, I am telling it what methods to subscribe to but don't have them implemented yet.. Thanks heaps!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      576 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      334 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