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

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, 05: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 algospoke, Yesterday, 06:40 PM
          2 responses
          19 views
          0 likes
          Last Post algospoke  
          Started by ghoul, Today, 06:02 PM
          3 responses
          14 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by jeronymite, 04-12-2024, 04:26 PM
          3 responses
          44 views
          0 likes
          Last Post jeronymite  
          Started by Barry Milan, Yesterday, 10:35 PM
          7 responses
          20 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by AttiM, 02-14-2024, 05:20 PM
          10 responses
          180 views
          0 likes
          Last Post jeronymite  
          Working...
          X