• 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

Draw elements are pl

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

    Draw elements are pl

    Hi,

    I wrote a custom indicator that is set to show intrabar (Calc on bar closed=false). The indicator draw on the char intrabar, but the drawn elements are shown on the closed bar before the current intra bar. Attached is the screen and below is the code:

    Code:
            protected override void OnBarUpdate()
            {
    		//...
    
    		if (longValue > 0)
    		     this.DrawTriangleUp(this.High[0].ToString()
    		         +" "+Time[0].TimeOfDay.ToString(), true, 0, Close[0], Color.White);
    		if (shortValue < 0)
    		     this.DrawTriangleDown(this.Low[0].ToString()
    		         +" "+Time[0].TimeOfDay.ToString(), true, 0, Close[0], Color.White);
    		//...
    	}
    I am using Range chart. The green bar which is marked on the screen as 16:14, is actually closed on 16:14:30.

    Same thing happen on a 3 min chart, where the price of 2049 does not exists at the bar it shown (See the 2 images shown the min char)
    Attached Files
    Last edited by Shai Samuel; 12-28-2015, 04:29 PM.

    #2
    Hello Shai Samuel,

    Thanks for your post.

    Your code would print on the currently forming bar when CalculateOnBarClose is set to false.

    Please verify that you do have CalculateOnBarClose set to false in the indicator panel and check your code to ensure it is not set to true elsewhere.

    If you find that CalculateOnBarClose is correctly set then you may want to check your PC clock to ensure it is in sync. Please use the steps below to change/check your Time Zone and sync the PC clock:

    Close NinjaTrader.
    Click on the clock in the lower right corner of your desktop.
    Press 'Change time zone...'.
    Set the Time zone and press 'OK'.
    Click on Internet Time tab.
    Set the server to time.nist.gov and then click Update.
    Your PC clock should now be updated.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thank Paul.

      I got CalculateOnBarClose is set to false in Initialize, and my clock is sync.

      On live data, its draw all in place. The problem is on the historical data when the indicator starts. I let it run for a while and it draws OK, if I refresh it (F5), it redrawn all one bar back, and forward is OK.

      Comment


        #4
        Hello Shai Samuel,

        Thanks for your reply and clarifying what you are doing.

        When you refresh the chart the indicator then reloads and processes all of the data from the beginning and applies the draw objects however when working on the historical data the indicator (all indicators) function as if CalculateOnbarClose = true. This is because historical data does not contain all of the ticks, only the Open, High, Low and Close are available to the indicator when processing historical data. Once the live data appears your indicator would then resume in the CalculateOnBarClose = false mode.
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Hi Paul,

          I found the problems. One issue I had, was that I work with multiple time frames, so Close[0] and Time[0] are not the right approach, and I needed to use Closes[0][0] and Times[0][0]. And to go with that, I needed to use the 3rd form of the DrawTriangleUp, which uses DateTime. Once I fixed it, it all works as expected.

          I have seen the issue in other posts, such #77736, and it might be the same issue.

          Anyway, thank you for your support.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by usero86, Today, 04:28 AM
          0 responses
          7 views
          0 likes
          Last Post usero86
          by usero86
           
          Started by bohenriksen, Today, 04:00 AM
          0 responses
          4 views
          0 likes
          Last Post bohenriksen  
          Started by Derjan, Today, 03:09 AM
          0 responses
          5 views
          0 likes
          Last Post Derjan
          by Derjan
           
          Started by CDXTrader, Today, 12:29 AM
          0 responses
          7 views
          0 likes
          Last Post CDXTrader  
          Started by TopGun13, Yesterday, 10:35 PM
          0 responses
          5 views
          0 likes
          Last Post TopGun13  
          Working...
          X