Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy and Indicator superclass

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

    #16
    Originally posted by adamus View Post
    In the LogHelper class - so that I don't have to write it repeatedly in the indicators and strategies that use it.
    All the more reason to use partial classes. All those methods are then natively available.

    Comment


      #17
      Originally posted by koganam View Post
      All the more reason to use partial classes. All those methods are then natively available.
      Maybe I don't know enough C# but I thought that wouldn't be possible, since I want to use the LogHelper in indicators and in strategies - are you saying I can code partial class that is a partial class of both Strategy and of Indicator? And aren't namespaces an issue?

      And when you say "natively available", do you mean that instead of

      Code:
      logHelper.log("stuff");
      I could just do this?:

      Code:
      log("stuff");

      Comment


        #18
        Hello adamus,

        While partial classes are something that we cannot support here are a few examples that may help you out.


        I was wondering if someone could give me an overview of why I would use them and what advantage I would gain in the process.

        Partial classes and members in C# split the definition of a class, a struct, an interface, or a member over two or more source files.
        JCNinjaTrader Customer Service

        Comment


          #19
          Originally posted by NinjaTrader_JC View Post
          Hello adamus,

          While partial classes are something that we cannot support here are a few examples that may help you out.


          I was wondering if someone could give me an overview of why I would use them and what advantage I would gain in the process.

          http://msdn.microsoft.com/en-us/library/wa80x488.aspx
          Huh? Do you support UserDefinedMethods.cs that you ship? They are partial classes.

          Comment


            #20
            Originally posted by adamus View Post
            Maybe I don't know enough C# but I thought that wouldn't be possible, since I want to use the LogHelper in indicators and in strategies - are you saying I can code partial class that is a partial class of both Strategy and of Indicator? And aren't namespaces an issue?

            And when you say "natively available", do you mean that instead of

            Code:
            logHelper.log("stuff");
            I could just do this?:

            Code:
            log("stuff");
            Not quite. That would depend on how you define/override the method. OTOH, you would not have to say Indicator.Print() or Indicator.Log(), nor their Strategy analogs, as they would both be natively supported as simply Print() and Log(). While you can embed a class in another class, that would not even be necessary. You could pretty much just define them as methods of the partial class itself, and call them as necessary.
            Last edited by koganam; 07-21-2013, 08:28 AM. Reason: Removed duplicate word.

            Comment


              #21
              Originally posted by koganam View Post
              Not quite. That would depend on how you define/override the method. OTOH, you would not have to say Indicator.Print() or Indicator.Log(), nor their Strategy analogs, as they would both be natively supported as simply Print() and Log(). While you can embed a class in another class, that would not even be necessary. You could pretty much just define them as as methods of the partial class itself, and call them as necessary.
              OK thanks. But wouldn't I have to maintain two different versions of my log-helper stuff? One for Indicator namespace and one for the Strategy namespace?

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              661 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              376 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              110 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              574 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              580 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X