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

limit my strategy to be used only by one machine

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

    limit my strategy to be used only by one machine

    How can I make a strategy that I create only be used on one machine? and not be copied and distributed without my consent, maybe using the machine id but not know to enable that option, could they help me
    Last edited by JONHMALCOVICH; 03-17-2020, 11:36 AM.

    #2
    Hello JONHMALCOVICH,

    The Machine ID licensing would only be available to ecosystem vendors, you can read about that in the help guide here: https://ninjatrader.com/support/helpGuides/nt7/licensing_user_authentication.htm

    To otherwise license the script to a single machine you would likely need to implement your own type of system. If you trust the source to not share it but want to make sure the code is not able to be shared you could likely use a compiled export and a string input within the script that takes a password. So long as they don't share the password the script would be useless to anyone else who may access the actual file.

    I look forward to being of further assistance.
    Last edited by NinjaTrader_Jesse; 03-17-2020, 12:40 PM.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Welcome to the forums!

      You have total access to your own MachineId via "Cbi.License.MachineId", which returns a string.

      I presume what you want to do is check for known MachineId's of known friends and family, whom
      you have authorized to use your strategy.

      The easiest way to do this is to hardcode a list of these known MachineId's directly into your
      strategy, then don't allow the strategy to run unless the current Cbi.License.MachineId is found
      in that hardcoded list.

      You'll need the MachineId from each authorized user ahead of time, because you're going to
      edit your code so that their MachineId is included in your list of authorized users.

      Authorizing additional users is relatively easy. When you authorize a 2nd user, get their MachineId
      and add it the internal list in your code, rebuild the strategy, export it, and send the new ZIP file
      to the 2nd user only -- you don't have to send the new ZIP file to the 1st user since the only
      change to the code was the new MachineId of the 2nd user.

      Make sure you protect the compiled assembly. There is a checkbox to automatically do this
      during the Export NinjaScript dialog. You'll have to follow the registration process to use this
      builtin DLL protection layer, which is actually provided by SecureTeam's CliSecure product.

      The registration process to use CliSecure for NT7 is free, but you'll have to pay an additional
      fee to utilize this same feature in NT8.
      Last edited by bltdavid; 03-17-2020, 12:10 PM.

      Comment


        #4
        Originally posted by JONHMALCOVICH View Post
        not be copied and distributed without my consent
        You're not going to stop someone copying and distributing your ZIP file.

        What you really want to do is stop execution without your consent. You'll do this by,

        A) Protect your compiled DLL during the export process.
        B) Refuse to execute unless the current Cbi.License.MachineId is authorized.

        For the poor-man's approach to Step B, see my answer above.

        If someone does copy and distribute your DLL, it is step B that prevents the recipient
        from actually using it.

        Comment


          #5
          Hi, I'm not a professional programmer, and I have a strategy and I still want to protect it and apart from having a 1-year validation, I asked chtgpt to help me with the code but I can't understand it well, could you please guide me


          using System.IO;
          using System.Management;
          using System.Security.Cryptography;​



          class Program
          {
          static void Main(string[] args)
          {
          // Obtener el ID de la máquina
          string machineId = GetMachineId();

          // Generar una licencia única basada en el ID de la máquina
          DateTime expirationDate = DateTime.Now.AddYears(1);
          string licenseKey = GenerateLicenseKey(machineId, expirationDate);

          // Guardar la licencia en un archivo o base de datos
          SaveLicenseKey(licenseKey);

          // Verificar la licencia al iniciar la aplicación
          if (IsValidLicense(machineId, licenseKey))
          {
          Console.WriteLine("Licencia válida. La aplicación puede ejecutarse.");
          // Aquí va tu lógica principal de la estrategia en NinjaTrader
          }
          else
          {
          Console.WriteLine("Licencia inválida. La aplicación no puede ejecutarse.");
          }

          Console.ReadLine();
          }

          static string GetMachineId()
          {
          // Utilizar el ID de la máquina basado en información del sistema
          string machineId = string.Empty;

          using (ManagementObject managementObject = new ManagementObject("win32_logicaldisk.deviceid="c:\ ""))
          {
          managementObject.Get();
          machineId = managementObject["VolumeSerialNumber"].ToString();
          }

          return machineId;
          }

          static string GenerateLicenseKey(string machineId, DateTime expirationDate)
          {
          // Generar una licencia única utilizando el ID de la máquina y la fecha de vencimiento
          string licenseKey = string.Format("{0}-{1:yyyyMMdd}", machineId, expirationDate);

          // Aquí puedes agregar más lógica de encriptación o cálculos adicionales para mejorar la seguridad de la licencia

          return licenseKey;
          }

          static void SaveLicenseKey(string licenseKey)
          {
          // Guardar la licencia en un archivo o base de datos para su posterior verificación
          File.WriteAllText("license.txt", licenseKey);
          }

          static bool IsValidLicense(string machineId, string licenseKey)
          {
          // Verificar si la licencia es válida comparando el ID de la máquina y la fecha de vencimiento
          string savedLicenseKey = File.ReadAllText("license.txt");

          return savedLicenseKey == licenseKey;
          }​

          Comment


            #6
            Hello HGTrader,

            Thank you for your post.

            From our experience at this time, ChatGpt is not quite adequate to generate valid compilable NinjaScripts that function as the user has intended. We often find that the generated code will call non-existent properties and methods, use improper classes or inheritance, and may have incorrect logic. We highly encourage that you create a new NinjaScript yourself using the NinjaScript Editor, and use the code generated by ChatGpt as more as suggestions and guides when coding the script yourself, than using the actual code generated.


            While It would not be within our support model to correct these scripts at user request, we would be happy to provide insight for any direct specific inquiries you may have if you would like to create this script yourself. Our support is able to assist with finding resources in our help guide as well as simple examples, and we are happy to assist with guiding you through the debugging process to assist you with understanding unexpected behavior. For example, we have the following page in the help guide about exporting your NinjaScript as a compiled assembly and using Agile.NET to add an additional layer of obfuscation to your code:



            You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like a list of affiliate consultants who would be happy to create this script or any others at your request or provide one on one educational services.

            Please let us know if we may be of further assistance.​
            Emily C.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by andrewtrades, Today, 04:57 PM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by chbruno, Today, 04:10 PM
            0 responses
            6 views
            0 likes
            Last Post chbruno
            by chbruno
             
            Started by josh18955, 03-25-2023, 11:16 AM
            6 responses
            436 views
            0 likes
            Last Post Delerium  
            Started by FAQtrader, Today, 03:35 PM
            0 responses
            7 views
            0 likes
            Last Post FAQtrader  
            Started by rocketman7, Today, 09:41 AM
            5 responses
            19 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Working...
            X