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 rtwave, Today, 01:49 PM
        0 responses
        8 views
        0 likes
        Last Post rtwave
        by rtwave
         
        Started by papaoutai, Today, 08:56 AM
        0 responses
        22 views
        0 likes
        Last Post papaoutai  
        Started by jdspwe, Today, 05:22 AM
        0 responses
        13 views
        0 likes
        Last Post jdspwe
        by jdspwe
         
        Started by JeremuFemstu, Today, 04:49 AM
        0 responses
        16 views
        0 likes
        Last Post JeremuFemstu  
        Started by pjsmith, Today, 04:11 AM
        1 response
        21 views
        0 likes
        Last Post Green Lobster CBD  
        Working...
        X