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.

      Free online storage and sharing with Screencast.com. 2 GB of storage and 2 GB of bandwidth per month for free. We won't compress, alter or take ownership of your content.

      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 benmarkal, Yesterday, 12:52 PM
          3 responses
          22 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by helpwanted, Today, 03:06 AM
          1 response
          17 views
          0 likes
          Last Post sarafuenonly123  
          Started by Brevo, Today, 01:45 AM
          0 responses
          11 views
          0 likes
          Last Post Brevo
          by Brevo
           
          Started by aussugardefender, Today, 01:07 AM
          0 responses
          6 views
          0 likes
          Last Post aussugardefender  
          Started by pvincent, 06-23-2022, 12:53 PM
          14 responses
          244 views
          0 likes
          Last Post Nyman
          by Nyman
           
          Working...
          X