• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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.
    Patrick H.NinjaTrader Customer Service

    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.
        Patrick H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by maggie3, Today, 02:05 AM
        0 responses
        3 views
        0 likes
        Last Post maggie3
        by maggie3
         
        Started by qewcool, Today, 01:14 AM
        0 responses
        3 views
        0 likes
        Last Post qewcool
        by qewcool
         
        Started by fredrikn, 05-08-2019, 04:01 AM
        17 responses
        669 views
        1 like
        Last Post emtrader  
        Started by zacharydw00, Yesterday, 10:19 PM
        0 responses
        3 views
        0 likes
        Last Post zacharydw00  
        Started by chafan11, Yesterday, 09:28 PM
        0 responses
        7 views
        0 likes
        Last Post chafan11  
        Working...
        X