Issues with TurboActivate and NinjaTrader C# indicatorAnswered

I have created a NinjaTrader Indicator which is based on NinjaScript, based around C#. 

I am struggling to follow the instructions to get things setup to use this on an indicator. In NinjaTrader, the indicator is compiled to a single DLL. 

Can you give me some guidance on how to integrate? Your instructions and code for C# would not work in my indicator.

I have provided the code to a very basic sample indicator so you can see the structure. My indicator is much more complex, but the code below still provides the core structure to an indicator. 

Sample NinjaTrader Indicator
 

// This namespace holds indicators in this folder and is required. Do not change it.
namespace NinjaTrader.NinjaScript.Indicators
{
    /// <summary>
    /// Exponential Moving Average. The Exponential Moving Average is an indicator that
    /// shows the average value of a security's price over a period of time. When calculating
    /// a moving average. The EMA applies more weight to recent prices than the SMA.
    /// </summary>
    public class EMA : Indicator
    {
        private double constant1;
        private double constant2;
        protected override void OnStateChange()
        {
            if (State == State.SetDefaults)
            {
                Description                    = NinjaTrader.Custom.Resource.NinjaScriptIndicatorDescriptionEMA;
                Name                        = NinjaTrader.Custom.Resource.NinjaScriptIndicatorNameEMA;
                IsOverlay                    = true;
                IsSuspendedWhileInactive    = true;
                Period                        = 14;
                AddPlot(Brushes.Goldenrod, NinjaTrader.Custom.Resource.NinjaScriptIndicatorNameEMA);
            }
            else if (State == State.Configure)
            {
                constant1 = 2.0 / (1 + Period);
                constant2 = 1 - (2.0 / (1 + Period));
            }
        }
        protected override void OnBarUpdate()
        {
            Value[0] = (CurrentBar == 0 ? Input[0] : Input[0] * constant1 + constant2 * Value[1]);
        }
        #region Properties
        [Range(1, int.MaxValue), NinjaScriptProperty]
        [Display(ResourceType = typeof(Custom.Resource), Name = "Period", GroupName = "NinjaScriptParameters", Order = 0)]
        public int Period
        { get; set; }
        #endregion
    }
}
, edited

I tried adding in code to make things work but not sure if this is right. I have bolded the code I added. When compiling, I am getting the error related to turboactivate.cs on line 86 which is code public string VersionGUID { get; }

The error is: 'wyDay.TurboActivate.TurboActivate.VersionGUID.get' must declare a body because it is not marked abstract or extern. Automatically implemented properties must define both get and set accessors.

Here is my code of my indicator

#region Using declarations
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Gui;
using NinjaTrader.Gui.Chart;
using NinjaTrader.Gui.SuperDom;
using NinjaTrader.Data;
using NinjaTrader.NinjaScript;
using NinjaTrader.Core.FloatingPoint;
using NinjaTrader.NinjaScript.DrawingTools;

using wyDay.TurboActivate;

#endregion
// This namespace holds indicators in this folder and is required. Do not change it.
namespace NinjaTrader.NinjaScript.Indicators
{
 
    public class EMA : Indicator
    {
        private TurboActivate ta;
        private bool isGenuine;
        private string productKey;

