Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to programmatically read (and hopefully write) user-editable global properties...

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

    How to programmatically read (and hopefully write) user-editable global properties...

    Hello NinjaTrader gurus!

    I am creating my own strategy and that same strategy must run on several different instruments. (On a given trading day I'll have 9-12 different charts all running my one strategy in different tiled windows)

    While I can control the operation of each instance of my strategy, there are situations where I need to control all running instances in the same way.

    Is there in any window of NinjaTrader8 some 'custom user fields' that a) the user can modify via some kind of global GUI control and a) can be programmatically read from each strategy instance?

    IDEA1: If a strategy instance can access the other running instances perhaps I can designate one as the 'master' and have the 'slave' strategies poll from the master one?
    IDEA2: Perhaps some NinjaTrader entity such as 'Account', or 'Instrument' can have extra user properties that a strategy can read?
    IDEA3: Perhaps having all strategies poll their input values from some Excel spreadsheet (values read through .Net COM automation)

    For the above to work well I need some sort of easy 'global input GUI' that I can interact with to control all my instances.

    Many thanks!

    #2
    Hello JPPoulin, thanks for your note.

    This kind of multiple strategy management does not exist, you would either need to manage each strategy instance or design your strategy to accept multiple instruments as NinjaTrader does support multi instrument scripts. If you have a specific feature you would like to see in the platform to help with this, please describe the feature in as much detail as possible.

    Kind regards.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Hi Chris,

      Thanks for the early and useful response!

      Too bad there isn't a 'global user properties' mechanism (and accompanying GUI) that could steer multiple instances in one go.

      Q: Do you think a multi-instrument script is recommended in a setup that has 9-12 different chart windows all neatly tiled up? (In other words, if I port my code to use a multi-instrument approach, would I be forced to make heavy concessions as to my (currently super-usable) tiled-chart layout? (e.g. forces 9-12 instruments to be stacked up and become wide but super short?)

      Alternatively, maybe automating Microsoft Excel to act as my 'central GUI' would be the better approach... I'm currently researching the (very helpful) post linked below to circumvent this issue. (By going through Excel I can also log things out better and have an Excel and a NT8 codebase that work together to automate my trades, facilitate performance stats, help with accounting, etc)

      Comment


        #4
        Hello JPPoulin, thanks for your reply.

        The one downside to developing the strategy to take all of the instruments is that it will run on one chart only (Or as once instance from the Control Center). The data series that you enable your strategy on will be the primary series. If you have ChartTrader enabled on all of your charts, you will see the executions from the strategy even if they run as a single instance.

        Excel programming goes beyond the scope of support I can provide and im not sure how much Excel could manipulate the platform, but if you are able to get use out of that then that is good. I will submit a feature request to add a batch strategy management tool.

        Best regards.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Hi Chris,

          Thanks for the advice. Full steam ahead to integrate NT8 with Excel then!

          As for the new feature request what would be super useful is:
          - A 'Visual Basic'-like Canvas where programmatic code can insert controls dynamically and trap events in code when user interacts with them.
          - The ability for this 'global GUI' to 'push' its commands into running instances of strategies (via its public functions)
          - The ability for strategy / indicator instances to 'pull' data from the above global GUI canvas.
          - A sample GUI with code, and a sample strategy that communicates with it.

          Such functionality would make it possible for programmers to create an 'account manager' where the funds allocated for a given investment opportunity are managed by some global user logic.

          Hope that helps!

          Comment


            #6
            Originally posted by JPPoulin View Post
            Hello NinjaTrader gurus!

            I am creating my own strategy and that same strategy must run on several different instruments. (On a given trading day I'll have 9-12 different charts all running my one strategy in different tiled windows)

            While I can control the operation of each instance of my strategy, there are situations where I need to control all running instances in the same way.

            Is there in any window of NinjaTrader8 some 'custom user fields' that a) the user can modify via some kind of global GUI control and a) can be programmatically read from each strategy instance?

            IDEA1: If a strategy instance can access the other running instances perhaps I can designate one as the 'master' and have the 'slave' strategies poll from the master one?
            IDEA2: Perhaps some NinjaTrader entity such as 'Account', or 'Instrument' can have extra user properties that a strategy can read?
            IDEA3: Perhaps having all strategies poll their input values from some Excel spreadsheet (values read through .Net COM automation)

            For the above to work well I need some sort of easy 'global input GUI' that I can interact with to control all my instances.

            Many thanks!
            Use a static field.

            ref: https://docs.microsoft.com/en-us/dot...-class-members
            A field in C# is a variable of any type that is declared directly in a class or struct. Fields are members of their containing type.

            Comment


              #7
              Hello Koganam,

              Thank you for the suggestion. If I understand correctly you think that the 'master strategy' (the one that is the source of the shared properties the slave use) should define itself in a static field?

              That could work if a strategy can obtain a list of all the other running strategies.

              Do you know how that can be done?

              Thanks!

              Comment


                #8
                Originally posted by JPPoulin View Post

                Hello Koganam,

                Thank you for the suggestion. If I understand correctly you think that the 'master strategy' (the one that is the source of the shared properties the slave use) should define itself in a static field?

                That could work if a strategy can obtain a list of all the other running strategies.

                Do you know how that can be done?

                Thanks!
                Just declare the static field in the class itself. Every instance of the class will use the same static field, and by default, every instance can read and update that field.

                If you want to be able to deny writing to that field, create a static method that validates access. For example, the class can have a bool "master" such that only if that is "true" can that instance update your tracking static field.

                Comment


                  #9
                  Thanks koganam,

                  I tried it and it works great! I've created a class with a singleton instance that manages my connection to MS Access. (to pull global and per-instance arguments for all instances of my running strategy)

                  Works great!

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by bortz, 11-06-2023, 08:04 AM
                  47 responses
                  1,605 views
                  0 likes
                  Last Post aligator  
                  Started by jaybedreamin, Today, 05:56 PM
                  0 responses
                  8 views
                  0 likes
                  Last Post jaybedreamin  
                  Started by DJ888, 04-16-2024, 06:09 PM
                  6 responses
                  18 views
                  0 likes
                  Last Post DJ888
                  by DJ888
                   
                  Started by Jon17, Today, 04:33 PM
                  0 responses
                  4 views
                  0 likes
                  Last Post Jon17
                  by Jon17
                   
                  Started by Javierw.ok, Today, 04:12 PM
                  0 responses
                  13 views
                  0 likes
                  Last Post Javierw.ok  
                  Working...
                  X