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

reading data from another chart

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

    reading data from another chart

    I was creating a new indicator and noticed one can receive data from another chart but the question is how do you isolate one data series from another here is the code

    else if (State == State.Configure)
    {
    AddDataSeries("CL 10-17", Data.BarsPeriodType.Minute, 1, Data.MarketDataType.Last);
    }
    }

    protected override void OnBarUpdate()
    {
    Print(Time[0]);
    Print("high cl " + High[0]);
    Print("++++++++++++++++++++");
    }

    the data displayed is this in the output box it is a NQ chart but CL data series added.

    2017-09-01 8:16:00 AM
    high cl 46.74
    ++++++++++++++++++++
    2017-09-01 8:16:00 AM
    high cl 5987.25
    ++++++++++++++++++++
    2017-09-01 8:17:00 AM
    high cl 5984.75
    ++++++++++++++++++++
    2017-09-01 8:17:00 AM
    high cl 46.71
    ++++++++++++++++++++

    the question is

    How can you differentiate the difference between the NQ data and the CL data

    #2
    Hello ballboy11,

    Thanks for your post.

    Each data series added to the script will call the OnBarUpdate(). As your script shows, when CL calls the OnBarUpdate() the references of High[0] point to the CL data, when NQ calls OnBarUpdate() then High[0] points to the NQ data.

    You can use BarsInProgress to isolate or segment your code. The chart bars are always BarsInProgress 0, the first added dataseries is 1, the next 2, etc etc.

    Here is an example of segmenting:

    if (BarsInProgress == 0)
    {
    Print(Time[0]);
    Print("Chart Bars: " + High[0]);
    Print("++++++++++++++++++++");
    }

    if (BarsInProgress == 1)
    {
    Print(Time[0]);
    Print("Added bars: " + High[0]);
    Print("++++++++++++++++++++");
    }

    if you only wanted to work with the chart bars you could use:
    protected override void OnBarUpdate()
    {
    if (BarsInProgress != 0) return; //
    ..
    .
    }

    As you are into a multi instrument script, it will be important for you to review the helpguide as there are many considerations besides BarsInProgress and they are sequentially detailed here: http://ninjatrader.com/support/helpG...nstruments.htm
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thank you Instrument population

      Thanks That is exactly what I was looking for. Last question is there a way to populate
      Instruments in a parameter list the same ones that are on the top of the chart.

      Active instruments that the user commonly uses

      Comment


        #4
        Hello ballboy11,

        Thanks for your reply.

        I'm not quite sure I understand what you are trying to do or looking for. Can you clarify where you want to use a drop down type instrument list?
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          On the top left hand corner there is the instrument list

          Cl 10-17
          NQ 09-17
          ES 09-17
          GC 11-17


          etc

          Can you poplulate the current user list in the indicator parameter as a drop down list

          Comment


            #6
            Hello ballboy11,

            Thanks for your reply.

            I have not been able to find a way to provide access to a recents instrument list from an indicator property and will continue looking and will update this thread if/when I have further information on this.
            Paul H.NinjaTrader Customer Service

            Comment


              #7
              Thank you. (NOTES FOR DRAWING APPLICATIONS)

              A personal note on BarsInProgress.

              I think the OnbarUpdate goes through BarsInProgress 0 THEN BarsInProgress1

              I made a function with If statements with BarsInProgress 0 and 1 and I found out if I want to make my program work I had to make a global variable to store the if( BarsInProgress== 0 For high low close etc.

              I needed bars in progress 1 information but with bars in progress 0 data

              Comment


                #8
                Hello ballboy11,

                Thanks for your reply.

                The order of the BarsInProgress could be different on different chart bars, for example, if the chart bars were of a slower time frame than the added data series.

                You can access different data series from different BarsInProgress. Here is an example that would check the added data series High value is greater than the SMA(10) of the added dataseries during the chart bars update.

                if (BarsInprogress == 0)
                {

                if (Highs[1][0] > SMA(Closes[1], 10)[0]) // check the added dataseries values
                {
                // do something
                }
                }

                Please review in sequence: http://ninjatrader.com/support/helpG...nstruments.htm
                Paul H.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by GussJ, 03-04-2020, 03:11 PM
                11 responses
                3,227 views
                0 likes
                Last Post xiinteractive  
                Started by andrewtrades, Today, 04:57 PM
                1 response
                13 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Started by chbruno, Today, 04:10 PM
                0 responses
                7 views
                0 likes
                Last Post chbruno
                by chbruno
                 
                Started by josh18955, 03-25-2023, 11:16 AM
                6 responses
                440 views
                0 likes
                Last Post Delerium  
                Started by FAQtrader, Today, 03:35 PM
                0 responses
                12 views
                0 likes
                Last Post FAQtrader  
                Working...
                X