Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Move execution management from a Strategy into an AddOn Custom Class

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

    Move execution management from a Strategy into an AddOn Custom Class

    NT Team,

    Is it possible to move execution management from a Strategy into an AddOn Custom Class?

    I am attempting to break a Strategy into more manageable classes. Please find attached a Strategy "TestOnOrderUpdate", and AddOn "ManagerExecution" which attempt to move execution management out of the Strategy. The Strategy is based on SampleOnOrderUpdate.

    Please advise :
    - whether this is a viable solution,
    - whether this course of action is ill-advised, or
    - propose a more appropriate solution.

    As always, thanks
    Shannon
    Attached Files

    #2
    Originally posted by Shansen View Post
    - propose a more appropriate solution.
    My suggestion is: use an abstract base class.

    You can add your overrides for the NinjaScript methods
    OnExecutionUpdate, OnOrderUpdate, etc, directly to your
    abstract base class.

    Portions of that idea available for study here.
    Last edited by bltdavid; 12-31-2021, 11:29 PM.

    Comment


      #3
      Hello Shansen,

      Abstract classes are an advanced C# concept and not fully supported by the Scripting Support team.

      There can be limitations using advanced C# concepts, in NinjaScript, so your mileage may vary. As of now, we do not have any examples that can be used to navigate that path.

      Partial classes are also an advanced C# concept but I do have an example of this.
      Explanation: I wrote a base class Indicator class that I'm using to inherit all my other indicators from. So this baseclass is defined as: namespace NinjaTrader.NinjaScript.Indicators.AssistedTrades { public class ATBaseIndicator: Indicator { ... } } And any other indicator is defined as: namespace NinjaTrader.NinjaScr
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        Originally posted by NinjaTrader_ChelseaB View Post
        Abstract classes are an advanced C# concept and not fully supported by the Scripting Support team.

        There can be limitations using advanced C# concepts, in NinjaScript, so your mileage may vary. As of now, we do not have any examples that can be used to navigate that path.
        Limitations for strategies?
        Can you elaborate?

        Comment


          #5
          bltdavid, thank for suggesting your approach, an abstract base class.
          If I understand correctly, this approach would allow:
          - coding logic for one Strategy to be split among multiple files (via the Strategy and base class files).
          - multiple Strategies to access shared methods in the abstract base class.

          NinjaTrader_ChelseaB, thank for suggesting your approach, partial classes.
          If I understand correctly, this approach would allow:
          - coding logic for one Strategy to be split among multiple files (via several partial class files for the Strategy).
          - coding logic for multiple Strategies, to be split among multiple files (via "partial class Strategy").
          - multiple Strategies to access shared methods in the "partial class Strategy".

          I am trying to separate the one Strategy class into several classes pursuing (perhaps naively) the Single Responsibility Principle (SRP), that a class should have only one responsibility.
          Currently my multi-timeframe Strategy:
          - Manages Entry Criteria from Indicators
          - Manages Entry after meeting criteria
          - Manages Execution (via OnOrderUpate & OnExecutionUpdate)
          - Manages Exits after meeting criteria
          - Manages Session Hours (by Instrument, US cash hours, and EU cash hours)
          - Manages Margins (by Instrument, intraday, and initial)
          - Manages Order Quantity (for entry and exit by margin and risk)

          I imagine this is a common problem and am looking for guidance on common approaches to split one Strategy class into several classes with a single responsibility (or closer to it).
          If my understanding is correct, implementing an abstract base class or partial classes would not achieve this goal.

          Happy to have my understanding corrected.
          Happy for other approaches to achieve this goal.
          Last edited by Shansen; 01-02-2022, 11:48 PM.

          Comment


            #6
            Originally posted by Shansen View Post
            I imagine this is a common problem and am looking for guidance on common approaches to split one Strategy class into several classes with a single responsibility (or closer to it).
            If my understanding is correct, implementing an abstract base class or partial classes would not achieve this goal.
            Nonsense.
            One or more abstract base classes can achieve all your goals.
            Contact me privately if you wish a Skype exchange to see what's possible.

            Comment


              #7
              bltdavid, thank you for your offer of help.
              You have received a private message from me.
              Again, thanks
              Shannon

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by NullPointStrategies, Yesterday, 05:17 AM
              0 responses
              65 views
              0 likes
              Last Post NullPointStrategies  
              Started by argusthome, 03-08-2026, 10:06 AM
              0 responses
              139 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              75 views
              0 likes
              Last Post NabilKhattabi  
              Started by Deep42, 03-06-2026, 12:28 AM
              0 responses
              45 views
              0 likes
              Last Post Deep42
              by Deep42
               
              Started by TheRealMorford, 03-05-2026, 06:15 PM
              0 responses
              50 views
              0 likes
              Last Post TheRealMorford  
              Working...
              X