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

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 GussJ, 03-04-2020, 03:11 PM
            16 responses
            3,279 views
            0 likes
            Last Post Leafcutter  
            Started by WHICKED, Today, 12:45 PM
            2 responses
            19 views
            0 likes
            Last Post WHICKED
            by WHICKED
             
            Started by Tim-c, Today, 02:10 PM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by Taddypole, Today, 02:47 PM
            0 responses
            5 views
            0 likes
            Last Post Taddypole  
            Started by chbruno, 04-24-2024, 04:10 PM
            4 responses
            51 views
            0 likes
            Last Post chbruno
            by chbruno
             
            Working...
            X