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


Accessing an Exposed Series from another Indicator

  • Filter
  • Time
  • Show
Clear All
new posts

    Accessing an Exposed Series from another Indicator

    Hello - I am having on issue with the proper syntax to get a value stored from an Exposed Series. Indicator #1 has the following

    private Series<double> myP1TSeries;

    in State.DataLoaded:
    myP1TSeries = new Series<double>(this);

    In OnBarUpdate:
    myP1TSeries[0] = High[0] - High[1];

    public Series<double> MyP1TSeries
    get { return myP1TSeries; }

    I know the data is stored in this Series in Indicator #1 as I can print out any of the index values.

    When I try and code to get the [0] value from MyP1TSeries into Indicator #2 I am getting compile errors. From previous searches through the forum in appears I should be using:
    StepValue [0] = myPSV1TSeries.MyP1TSeries ;

    but I am getting a CS1061 error.

    Would someone be able to help me with the correct syntax please??
    Thank you.

    Hello Blaine987,

    Welcome to the NinjaTrader forums!

    If you are getting an error, be sure to provide the full error message.

    Your exposed series appears to be correct.

    Calling this from the host script would appear as:

    Chelsea B.NinjaTrader Customer Service


      Thank you Chelsea. While the code does compile I am still having an issue getting the data to be pulled into an indicator correctly. Let me explain what I am trying to do.

      I have an indicator on the 100, 300, 900, 2700 Tick charts. This indicator calculates a value which is stored in both a Series and as an exposed variable. On the local charts, 100-2700, the data is being stored correctly. Once I have these calculated value I would like to Plot the values from the 300 and 900 added together on the 100 chart in a new indicator window. I also want to plot on the 300 the values from the 900 and 2700, and on the 900 the values from the 2700 and 8100 etc.
      I written this new indicator to call the Series from the 300 and 900. In testing I print out these values. What seems to be happening is the code runs but when I print out the values it displays only the calculated value from the 100 chart. The values should be for example 100= 2.5 300 = 4.2 900= -1.2 but the printout shows all three values 2.5. Code snippet

      GetThe3TVariable = PSV3TCodeTesting().StepValue3T[0]; Have a line similar for the 900Tick chart.

      I do have this work another way but I was worried about the repeating data series.
      in the working version on the 100 Tick chart I am adding
      AddDataSeries(BarsPeriodType.Tick,300); //series [2]
      AddDataSeries(BarsPeriodType.Tick,900); //series [2]
      From the these I can get the correct calculations and plot them correctly.

      But my concern was that on the 300 chart I also had the 900 series. Why would I need to have this 900 series on 3 charts, the 900 chart itself and the 100 and 300. Why not just grab the calculated value from the 900?

      Is my concern about the overhead from all of these repeated series valid?
      If the 100 Tick chart has 6 days of data, 300 has 18 days, 900 has 30 days, when I add the 900 tick data series to the 100 it will have only 6 days of data while adding the 900 series to the 300 tick chart would have 18 days.
      Are these 2 900 tick data series treated as separate entities?
      Before going much further is my first question about the overhead something to be concern with?

      Thank you.


        Hello Blaine987,

        Note, that an indicator is not able to see other charts or other data series added to the same chart. It see's only its input series.
        If there is historical data cached from another chart that was opened, the indicator will read from cache and likely have to download less historical data.
        In real-time, all charts and indicators (and strategies and bar types etc) are subscriber threads fed from the instrument thread of the instrument they are running on. A separate chart on the same instrument would be a separate subscriber thread that is also fed from the instrument thread that pushes data out to all the subscribers.

        So when you talk about overhead, opening separate charts would be overhead as the indicator would still need to add all of its own series and would be its own subscriber thread.

        All that said, this does not appear related to your initial inquiry.

        You have a public series you are setting a value to and you are calling this value from host script and the hosted indicator is not returning the value that was set from the hosted indicator?

        How are you involving AddDataSeries() to add instrument series?
        Do you have multiple public custom series that are being assigned values from different barsarray values?

        I would start by simplifying what you are trying to do.

        I think I'm understanding you want to be able to place the indicator on charts with different indicators and bar types. This means the code within the indicator would not be performed on primary series BarsInProgress 0, but would be performed on the added series. So you may need a series synchronized to the BarsArray of the added series.

        private Series<double> myCustomSeries;
        public Series<double> MyCustomSeries
        { get { Update(); return myCustomSeries; } }
        in State.Configure:
        AddDataSeries(BarsPeriodType.Tick, 100);
        in State.DataLoaded
        MyCustomSeries = new Series<double>(BarsArray[1], MaximumBarsLookback.Infinite);
        in OnBarUpdate:
        if (BarsInProgress == 1)
        myCustomSeries[0] = Highs[1][0] - Lows[1][0];
        Make a new script that adds just one instrument series and one public custom series, set the value, and call this from a host script.

        Post the simple test script so that we may test and assist.
        Chelsea B.NinjaTrader Customer Service


          Thank you for explaining how the subscriber feed works. I feel I have a better understanding now.
          I DO have the data series working as expected for what I am trying to accomplish.
          Thank you again and I do not have any more questions currently.


          Latest Posts


          Topics Statistics Last Post
          Started by 309338, Today, 12:06 PM
          0 responses
          Last Post 309338
          by 309338
          Started by AaronKoRn, Yesterday, 08:38 PM
          2 responses
          Last Post NinjaTrader_ChrisL  
          Started by rocketstock, 08-05-2022, 09:36 PM
          2 responses
          Last Post NinjaTrader_ChrisL  
          Started by ronyggg83, Yesterday, 03:48 PM
          4 responses
          Last Post NinjaTrader_ChelseaB  
          Started by preqc, 08-05-2022, 09:10 AM
          1 response
          Last Post NinjaTrader_Jim