• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Subscribing to Strategy Order/Execution updates by delegate

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

    Subscribing to Strategy Order/Execution updates by delegate

    The account class lets us subscribe to OnOrderUpdate and OnExecutionUpdate etc via an event delegate

    e.g. https://ninjatrader.com/support/help...rderupdate.htm

    Code:
    account.OrderUpdate += OnOrderUpdate;
    Is it possible to do the same for a Strategy?


    #2
    Hello kevinenergy,

    When working with a strategy you would have the override methods instead of event handlers that can be used within the strategies code. You would need to utilize the Account class if you wanted to subscribe to the events of the account directly. The platform and its internal logic would filter relevant internal events related to that script and then would supply that information to your script by calling its overrides. because this is an override method and not an event, an outside script would be unable to subscribe to the strategies events specifically.

    https://ninjatrader.com/support/help...=OnOrderUpdate

    Please let me know if I may be of additional assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hey Jesse, thanks for the response.

      The problem I've got, is that if I subscribe to the OnOrderUpdate or OnExecutionUpdate events via the Account class, the events don't get fired during the Strategy's historical data processing. This means that my unmanaged order handling is totally broken and my strategy starts in a very corrupted state.

      The events do fire during realtime processing though. Possibly a bug?

      Not an ideal situation because I spent a lot of time writing an unmanaged order handling system, I would ideally like to share this between multiple strategies by instantiating the unmanaged order handler in the strategy and subscribing to the events it needs. But the way things are presently it looks I need to duplicate all of the order handler code between every strategy that uses it.

      Comment


        #4
        Hello kevinenergy,

        This is not a bug this is how the account class should work. In this case, you are mixing two separate concepts of the Addon account methods which interface directly with the account and the virtual strategy methods which do not directly interface with the account.

        In general, the addon account methods are only intended for complex tools that are not specifically strategies, for example, if you wanted to make your own DOM tool for manual trading that applies some extra logic. Strategies are intended to work as a virtual entity which is loosely associated with the account in a virtualized way. Strategies are also intended to isolate performance away from the overall account and give the ability to backtest in the analyzer. The Addon account methods would not be for these virtualized uses.

        The short solution here is to avoid using a strategy if you want to use the account class for order handling. In that situation, you could use the account class to both observe and submit orders to avoid the virtualization problem. If you want to use specifically a strategy, I would suggest avoiding using the account class as you will run into roadblocks like this where the concepts do not match together in a way that would work correctly.

        The historical trades a strategy produces are virtual and not being sent to the Account as live trades, you will see that the control center does not display these historical trades. The Account class would really only be useful for real-time trading or actual events that are sent to the selected account such as a manual trade. If you are trying to use the historical backtest information from the strategy that logic would generally need to go inside of the strategy where the virtual properties apply. You may be able to use the strategies trade collections but in general, I wouldn't suggest trying to mix the virtual and real information and instead use one or the other.

        Please let me know if I may be of additional assistance.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by xsgex, Yesterday, 09:46 PM
        0 responses
        2 views
        0 likes
        Last Post xsgex
        by xsgex
         
        Started by Steve L, Yesterday, 09:36 PM
        0 responses
        1 view
        0 likes
        Last Post Steve L
        by Steve L
         
        Started by krugman25, Yesterday, 09:34 PM
        0 responses
        4 views
        0 likes
        Last Post krugman25  
        Started by indy73, Yesterday, 04:42 PM
        0 responses
        15 views
        0 likes
        Last Post indy73
        by indy73
         
        Started by Italianforex, Yesterday, 06:20 AM
        2 responses
        13 views
        0 likes
        Last Post gplatis
        by gplatis
         
        Working...
        X