Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

BarsArray[0].GetTime(0) Different from Date of First Bar Painted on Chart

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

    BarsArray[0].GetTime(0) Different from Date of First Bar Painted on Chart

    Hi guys, I'm coding a custom chart using the overidden plot function and I'm using BarsArray[0] to calculate my indicators and plot them.

    I loaded a EURUSD daily data series, Days to Load = 14, End Date = 5/9/2012 in a Default 24/7 Template.

    The EURUSD chart painted 10 candles on the daily chart, the days plotted are 26 APR,27 APR,28 APR,1 MAY,2 MAY,3 MAY,4 MAY,5 MAY,8 MAY,9 MAY as shown below.



    In the overidden plot function, my code read the very first value from BarsArray[0].GetTime(0) (when i=0) i.e. the very first date loaded, and the date shows 25 Apr 12. However, if you recall, my chart shows the first candle as 26 Apr 12 (seen from the NT data box above) . My code is as follows:



    The codes above can be read in the below context :
    Code:
    public override void Plot(Graphics graphics, Rectangle bounds, double min, double max)
            {
            
                
                int LastBar        = Math.Min(ChartControl.LastBarPainted, Bars.Count - 1);
                int BarsPainted = Bars.Count - ChartControl.FirstBarPainted; 
                int FirstBar    = Math.Max(0, (LastBar - BarsPainted) + 1);
                
                int intFirstBarOnChart = ChartControl.FirstBarPainted;
                int intLastBarOnChart = ChartControl.LastBarPainted;
                int intBarsOnChart = intLastBarOnChart - intFirstBarOnChart;
                int iFontHt=0;
                
                
                List <int> XCoordOfSessions = new List<int>();
                List <int> YCoordOfSessions = new List<int>();
                List <string> ProfileAlphabetList = new List<string>();
                
                DateTime FirstDay = new DateTime();
                double FirstOpen=0;
                
                
                try
                {            
                    
                    //Print(BarsArray[0].GetOpen(1));
                    
                    for (int i =0;i<=LastBar+10;i++)
                    {
                        int watch = (i+1)%numberOfInputPeriodsPerProfile;
    
                        #region Main loop            
    
                        //Add bar to custom bar list
                        if (i==0) BarList.Clear();
                        MyBar mb = new MyBar(BarsArray[0].GetOpen(i),BarsArray[0].GetHigh(i),BarsArray[0].GetLow(i),BarsArray[0].GetClose(i),BarsArray[0].GetTime(i));
                        this.BarList.Add(mb);    
                        
                        
                        FirstOpen=BarsArray[0].GetOpen(i);
                        FirstDay = BarsArray[0].GetTime(i);
                        int TotalBars = BarsArray[0].Count;
    Pl can someone clarify why the first bar painted on my chart does not have the same date as the first bar in my BarsArray? Am I missing something here?

    Any help would be appreciated.

    Thanks.

    #2
    Hello glitzprince,
    Welcome to the forum and I am happy to assist you.

    To assist you further can you tell me have you set CalculateOnBarClose (COBC) to true or false?

    Are you able to get the right value if you set COBC to false?

    I look forward to assisting you further.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Hi Joydeep. I tried setting COBC to false but it didn't work. This is driving me nuts! =( I'm so close to completing the indicator.

      Comment


        #4
        Hello,
        Please refer to this thread and see if it can offer you any solutions.


        If you are still unable to resolve it please send a sample code to support[AT]ninjatrader[DOT]com so that I can look into it.

        Please append Attn:Joydeep in the subject of the email and give a reference of this thread in the body of the email.

        Please let me know if I can assist you any further.
        JoydeepNinjaTrader Customer Service

        Comment


          #5
          Been looking at it for a couple of days now. I've sent you an email with the sample code. Thanks in advanced.

          Comment


            #6
            Hello,
            This is to confirm I have got your code and will be contacting you via email.

            I look forward to assisting you further.
            JoydeepNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            647 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            368 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
            571 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            573 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X