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

How to detect user doesn't have access to data

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

    How to detect user doesn't have access to data

    Hi,

    I use AddDataSeries() to add several other symbols in my code. But if the user doesn't have access to that data (they haven't subscribed) then the whole indicator is just blank. How can I detect that they don't have access to that data, or continue to display the rest of the indicator even without that particular symbol?

    Thanks

    #2
    Hello bubblegum,

    The same way a chart does.

    If the chart doesn't load data then the user doesn't have access to that data.

    Similarly if you do a BarsRequest and the request come up with nothing, the user doesn't have access to the data..
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      If I have 'AddDataSeries()' in my code, and the user doesn't have access to that data, will the indicator always be blank?

      Comment


        #4
        Hello bubblegum,

        If there is data for the primary series, that series may still update OnBarUpdate(). It would depend on how the script is written and if the conditions are written to trigger actions in BarsInProgress 1 or above.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          So what do I need to do to this code to get is to plot something, even when I don't have access to the symbol in AddDataSeries (in this case "CL ##-##") ?

          Code:
                  {
                      if (State == State.SetDefaults)
                      {
                          AddPlot(new Stroke(Brushes.LimeGreen, 3), PlotStyle.Line, "Plot A");
                          AddPlot(new Stroke(Brushes.Red, 3), PlotStyle.Line, "Plot B");
                      }
                      else if (State == State.Configure)
                      {
                          AddDataSeries("CL ##-##", BarsPeriodType.Minute, 3);
                      }
                  }
          
                  protected override void OnBarUpdate()
                  {
                      if ( CurrentBars[0] < 1 || CurrentBars[1] < 1 ) return;
          
                      Values[0][0] = Closes[0][0];
                      Values[1][0] = Closes[1][0];
                  }

          Comment


            #6
            Hello bubblegum,

            The CurrentBars[1] < 1 requires the first added series to have at least 1 bar.

            That would be necessary to reference Closes[1][0].

            If you were to make the condition separate that calls this, you could still allow Values[0] to be set to Closes[0][0] in a separate condition set that only looks for CurrentBars[0] to have at least one bar.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              That's it. So obvious when you point it out. Thank you.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by love2code2trade, 04-17-2024, 01:45 PM
              4 responses
              31 views
              0 likes
              Last Post love2code2trade  
              Started by cls71, Today, 04:45 AM
              2 responses
              10 views
              0 likes
              Last Post eDanny
              by eDanny
               
              Started by proptrade13, Today, 11:06 AM
              0 responses
              4 views
              0 likes
              Last Post proptrade13  
              Started by kulwinder73, Today, 10:31 AM
              1 response
              10 views
              0 likes
              Last Post NinjaTrader_Erick  
              Started by RookieTrader, Today, 09:37 AM
              3 responses
              15 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Working...
              X