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, 05: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

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      576 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      334 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      553 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      551 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X