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
    Explore futures trading platforms designed for traders of all levels at NinjaTrader. Learn how to open a brokerage account and take the next step.

    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:



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



      Please let me know if I can assist any further.

      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"

            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.

              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

                    Comment


                      #11
                      Hello,

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

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                      0 responses
                      648 views
                      0 likes
                      Last Post Geovanny Suaza  
                      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                      0 responses
                      369 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by Mindset, 02-09-2026, 11:44 AM
                      0 responses
                      108 views
                      0 likes
                      Last Post Mindset
                      by Mindset
                       
                      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                      0 responses
                      572 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by RFrosty, 01-28-2026, 06:49 PM
                      0 responses
                      573 views
                      1 like
                      Last Post RFrosty
                      by RFrosty
                       
                      Working...
                      X