• 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

How to use NinjaTrader.Cbi.License object as a method parameter

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

    How to use NinjaTrader.Cbi.License object as a method parameter

    Hello.

    I made my own Test_class and put it to separate .cs file
    And I'd like to check MashineID in constructor.
    Code:
    using NinjaTrader.Cbi;
    namespace i_Lib_Test
    {
        public class Test_class
        {
            public Test_class( NinjaTrader.Cbi.License licenseObject )
            { 
            }
        }
    }
    Then I tried to create an instance of Test_class object, but it don't work:

    Code:
    Test_class tc = new Test_class( this.Cbi.License );
    Test_class tc = new Test_class( NinjaTrader.Cbi.License );
    Test_class tc = new Test_class( License );
    Can You, please, tell what object I have to use as argument?
    (I'm sure using just Licenes.MashineID string as argument is useless, am I wrong?).
    Last edited by fx.practic; 09-07-2015, 02:04 PM.

    #2
    Originally posted by fx.practic View Post
    Hello.

    I made my own Test_class and put it to separate .cs file
    And I'd like to check MashineID in constructor.
    Code:
    using NinjaTrader.Cbi;
    namespace i_Lib_Test
    {
        public class Test_class
        {
            public Test_class( NinjaTrader.Cbi.License licenseObject )
            { 
            }
        }
    }
    Then I tried to create an instance of Test_class object, but it don't work:

    Code:
    Test_class tc = new Test_class( this.Cbi.License );
    Test_class tc = new Test_class( NinjaTrader.Cbi.License );
    Test_class tc = new Test_class( License );
    Can You, please, tell what object I have to use as argument?
    (I'm sure using just Licenes.MashineID string as argument is useless, am I wrong?).
    Just use the string.

    ref: http://ninjatrader.com/support/forum...ead.php?t=1478

    Comment


      #3
      Originally posted by koganam View Post
      I want put main calculation in separate class compiled to DLL. That class will be "black box" - just gives buy / sell signals.

      And strategy code I want leave opened.

      In this case anyone can edit strategy code and change
      Code:
      Test_Class ts = new Test_class( NinjaTrader.Cbi.License.MashineID);
      to constant string:
      Code:
      Test_Class ts = new Test_class( "666777666777666777666777666777666777");

      Comment


        #4
        Originally posted by fx.practic View Post
        I want put main calculation in separate class compiled to DLL. That class will be "black box" - just gives buy / sell signals.

        And strategy code I want leave opened.

        In this case anyone can edit strategy code and change
        Code:
        Test_Class ts = new Test_class( NinjaTrader.Cbi.License.MashineID);
        to constant string:
        Code:
        Test_Class ts = new Test_class( "666777666777666777666777666777666777");
        So create a static class to check and report for you.

        ref: http://ninjatrader.com/support/forum...27&postcount=5

        You might want to read the entire thread for the subtle nuances.

        Comment


          #5
          koganam, thank You for Your answers!

          I read the thread, but I have misunderstanding.

          My situation: I want give to another person 2 files:
          1) BuySell.dll that contain Test_class;
          2) MyStarategy.cs, that contain this code:
          Code:
          using BuySellSignals;
          
              public class MyStartegy : Strategy
              {        
                  private BuySellSignals_class Buy_Sell_Object;
          
                  protected override void OnStartUp()
                  { 
                      Buy_Sell_Object = new BuySellSignals_class( NinjaTrader.Cbi.License.MashineID );
                  }    
                  
                  protected override void OnBarUpdate()
                  {
                      switch( Buy_Sell_Object( Open[0], High[0], Low[0], Close[0] ) )
                      {
                          case "buy":  EnterLong();
                          case "sell": EnterShort();                
                      }            
                  }
              }
          }
          In that case, independently of BuySell.dll code and access modifiers inside it, any user can replace in any text editor "NinjaTrader.Cbi.License.MashineID" to constant string.

          So, I want to use as a parameter something bigger than just string.

          Comment


            #6
            Hello fx.practic,

            Could you please clarify what you mean when you say the following:
            So, I want to use as a parameter something bigger than just string.
            From the example provided, you could put the code that checks the license key in your BuySellSignals_class and have it return null (or similar) if the machine ID provided to it is not valid.

            Then you would just recompile the BuySell.cs assembly and add in a null reference check inside the OnBarUpdate code of your MyStrategy.cs file.

            Please let me know if you have any questions.
            Michael M.NinjaTrader Quality Assurance

            Comment


              #7
              Originally posted by fx.practic View Post
              koganam, thank You for Your answers!

              I read the thread, but I have misunderstanding.

              My situation: I want give to another person 2 files:
              1) BuySell.dll that contain Test_class;
              2) MyStarategy.cs, that contain this code:
              Code:
              using BuySellSignals;
              
                  public class MyStartegy : Strategy
                  {        
                      private BuySellSignals_class Buy_Sell_Object;
              
                      protected override void OnStartUp()
                      { 
                          Buy_Sell_Object = new BuySellSignals_class( NinjaTrader.Cbi.License.MashineID );
                      }    
                      
                      protected override void OnBarUpdate()
                      {
                          switch( Buy_Sell_Object( Open[0], High[0], Low[0], Close[0] ) )
                          {
                              case "buy":  EnterLong();
                              case "sell": EnterShort();                
                          }            
                      }
                  }
              }
              In that case, independently of BuySell.dll code and access modifiers inside it, any user can replace in any text editor "NinjaTrader.Cbi.License.MashineID" to constant string.

              So, I want to use as a parameter something bigger than just string.
              I do not understand what you have written and how it relates to the code to which I referred you.

              The class for checking the MachineID has only one purpose: to check that the MachineID of the running computer is in the list maintained inside the MachineID-checking class. So how does changing the comparator in another class have any meaning, unless that, now fixed, comparator is already on the approved list inside the MachineID-checking class?

              Addendum:
              And if you are going to expose the check in another class which can be edited to replace the MachineID in the first place, then that same person can edit out the check completely, no matter what you think you are doing in the checking class.
              Last edited by koganam; 09-08-2015, 02:37 PM.

              Comment


                #8
                2 NinjaTrader_MichaelM:Wow! It's rely work!

                Code:
                namespace Lib_BuySelSignals
                {    
                    public class BuySelSignals_class
                    {
                        public BuySelSignals_class()
                        {
                            string masine_id = NinjaTrader.Cbi.License.MachineId;    
                        }
                    }
                }
                Some time ago I tried to call Open, High, Low, Close, Time dataseries from my own classes, and got error. So, I decided that NT objects and classes are unaccessible from custom classes.

                And now I see NinjaTrader.Cbi.License can be called with no problem.

                Thank You.


                2 koganam:
                I thought in this way:
                Can user create new string object (that contains fixed MachineID)? - Yes, he can.
                Can user create, for example new NinjaTrader object? - No, he can't - only one NT instance can be running.
                Can user create NinjaTrader.Cbi or NinjaTrader.Cbi.License object? - I don't know. But, if he can, it must be march more difficult that create fake string.

                But now I see there no need to do it. As for, as I understand, NinjaTrader.Cbi.License is a static class ant it can be accessible from custom libraries.

                Thank You.

                Comment


                  #9
                  Hello fx.practic,

                  Thank you for the update. I am glad to hear everything is working for you now.

                  Please let us know if you have any questions or if we may be of further assistance anytime.
                  Michael M.NinjaTrader Quality Assurance

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by wolfcuring, Today, 04:08 AM
                  0 responses
                  2 views
                  0 likes
                  Last Post wolfcuring  
                  Started by cirzonorkecv, Yesterday, 11:52 PM
                  0 responses
                  6 views
                  0 likes
                  Last Post cirzonorkecv  
                  Started by rickyblah12, Yesterday, 01:01 PM
                  1 response
                  14 views
                  0 likes
                  Last Post Erwin Beckers  
                  Started by dadarara, Yesterday, 12:18 PM
                  0 responses
                  8 views
                  0 likes
                  Last Post dadarara  
                  Started by joemiller, Yesterday, 07:33 AM
                  2 responses
                  13 views
                  0 likes
                  Last Post joemiller  
                  Working...
                  X