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 NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    53 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    130 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    70 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    44 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    49 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X