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

Ninjascript Programmers Launch Pad

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

    Ninjascript Programmers Launch Pad

    Has anyone purchased this book "Ninjascript Programmers Launch Pad" by Scott Daggett?

    In the book he has us create 2 indicators:
    UpDownTradeVolumeNV
    UpDownVolumePlot

    After completing indicators, he says to add the indicator to a chart. However when trying to add to chart, the new indicators are not in the list. Does not say whether they need to be compiled. When compiling the indicators, get an error:

    Indicator\UpDownTradeVolumeNV.cs The type 'NinjaTrader.Indicator.UpDownTradeVolumeNV' already contains a definition for 'downVolume' CS0102 - click for info 82 21

    Line 82 in the code is: private UpDownVolumePlot[] cacheUpDownVolumePlot = null;

    This is under NInjascript generated code and cannot be changed or removed. So what am I doing wrong?

    Thanks

    #2
    Hello,

    Yes, the indicator would need to be in a compiled state to be able to apply the indicator to a chart.

    Regarding the error, without the indicator I'm unable to test on my end.

    Please upload a copy of the indicator with the instructions below,

    To export a NinjaScript from NinjaTrader 7 do the following:
    From the Control Center window select File -> Utilities-> Export NinjaScript...
    Select the file in the left column then click “>”, then press export and name the file.
    Then attach that file you saved; under My Docs>NT7>Bin>Custom>Select the downloaded .zip file.

    I look forward to your reply.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Hi Alan,

      Thank you for the quick reply...

      I am unable to export the indicator since Ninja is telling me there are code errors. In Ninjascript I do not see any errors but when trying to compile it gives that error on line 82 which is under the "ninjatrader generated code". I copied exactly what the book said to code, and this is what has happened. So far this book is turning into a dissapointment if it does not even say to compile.
      I copied the code and here is the paste if that helps...

      /// <summary>
      /// Plots the estimated volumes higher and lower than previous trades.
      /// </summary>
      [Description("Plots the estimated volumes higher and lower than previous trades.")]
      public class UpDownVolumePlot : Indicator
      {
      #region Variables
      // Wizard generated variables
      // User defined variables (add any user defined variables below)
      #endregion

      /// <summary>
      /// This method is used to configure the indicator and is called once before any bar data is loaded.
      /// </summary>
      protected override void Initialize()
      {
      Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Bar, "UpVol"));
      Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Bar, "DownVol"));
      Add(new Plot(Color.FromKnownColor(KnownColor.Gray), PlotStyle.Line, "ZeroLine"));
      Overlay = false;
      }

      /// <summary>
      /// Called on each bar update event (incoming tick)
      /// </summary>
      protected override void OnBarUpdate()
      {
      // Use this method for calculating your indicator values. Assign a value to each
      // plot below by replacing 'Close[0]' with your own formula.
      UpVol.Set(UpDownTradeVolumeNV().UpVolume[0]);
      DownVol.Set(-UpDownTradeVolumeNV().downVolume[0]);
      ZeroLine.Set(0.00);
      }

      #region Properties
      [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
      [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
      public DataSeries UpVol
      {
      get { return Values[0]; }
      }

      [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
      [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
      public DataSeries DownVol
      {
      get { return Values[1]; }
      }

      [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
      [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
      public DataSeries ZeroLine
      {
      get { return Values[2]; }
      }

      #endregion

      Comment


        #4
        The other indicator (UpDwnTradeVolumeNV) also same error line 82.. here is the code:

        #region Variables
        // Wizard generated variables
        // User defined variables (add any user defined variables below)
        private DataSeries upVolume;
        private DataSeries downVolume;
        #endregion

        /// <summary>
        /// This method is used to configure the indicator and is called once before any bar data is loaded.
        /// </summary>
        protected override void Initialize()
        {
        Overlay = false;
        CalculateOnBarClose = true;
        PriceTypeSupported = false;
        }

        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
        // Use this method for calculating your indicator values. Assign a value to each
        // plot below by replacing 'Close[0]' with your own formula.
        double curC = Close[0];
        double curO = Open[0];
        double curR = High[0] - Low[0]; //range
        double curV = Volume[0];
        double uVolume;
        double dVolume;
        if (curC > curO)
        {
        uVolume = (curR / (2 * curR + curO - curC)) * curV;
        }
        else if (curC < curO)
        {
        uVolume = ((curR+curC+curO) / (2 * curR+curC+curO)) * curV;
        }
        else // (curC = curO)
        {
        uVolume = curV / 2;
        }
        dVolume = curV - uVolume;

        upVolume.Set(uVolume);
        downVolume.Set(dVolume);
        }



        #region Properties
        [Browsable(false)]
        [XmlIgnore()]
        public DataSeries UpVolume
        {
        get {return upVolume;}
        }

        [Browsable(false)]
        [XmlIgnore()]
        public DataSeries downVolume
        {
        get {return downVolume;}
        }

        #endregion

        Comment


          #5
          Hello SS213,

          It looks like you are using a lowercase d in the public data series downVolume when you should be using a capital D.

          If you change the following line,

          Code:
          public DataSeries downVolume
          To,

          Code:
          public DataSeries [B]DownVolume[/B]
          Does the indicator compile?

          I look forward to your reply.
          Alan P.NinjaTrader Customer Service

          Comment


            #6
            It was originally set as private, set it to: public DataSeries DownVolume and now compiling... Thank you!

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Waxavi, Today, 02:10 AM
            0 responses
            3 views
            0 likes
            Last Post Waxavi
            by Waxavi
             
            Started by TradeForge, Today, 02:09 AM
            0 responses
            7 views
            0 likes
            Last Post TradeForge  
            Started by Waxavi, Today, 02:00 AM
            0 responses
            2 views
            0 likes
            Last Post Waxavi
            by Waxavi
             
            Started by elirion, Today, 01:36 AM
            0 responses
            4 views
            0 likes
            Last Post elirion
            by elirion
             
            Started by gentlebenthebear, Today, 01:30 AM
            0 responses
            4 views
            0 likes
            Last Post gentlebenthebear  
            Working...
            X