        private double constant1;
        private double constant2;
        protected override void OnStateChange()
        {
            if (State == State.SetDefaults)
            {
                Description                    = NinjaTrader.Custom.Resource.NinjaScriptIndicatorDescriptionEMA;
                Name                        = NinjaTrader.Custom.Resource.NinjaScriptIndicatorNameEMA;
                IsOverlay                    = true;
                IsSuspendedWhileInactive    = true;
                Period                        = 14;
                AddPlot(Brushes.Goldenrod, NinjaTrader.Custom.Resource.NinjaScriptIndicatorNameEMA);
// Other initialization code... ta = new TurboActivate("Paste GUID Here");
private const uint DaysBetweenChecks = 90; 
private const uint GracePeriodLength = 14;
                try
               {
                   IsGenuineResult gr = ta.IsGenuine(DaysBetweenChecks, GracePeriodLength, true);
                   isGenuine = gr == IsGenuineResult.Genuine ||
                               gr == IsGenuineResult.GenuineFeaturesChanged ||
                               gr == IsGenuineResult.InternetError;
                   if (!isGenuine && ta.IsActivated())
                   {
                       // Since NinjaTrader doesn't support showing forms, replace this part with suitable code.
                       // For example, you could disable the indicator functionality here.
                       Print("The product is not genuine and needs to re-verify with the LimeLM servers.");
                   }
               }
               catch (TurboActivateException ex)
               {
                   // Handle the exception. For example, print the error message.
                   Print("Failed to check if activated: " + ex.Message);
               }

                // Define your buttons
               AddButton("Activate", "Activate License", ActivateLicense);
               AddButton("Deactivate", "Deactivate License", DeactivateLicense);

            }
            else if (State == State.Configure)
            {
                constant1 = 2.0 / (1 + Period);
                constant2 = 1 - (2.0 / (1 + Period));
            }
        }
        protected override void OnBarUpdate()
        {
            Value[0] = (CurrentBar == 0 ? Input[0] : Input[0] * constant1 + constant2 * Value[1]);
        }

        private void ActivateLicense()
       {
           // launch TurboActivate.exe to get the product key from
           // the user, and activate.
           string documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
           string turboActivateExePath = Path.Combine(documentsPath, @"NinjaTrader 8\bin\Custom\bin\Release\TurboActivate.exe");
           Process TAProcess = new Process
           {
               StartInfo =
       {
               FileName = Path.Combine(
               @"...\NinjaTrader 8\bin\Custom\bin\Release",
               "TurboActivate.exe"
           )
       },
               EnableRaisingEvents = true
           };
           TAProcess.Exited += (sender, e) =>
           {
               CheckIfActivated();
           };
           TAProcess.Start();
       }
       private void DeactivateLicense()
       {
           if (isGenuine)
           {
               // deactivate product without deleting the product key
               // allows the user to easily reactivate
               try
               {
                   ta.Deactivate(false);
               }
               catch (TurboActivateException ex)
               {
                   Print("Failed to deactivate: " + ex.Message);
                   return;
               }
               isGenuine = false;
               // ShowTrial(true); // Depends on your trial functionality
           }
       }

       private void CheckIfActivated()
       {
           bool isNowActivated = false;
           try
           {
               isNowActivated = ta.IsActivated();
           }
           catch (TurboActivateException ex)
           {
               Print("Failed to check if activated: " + ex.Message);
               return;
           }
           // recheck if activated
           if (isNowActivated)
           {
               isGenuine = true;
               // ReEnableAppFeatures(); // Enable your app features
               // ShowTrial(false); // Depends on your trial functionality
           }
       }
        #region Properties

        [Range(1, int.MaxValue), NinjaScriptProperty]
       [Display(ResourceType = typeof(Custom.Resource), Name = "Product Key", Description = "Enter your product key", Order = 0, GroupName = "NinjaScriptStrategyParameters")]
       public string ProductKey
       { get; set; }

        [Range(1, int.MaxValue), NinjaScriptProperty]
        [Display(ResourceType = typeof(Custom.Resource), Name = "Period", GroupName = "NinjaScriptParameters", Order = 0)]
        public int Period
        { get; set; }
        #endregion
    }
}
, edited
Answer

What version of .Net are you using?

It looks like this is a new error: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/cs0840


You can fix it as described in that link (add a private set;)

, edited

NinjaTrader is using .NET 4.8

I am not an experienced developer and I could use a bit more guidance. Can you tell me how I might be able to fix this with private set?

, edited

On line 86 in TurboActivate.cs change it to:

public string VersionGUID { get; private set; }

We can't reproduce this error, but that should fix it. We'll include the modified files in the new TA / TF release.