Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Barcounter - Dataseries

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

    Barcounter - Dataseries

    Hello,

    I need to compare barnumber to avoid wrong results in plotting.

    BarCounters[0]==BarCounters[1] does not work. How can I get this result so that a calculation and conditions are true only when same barnumber (of course both datseries are same, eg 1 min)

    Or would it work with if(BIP==0) {if(FirstTickOfBar) Barnumber0=Barcounter;} if(BIP==1) {if(FirstTickOfBAr) Barnumber1=Barcounter;}

    ??

    Thank you!
    Tony

    #2
    Hello tonynt,

    From the given sample I cannot tell what type BarCounters[0] is to know if that could be compared. If those are Series<double> type series then you cannot use ==, it will not be equal even if the same value is given.

    Generally if you need to know the bar index you would need to use the CurrentBar variable.

    CurrentBar represents the index of the bar for the series being processed. One possibility may be comparing CurrentBars[0] == CurrentBars[1].

    if you are comparing different instruments with different data you may see that these are never equal. For example comparing two instruments with different sessions, initially the CurrentBars will match but later they will become very different. One series may have more bars than the other.

    We would need more specific details on what you are trying to accomplish surrounding plotting to be of further assistance here.

    Please let me know if I may be of further assistance.

    Comment


      #3
      Hello,

      thank you for your reply. When comparing eg 1 min chart the barnumber/index/bar-that-day should be the same eg with ES and NQ. No?


      Thank you!
      Tony

      Comment


        #4
        Hello tonynt,

        No not in all cases. For those instruments it may line up but for a majority of instruments that have different trading hours that would not make sense. You can do a simple test to see if the instruments being used have the same amount of bars:

        protected override void OnBarUpdate()
        {
        Print(BarsInProgress + " " + CurrentBars[0] + " = " + CurrentBars[1]);
        }

        For those two instruments specifically I see the same indexes, for others like the ES and 6E that would not line up because they have different trading hours.


        Please let me know if I may be of further assistance.

        Comment


          #5
          Hello,

          thank you for your reply. This moment I experienced what you wrote with plotting me the CurrentBars[0] and [1].
          And I could match it when changing dataseries to US equ RTH. Then it is the same number/index of Bar.

          What do I have to add in a script (indicator or strategy) so that the ints I have for CurrentBars[0] and [1] start counting with US equ RTH please?

          Thank you!
          Tony
          Last edited by tonynt; 05-14-2021, 10:34 AM. Reason: translation error

          Comment


            #6
            Hello tonynt,

            I am sorry but I don't understand what you are asking here.

            If the trading hours are different you should see different numbers of bars for each instrument. In general its not expected that all instruments have the same number of bars exactly, they are different instruments.

            Comparing the indexes like this will be unlikely to match unless you have a very specific use case like NQ and ES as the only instruments being used and they have identical sessions and data selected.


            Please let me know if I may be of further assistance.

            Comment


              #7
              Hello,

              I thought to resolve it with
              if(ToTime(Time[0])>=093000 && ToTime(Time[0])<161500)
              {if(CurrentBars[0]==CurrentBars[1] && other conditions)
              then do....

              this worked for half an hour maybe and now CurrentBars[0] does not match with CurrentBars[1] (both are 1 min)
              but now they plot different values/ints.

              How can I please have counting the number of bar eg ES and NQ please, starting with 9:30 EST?

              Thank you for your support!

              Tony
              Last edited by tonynt; 05-14-2021, 11:29 AM. Reason: add info

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              648 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              369 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              108 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              572 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              574 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X