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

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.

    JesseNinjaTrader Customer Service

    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.

      https://www.screencast.com/t/9WSddJdT2Yk

      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.
          JesseNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by r3n3v, 11-24-2022, 09:35 PM
          2 responses
          22 views
          0 likes
          Last Post r3n3v
          by r3n3v
           
          Started by llanqui, 11-26-2022, 12:05 PM
          3 responses
          21 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by measmukesh, 11-26-2022, 07:53 AM
          3 responses
          47 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by ラリー, 11-22-2022, 04:57 AM
          11 responses
          67 views
          0 likes
          Last Post NinjaTrader_Emily  
          Started by sesplin, Yesterday, 07:53 PM
          2 responses
          16 views
          0 likes
          Last Post sesplin
          by sesplin
           
          Working...
          X