Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Master and Secondary Strategy files

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

  • bltdavid
    replied
    Although Kate means well, I would forget the 'partial class' suggestion.

    There is a better way.

    Create your own abstract base class that inherits from Strategy.

    Code:
    abstract public class MyStrategyBase : Strategy
    Then your actual strategy inherits from MyStrategyBase.

    All of your common strategy code goes into MyStrategyBase.

    Leave a comment:


  • UltraNIX
    replied
    So I can only use methods from one partial class, or anything else?

    Leave a comment:


  • NinjaTrader_Kate
    replied
    Hello UltraNix,

    Thank you for your post.

    There wouldn't be a way for two strategies to directly communicate with each other, but you could use custom partial classes in the Strategy namespace to hold common logic and then simply use the common logic in your script with the individualized entries and exits.

    Please see this section of our help guide on custom partial classes:



    Please let us know if we may be of further assistance to you.


    Leave a comment:


  • UltraNIX
    started a topic Master and Secondary Strategy files

    Master and Secondary Strategy files

    Hey,

    I want to reduce the amount of work when editing the same parts of code in multiple strategies and possibility of error doing so by just splitting strategy into several files, as my main code (with Entry/Exit/Money and Risk Management filters that are used in all strategies) is exactly the same, and only parts that change are specific entries and exits of each strategy.

    How can I refactor my strategies, so that all of them use main master file and only custom entries and exits?

Latest Posts

Collapse

Topics Statistics Last Post
Started by Mindset, 04-21-2026, 06:46 AM
0 responses
64 views
0 likes
Last Post Mindset
by Mindset
 
Started by M4ndoo, 04-20-2026, 05:21 PM
0 responses
94 views
0 likes
Last Post M4ndoo
by M4ndoo
 
Started by M4ndoo, 04-19-2026, 05:54 PM
0 responses
51 views
0 likes
Last Post M4ndoo
by M4ndoo
 
Started by cmoran13, 04-16-2026, 01:02 PM
0 responses
108 views
0 likes
Last Post cmoran13  
Started by PaulMohn, 04-10-2026, 11:11 AM
0 responses
63 views
0 likes
Last Post PaulMohn  
Working...
X