• 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

Index data

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

    Index data

    Hello,

    I have a chart for example of mini sp 500 and I would like to put in an indicator that in the current bar, I will use the data of that bar in the VIX and in the ATR of that VIX.
    Can you help me.
    I'm supposed to have both minisp and vix data

    Thank you

    #2
    https://ninjatrader.com/blog/emini-e...g-ninjatrader/

    Comment


      #3
      Hi anmir55, thanks for your note.

      NinjaScripts can have multiple series applied to them so you can have your primary series (the series on your chart), and others added with AddDataSeries:

      https://ninjatrader.com/support/help...dataseries.htm

      Multi time frame and Multi instrument scripts are a big part of NinjaScript, we have a guide on creating these types of scripts here:

      https://ninjatrader.com/support/help...nstruments.htm

      Please let me know if I can assist any further.
      Chris L.NinjaTrader Customer Service

      Comment


        #4
        Thank you Chris for your help

        Comment


          #5
          I want to have all the data but I have an error..

          "AddDataSeries(string instrumentName, BarsPeriod barsPeriod, string tradingHoursName)"

          else if (State == State.Configure)
          {

          AddDataSeries("^VIX",BarsPeriodType.Minute,"Defaul t 24 x 7");

          }

          I try this:
          AddDataSeries("^VIX", new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = 1440 }, "Default 24x7");
          But now it doesn't collect data ...

          If I only put this: AddDataSeries("^VIX");
          It works but only gives data in RTH
          Last edited by anmir55; 01-12-2020, 03:17 PM.

          Comment


            #6
            Hi anmir55, thanks for your reply.

            When you call this:
            AddDataSeries("^VIX",BarsPeriodType.Minute,"Defaul t 24 x 7");

            Do you get any errors in the log tab of your Control Center? It looks like there is a space in "Defaul t"
            Chris L.NinjaTrader Customer Service

            Comment


              #7
              Hello ammir55,

              Specifying only the Instrument name will attach a new instrument following the data series parameters of the primary data series.

              Calling the following will add a new instrument following a Trading Hours template

              AddDataSeries("^VIX", new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = 1440 }, "Default 24 x 7");

              Please ensure that the Trading Hours template name matches the template you want to use verbatim. You can check BarsArray[0].TradingHours to see the name of a Trading Hours template applied to the primary data series to confirm a string that should be entered.

              We look forward to being of further assistance.
              JimNinjaTrader Customer Service

              Comment


                #8
                Hello,
                As I said in the previous post that instruction does not return any data ....
                AddDataSeries("^VIX", new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = 1440 }, "Default 24 x 7");

                The errors with this instruction are the following:
                AddDataSeries("^VIX",BarsPeriodType.Minute,"Defaul t 24 x 7");
                errors:
                The best overloaded method match for 'NinjaTrader.NinjaScript.NinjaScriptBase.AddDataSe ries (string, NinjaTrader.Data.BarsPeriodType, int)' has some invalid arguments
                Argument 3: cannot be converted from 'string' to 'int'

                Comment


                  #9
                  Hello
                  I have another question, with the instruction AddDataSeries ... once I have the indicator in another chart as the mini sp, the Vix data is not updated .... I put a print inside the onbarupdate and those are not updated data....
                  this is the indicator


                  //This namespace holds Indicators in this folder and is required. Do not change it.
                  namespace NinjaTrader.NinjaScript.Indicators
                  {
                  public class Prove : Indicator
                  {
                  #region Variables

                  int a=0;
                  bool cross = false;

                  #endregion

                  protected override void OnStateChange()
                  {
                  if (State == State.SetDefaults)
                  {
                  Description = @"Enter the description for your new custom Indicator here.";
                  Name = "Prova";
                  Calculate = Calculate.OnEachTick;
                  IsOverlay = false;
                  DisplayInDataBox = true;
                  DrawOnPricePanel = true;
                  DrawHorizontalGridLines = true;
                  DrawVerticalGridLines = true;
                  PaintPriceMarkers = true;
                  ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
                  //Disable this property if your indicator requires custom values that cumulate with each new market data event.
                  //See Help Guide for additional information.
                  IsSuspendedWhileInactive = true;
                  }
                  else if (State == State.Configure)
                  {

                  AddDataSeries("^VIX");

                  }
                  }

                  protected override void OnBarUpdate()
                  {
                  cross = false;


                  if (CurrentBars[0] < 20 || CurrentBars[1] < 20 )

                  {return;}



                  // Ignore bar update events for the supplementary - Bars object added above
                  if (BarsInProgress == 1 )
                  {return;}


                  Print(string.Format("Time: {0} | Viplus= {1} | Viminus= {2} | cross= {3}",Time[1] , Vortex(BarsArray[1], 14).VIPlus[1], Vortex(BarsArray[1], 14).VIMinus[1],cross));


                  if(IsFirstTickOfBar && Vortex(BarsArray[1], 14).VIPlus[2] < Vortex(BarsArray[1], 14).VIMinus[2] && Vortex(BarsArray[1], 14).VIPlus[1] > Vortex(BarsArray[1], 14).VIMinus[1]) cross = true;

                  else if (IsFirstTickOfBar && Vortex(BarsArray[1], 14).VIPlus[2] > Vortex(BarsArray[1], 14).VIMinus[2] && Vortex(BarsArray[1], 14).VIPlus[1] < Vortex(BarsArray[1], 14).VIMinus[1]) cross = true;




                  if(cross && Closes[1][1] > Opens[1][1])
                  {

                  Draw.ArrowLine(this, "tag1", 1, High[1]+2, 1, High[1]+0.75, Brushes.Red, DashStyleHelper.Solid, 7);

                  }

                  Comment


                    #10
                    Hi anmir55, thanks for your reply.

                    I was able to pull VIX data with this simple test script:

                    Code:
                    public class TestVIX : Indicator
                        {  
                            protected override void OnStateChange()
                            {
                                if (State == State.SetDefaults)
                                {
                                    ...
                                }
                                else if (State == State.Configure)
                                {
                                    AddDataSeries("^VIX");
                                }
                            }
                    
                            protected override void OnBarUpdate()
                            {
                                if(BarsInProgress == 1)
                                {
                                    Print(Close[0] + " " + Instrument.FullName);
                                }
                            }
                        }
                    Are you getting print outs of the VIX when you run a script like this?
                    Last edited by NinjaTrader_ChrisL; 01-14-2020, 10:33 AM. Reason: spelling
                    Chris L.NinjaTrader Customer Service

                    Comment


                      #11
                      Hello,

                      Perfect, I'm going to try it
                      thanks for your help

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by maltese, Today, 02:54 AM
                      0 responses
                      1 view
                      0 likes
                      Last Post maltese
                      by maltese
                       
                      Started by morrnel, Yesterday, 04:18 PM
                      1 response
                      7 views
                      0 likes
                      Last Post NinjaTrader_Marco  
                      Started by jmahon, Today, 02:45 AM
                      0 responses
                      3 views
                      0 likes
                      Last Post jmahon
                      by jmahon
                       
                      Started by brianshih, Today, 02:40 AM
                      0 responses
                      2 views
                      0 likes
                      Last Post brianshih  
                      Started by franco12364, Yesterday, 02:29 PM
                      1 response
                      11 views
                      0 likes
                      Last Post NinjaTrader_Marco  
                      Working...
                      X