• 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

data from Custom Bar

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

    data from Custom Bar

    Hi

    I am trying to get an integer value from Custom Bar type but have got partial success.
    Perhaps I am making very basic mistake don't know.

    OK. An integer value is being calculated during bar formation in Custom Bar code.
    This value as obvious is different for each bar. I want to access that value from outside in an indicator. Right know I am exposing that value thru Default Value method of bars in indicator, but this is certainly not the right way. Apart from this it only exposes Current Bar's integer Value in Live or replay. I am unable to have that value for each bar on historic chart.

    Can any one suggest a way to do this ?

    #2
    Hello Devdas,

    Thank you for your note.

    Is this value available as on the Class properties? Like calling BarsPeriod

    How are you currently trying to access this value?
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      I have attached figure for this,

      accum_multi is integer value which i am trying to use in indicator, its working as shown in chart but only in live or replay not in historic data.


      Click image for larger version

Name:	2015-03-31 20 56 51.png
Views:	1
Size:	16.8 KB
ID:	873383


      Click image for larger version

Name:	CustomBar1.png
Views:	1
Size:	12.9 KB
ID:	873384

      Comment


        #4
        Hello Devdas,

        Custom BarType programming is not supported and do not have any documentation on the subject.

        I would take the same calculations that you are doing for this item and put them in an Indicator.

        BarTypes are designed to just work the data and create data points for the chart style then to use for drawing.
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Cal View Post
          Hello Devdas,

          Custom BarType programming is not supported and do not have any documentation on the subject.

          I would take the same calculations that you are doing for this item and put them in an Indicator.

          BarTypes are designed to just work the data and create data points for the chart style then to use for drawing.
          I know that these are not supported.

          But for the sake of programming can you suggest me a way to expose that ?

          Not every calculation can be taken out in indicator, especially those which are part of Bar formation logic.

          Comment


            #6
            Devdas,

            Let me see if I can't put something together for here by tomorrow at latest
            Cal H.NinjaTrader Customer Service

            Comment


              #7
              Devdas,

              I did some research and thinking on this.

              I think your best best bet would be to have a Static class for the name space that you can control this counter, update and reset it. This would then be accessible to outside scripts for that count.
              Cal H.NinjaTrader Customer Service

              Comment


                #8
                Thanx cal.
                I am still doing a way that will further help me to do more on that.
                I have as said partial success , but have alternate solution ready also.
                But all episode turned me towards another sofar unseen behavior of ninja charts.
                Let me explain thru a mimic situation when debug result are inconsistence .

                Say I am writing bars number when first bar of chart and when new session bar come.
                But above is done from bar code during bar data formation ,writing to a text file.
                Now when I load a chart with that bartype then result are inconsistent with what
                we normally expect. On some occasions it writes the bar numbers of even those bars and session which are not loaded in datseries dialogue.

                If above is unclear then tell me I will post a mimic code.
                I tried with other bar types also but the same unreliable result comes most of time.

                Comment


                  #9
                  Go ahead and post your code.

                  I'll have to work on a script later this week to get a good answer for you on this.

                  Comment


                    #10
                    I am posting only relevant part which is very simple alone apart from actual problem.

                    See below mimic code, i have tried to export/write the bar count and open price of first bar and subsequent session open bar loaded on chart , but during bar data formation.

                    Code:
                    public class MyBarsType : BarsType
                    	{
                    		............................
                    		private string path = Cbi.Core.UserDataDir.ToString() + "BarData.txt";
                    		private System.IO.StreamWriter sw;
                    		...........................
                    		public override void Add(Bars bars, double open, double high, double low, double close, DateTime time, long volume, bool isRealtime)
                    		{
                    			if (bars.Count == 0 || bars.IsNewSession(time, isRealtime))
                    			{
                    				AddBar(bars, close, close, close, close, time, volume, isRealtime);
                    				
                                                 using (StreamWriter sw = new StreamWriter(path,true))
                                                  {
                                                        sw.WriteLine((bars.Count -1).ToString()+" Open : "+ close.ToString());
                                                   }
                                      // rest of code
                                      }
                    I am posting 3 pics , showing result of above code, which seems not perfectly in sync with code.

                    Pic 1:
                    Loaded 2 days of chart ending 21 April. ( 20 - monday, 21- tuesday , sunday and saturday off ). Line corresponding to 20th April is absent. Line corresponding to 21 April is correct.

                    Click image for larger version

Name:	pic1.png
Views:	1
Size:	46.7 KB
ID:	873468

                    Pic 2:
                    Without cleaning the BarData.txt , now one date is reduced and ending date is 20 April.
                    Result are on second line in BarData.txt, which are not as expected. Though fesh chart and fresh BarData.txt file returned the same result.

                    Click image for larger version

Name:	pic2.png
Views:	1
Size:	47.0 KB
ID:	873469

                    Pic 3:
                    A fresh chart and fresh data file , now most things are ok but first line present which should not.

                    Click image for larger version

Name:	pic3.png
Views:	1
Size:	67.5 KB
ID:	873470

                    Apart from this there are instance when nothing prints in data file even charts are populated well with same days.

                    Please check the catch which i might be missing in this.

                    Comment


                      #11
                      Hi Cal,
                      Got time to test that ?

                      Comment


                        #12
                        Originally posted by devdas View Post
                        Hi Cal,
                        Got time to test that ?
                        I'm away right now for some time off and will be returning this weekend. I haven't forgotten about you but without a computer it does make it difficult.

                        Comment


                          #13
                          Hello Cal,

                          did you tried my problem ?

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by alfonso, Today, 10:21 AM
                          0 responses
                          1 view
                          0 likes
                          Last Post alfonso
                          by alfonso
                           
                          Started by saeed, Today, 10:20 AM
                          2 responses
                          4 views
                          0 likes
                          Last Post NinjaTrader_RyanS  
                          Started by ntbone, Yesterday, 05:21 PM
                          1 response
                          5 views
                          0 likes
                          Last Post NinjaTrader_ChelseaB  
                          Started by ntbone, Yesterday, 04:05 PM
                          1 response
                          5 views
                          0 likes
                          Last Post NinjaTrader_Jesse  
                          Started by tonynt, Today, 09:35 AM
                          1 response
                          13 views
                          0 likes
                          Last Post NinjaTrader_ChrisL  
                          Working...
                          X