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

Unmanaged Strategy selecting active trading account

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

    Unmanaged Strategy selecting active trading account

    So I've found and traversed the NinjaTrader.Cbi.Account.All collection.
    So I'll put those in a listbox.

    When I want to make an account the Active one for Live order entry
    or, I guess "real time" order entry; how do I programmatically set that account
    object to be the active one?

    [edit] Guessing, do I assign the field OrderEntryStrategy.account to be
    one of the account objects ? Is that how it is done?

    THANKS
    Last edited by Hyper; 09-11-2020, 01:13 PM. Reason: guessing an answer

    #2
    Hello Hyper,

    From a unmanaged strategy the only account which could be used to submit strategy based orders would be the one you select when you apply it.

    The Accounts collection you are working with would be part of the addon framework which is separate from strategies, that would be used with the Submit method from the account object. That should not be combined with a Strategy, if you are making some kind of GUI or using the account directly that should go in an indicator.

    You can find examples of using an account to submit orders in the help guide addon section and the addon framework sample basic:
    https://ninjatrader.com/support/help...ount_class.htm
    https://ninjatrader.com/support/help...t_overview.htm

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      OK, I am aware that significant logic can be placed in the Indicator framework; but I just gotta say
      that is extremely confusing. That a Strategy isn't the thing which would could have a user interface,
      and be interactive; and that it should be implemented as an Indicator is a little strange; but if that
      is really the case, then I guess I can refactor the whole thing.

      Only a rhetorical question but; "are you sure"? It's going to determine a lot of what I develop
      going forward.

      The framework name, whether Indicator or Strategy doesn't really matter; so long as the end result
      is achievable. [edit] I've already implemented a ridiculously complex Indicator which does lots
      of stuff that an "indicator" wouldn't be expected to do... so, I'm on board with the idea.

      [edit] in reading more carefully, maybe it is an "Add On" that I should be developing; so
      THANKS for the info.

      hyperscalper
      Last edited by Hyper; 09-11-2020, 03:39 PM. Reason: more musings

      Comment


        #4
        Thanks for pointing me to the AddOn framework. In my case, this Order Entry tool is very focussed on a single Account,
        and more importantly, only a single Symbol such as NQ futures. I've done a Winforms interface, and I know there is
        some interoperability between WPF and Winforms, but I don't want to open that can of worms right now.

        So I think launching the unmanaged Strategy from a Chart, and picking up the Account and Symbol will be just fine,
        right now. But I will think about the AddOn framework for the future.

        hyperscalper

        Comment


          #5
          Hello Hyper,

          For a quick answer here, I believe you made it to the correct answer. Using a Strategy and avoiding the addon account will be your best bet based on the details.

          Just to help clear some confusion, the general expectation for the types would be:
          • Strategy - Trades in your place automatically with no user interaction - not the best choice for UI creation but is possible.
          • Indicator - Visual and is applied to a specific chart. Can use addon methods to submit orders or work with account items.
          • Addon - A custom tool which may or may not have a UI. Addons start as a background service which can create menu items that lead to opening new tools or do other complex tasks involving manipulating existing windows.
          • Addon Framework (here is a confusion) - This is the Accounts collection you used and the associated logic/methods. The addon framework can be used in any type like an indicator or an Addon type/BarsType/anywhere really.

          The Addon Framework items should generally not be combined with the Managed or Unmanaged items because its a different concept for order entry. The strategy is expecting strategy based orders for its virtual reporting. The Addon framework is submitting and altering things on the account directly. That can conflict with a strategy or cause it to disable depending on what you do.


          I believe the following example could help to move forward if you want to work with UI in a strategy: https://ninjatrader.com/support/help...ub=usercontrol

          That is a simple way to create buttons or other UI elements on the chart. You can also see the indicator DrawingToolTile for an example of creating a floating panel on the chart using the same concepts. More complex items like creating windows can also be achieved.

          One item which comes up here would be using button events or other UI events to access data like Close[0]. In those contexts you need to surround your code with a TriggerCustomEvent: https://ninjatrader.com/support/help...=triggercustom

          Code:
          public void buttonevent(){
              TriggerCustomEvent(o =>
             {
                //code here, Close[0] works here
             }, null);
          }


          I look forward to being of further assistance.
          JesseNinjaTrader Customer Service

          Comment


            #6
            Thanks for every bit of help; your support is the best.
            I'm hoping today to be able to do a "sanity check" with a minimal Order Entry test.
            This should verify Account position tracking, and the entire design.
            This is a tool ranging from manual, through semi-automatic, and eventually
            through to an automated strategy capabilities. But one step at a time.
            It's going to do "micro trend", and "run length" based triggering, so some
            fairly quick things, but also will manage Micro futures contracts as
            aggregate groups, with things like "partial profit taking" of individual
            positions within the aggregate trade group. All of this within a single
            symbol, which is why it's fine if that symbol is determined when the
            code is launched from a Chart.
            My biggest hurdles were addressed elsewhere, and that involves
            identifying the Strategy states, and their relationship to the many
            "clone" instances which are created on startup. Having figured that
            out, I think this will work well, but I will update with a progress
            report, and may run into some roadblocks.
            THANKS for all of your help !!
            hyperscalper
            Last edited by Hyper; 09-14-2020, 08:25 AM. Reason: typo

            Comment


              #7
              Hi. I had a chance to look at the Addons info for both NinjaScript and Visual Studio examples.

              Although my stuff is working great, implemented as a Strategy (unmanaged) launched from a
              Chart with Winforms; having scanned over the Addons info

              I just wanted to thank you for that in-depth info that gives much more insight into how the
              NinjaTrader platform works.

              In future, I'll be using this and it just illustrates what a great job all of you do; by pointing out
              the more advanced information, showing how extensible and powerful the NT8 platform is !!

              Thanks,
              hyperscalper
              Last edited by Hyper; 10-03-2020, 03:02 PM. Reason: typo

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by terkk, Today, 01:16 PM
              1 response
              8 views
              0 likes
              Last Post NinjaTrader_Heath  
              Started by TraderElegante, Today, 12:14 PM
              1 response
              12 views
              0 likes
              Last Post NinjaTrader_PaulH  
              Started by dgee949, Today, 11:44 AM
              1 response
              13 views
              0 likes
              Last Post NinjaTrader_JustinD  
              Started by NinjaTrader_Kate, Today, 12:01 PM
              0 responses
              15 views
              0 likes
              Last Post NinjaTrader_Kate  
              Started by efeuvejota01, Today, 11:42 AM
              1 response
              24 views
              0 likes
              Last Post NinjaTrader_ChrisL  
              Working...
              X