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 Mindset, 04-21-2026, 06:46 AM
      0 responses
      44 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      56 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      35 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      95 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      57 views
      0 likes
      Last Post PaulMohn  
      Working...
      X