• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Advance Decline ^ADD symbol

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

    Advance Decline ^ADD symbol

    Trying to do what appears to be simple but I cannot seem to get this to work, I never get a BarsInProgress value of 1. The attached image shows I am receiving the ^ADD values I need, but I cannot parse the values. Any help would be appreciated, code here:

    protected override void Initialize()
    {
    Add("^ADD", PeriodType.Minute, 1);
    }

    protected override void OnBarUpdate()
    {
    //BarsInProgress never equals 1
    if ( BarsInProgress == 1 ) {
    Print(Close[0]);
    }
    }
    Attached Files

    #2
    Hello mbull,

    Thank you for your post.

    Please use Closes[1][0] to call the secondary bar series close:
    Code:
    if ( BarsInProgress == 1 ) {
    Print(Closes[1][0]);
    }
    For information on running multiple series in your code please visit the following link: http://www.ninjatrader.com/support/h...nstruments.htm
    Patrick H.NinjaTrader Customer Service

    Comment


      #3
      Thank you, I will not make that mistake again. But note, if I use MSFT (or whatever), everything works, but if I use the ^ADD index, which I have bid/ask values for, it seems like it does not get added to the BarsArray and I cannot read it's values (shown in the original attachment).
      So this works:
      protected override void Initialize()
      {
      Add("MSFT", PeriodType.Minute, 1);
      }
      protected override void OnBarUpdate()
      {
      if ( BarsInProgress == 1 ) {
      Print(Closes[1][0]);
      }
      }

      This does not:
      protected override void Initialize()
      {
      Add("^ADD", PeriodType.Minute, 1);
      }
      protected override void OnBarUpdate()
      {
      if ( BarsInProgress == 1 ) {
      Print(Closes[1][0]);
      }
      }

      Comment


        #4
        Hello mbull,

        Thank you for your response.

        Can you provide the full script that does not work for the ^ADD?
        Patrick H.NinjaTrader Customer Service

        Comment


          #5
          There is no real R&D on this indicator yet, but here is what we have, again if you replace ^ADD with MSFT, you can print the Close value (ideally I can get the GetCurrentBid and GetCurrentAsk) to the putput window. ^ADD gives me nothing.

          #region Using declarations
          using System;
          using System.ComponentModel;
          using System.Diagnostics;
          using System.Drawing;
          using System.Drawing.Drawing2D;
          using System.Xml.Serialization;
          using NinjaTrader.Cbi;
          using NinjaTrader.Data;
          using NinjaTrader.Gui.Chart;
          using System.IO;
          using System.Globalization;
          using System.Collections.Generic;
          #endregion

          // This namespace holds all indicators and is required. Do not change it.
          namespace NinjaTrader.Indicator
          {
          /// <summary>
          /// Enter the description of your new custom indicator here
          /// </summary>
          [Description("Enter the description of your new custom indicator here")]
          public class mbAD2 : 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("^ADD", PeriodType.Minute, 1);
          }

          protected override void OnBarUpdate()
          {
          //BarsInProgress never equals 1

          if ( BarsInProgress == 1 ) {
          Print(Closes[1][0]);
          }
          }

          #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 Plot0
          {
          get { return Values[0]; }
          }

          #endregion
          }
          }

          #region NinjaScript generated code. Neither change nor remove.
          // This namespace holds all indicators and is required. Do not change it.
          namespace NinjaTrader.Indicator
          {
          public partial class Indicator : IndicatorBase
          {
          private mbAD2[] cachembAD2 = null;

          private static mbAD2 checkmbAD2 = new mbAD2();

          /// <summary>
          /// Enter the description of your new custom indicator here
          /// </summary>
          /// <returns></returns>
          public mbAD2 mbAD2()
          {
          return mbAD2(Input);
          }

          /// <summary>
          /// Enter the description of your new custom indicator here
          /// </summary>
          /// <returns></returns>
          public mbAD2 mbAD2(Data.IDataSeries input)
          {
          if (cachembAD2 != null)
          for (int idx = 0; idx < cachembAD2.Length; idx++)
          if (cachembAD2[idx].EqualsInput(input))
          return cachembAD2[idx];

          lock (checkmbAD2)
          {
          if (cachembAD2 != null)
          for (int idx = 0; idx < cachembAD2.Length; idx++)
          if (cachembAD2[idx].EqualsInput(input))
          return cachembAD2[idx];

          mbAD2 indicator = new mbAD2();
          indicator.BarsRequired = BarsRequired;
          indicator.CalculateOnBarClose = CalculateOnBarClose;
          #if NT7
          indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
          indicator.MaximumBarsLookBack = MaximumBarsLookBack;
          #endif
          indicator.Input = input;
          Indicators.Add(indicator);
          indicator.SetUp();

          mbAD2[] tmp = new mbAD2[cachembAD2 == null ? 1 : cachembAD2.Length + 1];
          if (cachembAD2 != null)
          cachembAD2.CopyTo(tmp, 0);
          tmp[tmp.Length - 1] = indicator;
          cachembAD2 = tmp;
          return indicator;
          }
          }
          }
          }

          // This namespace holds all market analyzer column definitions and is required. Do not change it.
          namespace NinjaTrader.MarketAnalyzer
          {
          public partial class Column : ColumnBase
          {
          /// <summary>
          /// Enter the description of your new custom indicator here
          /// </summary>
          /// <returns></returns>
          [Gui.Design.WizardCondition("Indicator")]
          public Indicator.mbAD2 mbAD2()
          {
          return _indicator.mbAD2(Input);
          }

          /// <summary>
          /// Enter the description of your new custom indicator here
          /// </summary>
          /// <returns></returns>
          public Indicator.mbAD2 mbAD2(Data.IDataSeries input)
          {
          return _indicator.mbAD2(input);
          }
          }
          }

          // This namespace holds all strategies and is required. Do not change it.
          namespace NinjaTrader.Strategy
          {
          public partial class Strategy : StrategyBase
          {
          /// <summary>
          /// Enter the description of your new custom indicator here
          /// </summary>
          /// <returns></returns>
          [Gui.Design.WizardCondition("Indicator")]
          public Indicator.mbAD2 mbAD2()
          {
          return _indicator.mbAD2(Input);
          }

          /// <summary>
          /// Enter the description of your new custom indicator here
          /// </summary>
          /// <returns></returns>
          public Indicator.mbAD2 mbAD2(Data.IDataSeries input)
          {
          if (InInitialize && input == null)
          throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method");

          return _indicator.mbAD2(input);
          }
          }
          }
          #endregion

          Comment


            #6
            Hello mbull,

            Thank you for your response.

            Who do you connect to for data? Are there any error messages in the Log tab of the NinjaTrader Control Center when testing this indicator on the chart?
            Patrick H.NinjaTrader Customer Service

            Comment


              #7
              I use interactive brokers, no issues with them so far. As for the Log, I do not see anything out of the ordinary when loading the indicator. When I start the program from scratch I see "Error validating request:-'rd' : cause - The symbol or the local-symbol or the security is must be entered ServerValidateError". But I am still getting the bid ask quotes on ^ADD as shown in the original attachment.

              Comment


                #8
                Hello mbull,

                Thank you for your response.

                Please open a new chart (File > New > Chart) of the ^ADD, and take a screenshot of the chart and attach it to your response.
                Patrick H.NinjaTrader Customer Service

                Comment


                  #9
                  Seems it will not populate the chart, the ^ADD index is unique in that the AskPrice/BidPrice/LastPrice are the way this symbol contains the Advancing/Declining/Difference (respectively). I am not trying to chart ^ADD, I am just trying to get these values (AskPrice/BidPrice/LastPrice) for use in my script for calculations. I hope I am making sense.

                  Comment


                    #10
                    Hello mbull,

                    Thank you for your response.

                    If there is no historical data it will not be called historically, but going forward in real-time (starting from the time going forward that you enabled the strategy) is the BarsInProgress == 1 called?
                    Patrick H.NinjaTrader Customer Service

                    Comment


                      #11
                      I see where you are going, I can leave the indicator running for a while, a few OnBarUpdates() are made, but the BarsInProgress never equals 1, it remains at 0, here's a little adjustment I made to see the output:

                      protected override void Initialize()
                      {
                      Add("^ADD", PeriodType.Minute, 1);
                      }

                      protected override void OnBarUpdate()
                      {
                      //BarsInProgress never equals 1
                      Print("Bars In Progress: " + BarsInProgress + " Counter:" + iCounter++);
                      if ( BarsInProgress == 1 ) {
                      Print(Closes[1][0]);
                      }
                      }

                      Comment


                        #12
                        Hello mbull,

                        Thank you for your response.

                        Please send me your log and trace files so that I may look into what occurred. You can do this by going to the Control Center-> Help-> Mail to Support. Please place 'ATTN: Patrick - 1069392' in the subject line and a reference to this thread in the body of the email: http://www.ninjatrader.com/support/f...ad.php?t=65881
                        Patrick H.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by rainbow47, Today, 06:10 AM
                        0 responses
                        5 views
                        0 likes
                        Last Post rainbow47  
                        Started by stenberg98, Today, 04:53 AM
                        2 responses
                        7 views
                        0 likes
                        Last Post NinjaTrader_Marco  
                        Started by wukefuha, Today, 03:20 AM
                        1 response
                        7 views
                        0 likes
                        Last Post NinjaTrader_Marco  
                        Started by mbcmbc, Yesterday, 10:12 PM
                        1 response
                        10 views
                        0 likes
                        Last Post NinjaTrader_ChrisSch  
                        Started by fx.practic, Today, 03:44 AM
                        1 response
                        15 views
                        0 likes
                        Last Post NinjaTrader_Marco  
                        Working...
                        X