Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Issue Overriding OnConnectionStatusUpdate in AddOnBase Class

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

    Issue Overriding OnConnectionStatusUpdate in AddOnBase Class

    Hello NinjaTrader Support,

    I am currently developing an add-on for NinjaTrader and have encountered an issue with extending functionality related to connection status updates. I am using NinjaTrader 8 and my class is derived from NinjaTrader.NinjaScript.AddOnBase. Here is the class definition:
    Code:
    public class MyClass : NinjaTrader.NinjaScript.AddOnBase {
        protected override void OnConnectionStatusUpdate(ConnectionStatusEventArgs connectionStatusUpdate) { // Intended implementation }
    }
    When I try to override the OnConnectionStatusUpdate method to handle connection status changes, I receive the following compiler error:

    CS0115 'MyClass.OnConnectionStatusUpdate(ConnectionStatus EventArgs)': no suitable method found to override

    This suggests that the OnConnectionStatusUpdate method is not available for overriding in the AddOnBase class. My goal is to efficiently manage connection status changes to subscribe and unsubscribe from order updates dynamically within my add-on.​

    Questions:
    1. Is it possible to override the OnConnectionStatusUpdate method in a class derived from AddOnBase? If not, what would be the recommended approach to handle connection status changes within an add-on?
    2. If overriding this method is not feasible within AddOnBase, could I potentially implement this functionality by creating an indicator or another support class specifically for handling these events? How would I integrate such a class with my add-on to manage connection-related actions?

    It’s imperative for the functionality of my add-on to react to connection status updates, so any guidance on how to achieve this within the NinjaTrader framework would be greatly appreciated.

    Thank you for your assistance.

    Best regards,
    ​ Aviram Y.

    #2
    Update:
    I've tried using an indicator, it doesn't work since it needs to be attached to a chart.

    I would still like to know if there's a way to implement the above but:

    For anyone interested, I've found a workaround by subscribing to all trading related buttons, creating a reference class to hold accounts that already have some handler attached to them like OnOrderUpdate or anything else you desire in a dictionary containing the account as key and bool as value, then every PreviewMouseDown/PreviewKeyDown invocation i get the account to be manipulated via code and check if a handler has already been attached using the reference class..


    Comment


      #3
      Hello Aviram Y,

      Addons do not have any of the overriding methods that you find in indicators or strategies, you would need to work directly with the account in an addon. You can see an example of finding an account and subscribing to its events here:




      JesseNinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by SaltyCoffee, Today, 01:13 AM
      0 responses
      5 views
      0 likes
      Last Post SaltyCoffee  
      Started by FishTrade, 05-13-2024, 11:11 PM
      3 responses
      13 views
      0 likes
      Last Post FishTrade  
      Started by Graci117, Yesterday, 09:02 PM
      1 response
      13 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by ETFVoyageur, Yesterday, 07:55 PM
      0 responses
      9 views
      0 likes
      Last Post ETFVoyageur  
      Started by janio973, Yesterday, 07:24 PM
      1 response
      8 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Working...
      X