Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Reusable Code--Best Practice for Class location

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

    Reusable Code--Best Practice for Class location

    Sorry if this is a duplicate post. I can't find what I thought I posted

    What is the best practice for reusable code? Assume I want to build a trailing stop class to be tested/used in several different strategies. Should I locate it in the Strategies folder? I tried to put it in a sub folder but could not access it from the Edit NinjaScript menu.

    If I build a separate class, can I still use parameters from the optimizer in the Strategy analyzer?
    (partial class) file. But that appears to only be for common methods. Can that be adapted for common variables and parameters?

    #2
    Hello blach00,

    Thank you for your post.

    You would need to be able to access the class from within a strategy, any variable you pass to the class would need to be user defined variables so that the optimizer could optimize those parameters.

    For information on User Defined Parameters please visit the following link: http://www.ninjatrader.com/support/f...ead.php?t=5782

    You can also create User Defined Methods for your strategies, for information please visit the following link: http://www.ninjatrader.com/support/h...ed_methods.htm

    Please let me know if I may be of further assistance.

    Comment


      #3
      Thanks for your reply.

      I did try to instanciate an simple test strategy (class) and to make the instance a member of the actual Strategy Class but the Test Class was not accessible even though the Class is public and I am fully specifying the Namespace.Class.

      So, the only way to have the parameters available to the Optimizer is to put all the code in the Strategy, is that correct?

      Comment


        #4
        Hello blach00,

        Thank you for your response.

        Adding the code to the strategy will work.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by EB Worx, 04-04-2023, 02:34 AM
        7 responses
        161 views
        0 likes
        Last Post VFI26
        by VFI26
         
        Started by Mizzouman1, Today, 07:35 AM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by Radano, 06-10-2021, 01:40 AM
        20 responses
        616 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by i019945nj, 12-14-2023, 06:41 AM
        6 responses
        68 views
        0 likes
        Last Post i019945nj  
        Started by aa731, Today, 02:54 AM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Working...
        X