• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator Multi Instrument Value

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

    Indicator Multi Instrument Value

    Hello!
    I'm Trying to plot Close prices into indicator from diffirent instruments
    Want to plot two lines in indicator.
    I added two Plots and one add data series.
    F.e. CL 11-19 & CL 12-19

    I'm using thic code to Plot them:

    if (CurrentBars[0] <= BarsRequiredToPlot || CurrentBars[1] <= BarsRequiredToPlot)
    return;
    if (BarsInProgress == 0){
    Values[0][0] = Closes[0][0];
    }

    if (BarsInProgress == 1){
    Values[1][0] = Closes[1][0];
    }

    But it only works in real-time data. How can I see it on History? It shows fixed difference for me between that instruments. But if I showing only one of them - it shows me correct prices. The trouble is that when I'm trying to display both of them - it shows me incorrect history data. Thanks.
    Last edited by YevhenShynkarenko; 10-16-2019, 04:18 PM.

    #2
    I found the problem. But need help how to resolve it.
    I updated my code to next:

    protected override void OnBarUpdate()
    {
    if(CurrentBar == 0)
    return;

    if(State == State.Historical)
    {
    current = Close[0];
    next = Closes[1][0];
    Value[0] = current;
    Values[1][0] = next;
    Print(ToTime(Time[0]));
    Print("Value 0: " + " : " + current);
    Print("Value:1-0: " + " : " + next);
    }
    if(State == State.Realtime)
    {
    }


    }

    And then I saw in Output window that it calculates two times on each bar (it prints me time two times). And on first calculation it shows me correct prices, but on second it sets both on "next" double. So then it draws in one single line my both plots. What I need to do to calculate it only once?

    Thanks.

    Comment


      #3
      Hello YevhenShynkarenko, thanks for your note.

      This works for me on historical data:


      Code:
              else if (State == State.Configure)
                  {
                      AddDataSeries("CL 11-19");
                  }
      
              ...
      
              protected override void OnBarUpdate()
              {
                  if(BarsInProgress == 0)
                  {
                      Plot0[0] = Closes[0][0];
                  }
      
                  if(BarsInProgress == 1)
                  {
                      Plot1[0] = Closes[1][0];
                  }
              }
      They print the same data while running on a CL 12-19 chart. I also attached my test script. Could you test the same?

      Attached Files
      Chris L.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by learningnt, Yesterday, 10:21 PM
      0 responses
      3 views
      0 likes
      Last Post learningnt  
      Started by GMiller64, Yesterday, 01:13 PM
      3 responses
      10 views
      0 likes
      Last Post GMiller64  
      Started by itrader46, Yesterday, 12:51 PM
      5 responses
      43 views
      0 likes
      Last Post rithikanth  
      Started by hemlock, Yesterday, 11:45 AM
      3 responses
      15 views
      0 likes
      Last Post NinjaTrader_PatrickG  
      Started by gbulle, Yesterday, 11:31 AM
      4 responses
      12 views
      0 likes
      Last Post gbulle
      by gbulle
       
      Working...
      X