Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Default Constructor

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

    Default Constructor

    I am trying to add Vendor Licensing to my strategy but I am not familiar with using a default constructor. The strategy will compile, export and import ok, but when I go to add the strategy to a chart, I get an error.... Any guidance you can provide would be appreciated. Here is part of the code...

    #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.Gui.Tools;
    using NinjaTrader.Data;
    using NinjaTrader.NinjaScript;
    using NinjaTrader.Core.FloatingPoint;
    using NinjaTrader.NinjaScript.Indicators;
    using NinjaTrader.NinjaScript.DrawingTools;
    #endregion

    //This namespace holds Strategies in this folder and is required. Do not change it.
    namespace NinjaTrader.NinjaScript.Strategies
    {
    public class MOT_Strategy : Strategy
    {
    public MOT_Strategy()
    {
    VendorLicense("VendorName", "MOT_Strategy", "https://xxxx.com", "emailaddress");
    }


    private EMA EMA1;
    private EMA EMA2;
    private string atmStrategyId = string.Empty;
    private string orderId = string.Empty;
    private bool isAtmStrategyCreated = false;

    #2
    Hello mlarocco,

    Do you get this error when you add the vendor licensing line of code specifically or with the constructor by its self? I would suggest to remove the vendor licensing part and make sure that it can export/import and apply correctly when using a compiled/protected assembly. If that works you would need to try the constructor by its self without the vendor license code and repeat that test again.

    Comment


      #3
      Originally posted by NinjaTrader_Jesse View Post
      Hello mlarocco,

      Do you get this error when you add the vendor licensing line of code specifically or with the constructor by its self? I would suggest to remove the vendor licensing part and make sure that it can export/import and apply correctly when using a compiled/protected assembly. If that works you would need to try the constructor by its self without the vendor license code and repeat that test again.
      The strategy imported and would apply to the chart without error before the VendorLicense lines were added, it also worked correctly. I get the error when I open the strategy window (video below). Sorry, I don't know exactly what a constructor is or what the code looks like for it, this is the first time I've tried adding vendor licensing to any indicators/strategies.

      World's leading screen capture + recorder from Snagit + Screencast by Techsmith. Capture, edit and share professional-quality content seamlessly.

      Comment


        #4
        Originally posted by NinjaTrader_Jesse View Post
        Hello mlarocco,

        Do you get this error when you add the vendor licensing line of code specifically or with the constructor by its self? I would suggest to remove the vendor licensing part and make sure that it can export/import and apply correctly when using a compiled/protected assembly. If that works you would need to try the constructor by its self without the vendor license code and repeat that test again.
        I think I found the problem, it seems it didn't like the underscore in the product name. I removed it and the error is gone

        Comment


          #5
          Hello mlarocco,

          Thanks for the update. That would make sense, the platform prevents you from using underscores when you generate new files using either the strategy builder or the editor. In the future I would suggest to create the script using those tools just to make sure the name you used is completely valid.

          You can still use an underscore in the Name= "" string if you wanted it in the UI, alternatively you can use a Space in the actual Name property.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          579 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          334 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          554 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          551 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X