Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategies that inherit/INCLUDE from a main strategy?

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

    Strategies that inherit/INCLUDE from a main strategy?

    Hi.
    I have a custom strategy that I am building. Let's say it's called strategyMain.

    I'd like to be able to create another strategy that basically inherits all the properties, variables, and functions of strategyMain. Let's call this second strategy, strategyMainCloned.

    I would use these 2 strategies on 2 separate instruments/charts (say ES and CL)... but I want these 2 separate instance so that I can track the PNL and backtest and forward test them separately without the PNL for strategyMain being aggregated between instrument 1 and instrument 2.

    I know I can duplicate/clone the strategy and have a full copy of all the source code from strategyMain. But I'd rather have one main source of the code, so that as I need to tweak it, I only need to update the code in one place. Ideally, strategyMainCloned would automatically inherit the updates that I make to strategyMain.


    How would I do that within Ninjascript (Editor)?

    Thanks.

    #2
    Hello q40bomb,

    Thank you for your post.

    This would be unsupported as NinjaScript strategies are not meant to share information between eachother.

    If you want to use unsupported methods, consider using static properties in an Add On class to share information. Please note the support team cannot assist with unsupported code/solutions.

    Please let me know if you have any other questions.​

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    87 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    128 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    65 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    117 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    67 views
    0 likes
    Last Post PaulMohn  
    Working...
    X