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

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
    NinjaTrader is a leading futures broker & trading platform provider with deep discount commissions as low as $.09 per Micro contract. Start your FREE demo powered by live data.

    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.
      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 Pattontje, Yesterday, 02:10 PM
                      2 responses
                      14 views
                      0 likes
                      Last Post Pattontje  
                      Started by flybuzz, 04-21-2024, 04:07 PM
                      17 responses
                      229 views
                      0 likes
                      Last Post TradingLoss  
                      Started by agclub, 04-21-2024, 08:57 PM
                      3 responses
                      17 views
                      0 likes
                      Last Post TradingLoss  
                      Started by TradingLoss, 04-21-2024, 04:32 PM
                      4 responses
                      44 views
                      2 likes
                      Last Post TradingLoss  
                      Started by cre8able, 04-17-2024, 04:16 PM
                      6 responses
                      56 views
                      0 likes
                      Last Post cre8able  
                      Working...
                      X