• 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

Can't Get DrawRectangle To Update OnBarUpdate()

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

    Can't Get DrawRectangle To Update OnBarUpdate()

    My indicator draws two rectangles on an intraday chart to represent the previous weekly candle and current weekly candle that is developing. Trouble is, the rectangle that represents the developing weekly candle does not update with the current price--I have to refresh the indicator before it updates. What simple solution am I missing? Thanks in advance.

    Code:
      
    
    	protected override void OnBarUpdate()
    	{	
    			
    				
    	if(BarsInProgress == 1 && FirstTickOfBar)
    	{
    	
    	if (CurrentBar < 3) return;
    	
    			if ((Open[1]) >= (Close[1]))//BEARISH BAR PREVIOUS
    			{
    				DrawRectangle("Body", false, Math.Min(CurrentBar, -15), Open[1], Math.Min(CurrentBar, -25), Close[1], Color.Red, Color.Transparent, 1);
    		
    				DrawLine("High", Math.Min(CurrentBar, -20), High[1], Math.Min(CurrentBar, -20), Open[1], Color.Pink);
    				DrawLine("Low", Math.Min(CurrentBar, -20), Low[1], Math.Min(CurrentBar, -20), Close[1], Color.Pink);
    			
    				DrawLine("halfwaybear", false, Math.Min(CurrentBar,-16), ((Close[1] + Open[1])/2), Math.Min(CurrentBar, -24), ((Close[1] + Open[1])/2), Color.Blue, DashStyle.Solid, 1);
    		
    				RemoveDrawObject("halfwaybull");
    										
    			}
    			else if ((Open[1]) <= (Close[1]))//Bullish PREVIOUS
    			{
    				DrawRectangle("Body", false, Math.Min(CurrentBar, -15), Open[1], Math.Min(CurrentBar, -25), Close[1], Color.Green, Color.Transparent, 1);
    			
    				DrawLine("High", Math.Min(CurrentBar, -20), High[1], Math.Min(CurrentBar, -20), Close[1], Color.Pink);		
    				DrawLine("Low", Math.Min(CurrentBar, -20), Low[1], Math.Min(CurrentBar, -20), Open[1], Color.Pink);
    			
    				
    				DrawLine("halfwaybull", false, Math.Min(CurrentBar,-16), ((Close[1] + Open[1])/2), Math.Min(CurrentBar, -24), ((Close[1] + Open[1])/2), Color.Blue, DashStyle.Solid, 1);
    		
    					
    				RemoveDrawObject("halfwaybear");
    					
    			}
    		
    				
    	}//if(BarsInProgress == 1 && FirstTickOfBar)
    		
    	
    	
    	if(BarsInProgress == 1 )
    		{	
    			
    			if ((Open[0]) >= (Close[0]))//BEARISH BAR CURRENT
    			{
    				DrawRectangle("Body0", false, Math.Min(CurrentBar, -26), Open[0], Math.Min(CurrentBar, -36), Close[0], Color.Red, Color.Transparent, 1);
    			
    				DrawLine("High0", Math.Min(CurrentBar, -31), High[0], Math.Min(CurrentBar, -31), Open[0], Color.Pink);
    									
    				DrawLine("Low0", Math.Min(CurrentBar, -31), Low[0], Math.Min(CurrentBar, -31), Close[0], Color.Pink);
    					
    			}
    			else if ((Open[0]) <= (Close[0]))//BULLISH BAR CURRENT
    			{
    				DrawRectangle("Body0", false, Math.Min(CurrentBar, -26), Open[0], Math.Min(CurrentBar, -36), Close[0], Color.Green, Color.Transparent, 1);
    			
    				DrawLine("High0", Math.Min(CurrentBar, -31), High[0], Math.Min(CurrentBar, -31), Close[0], Color.Pink);		
    			
    				DrawLine("Low0", Math.Min(CurrentBar, -31), Low[0], Math.Min(CurrentBar, -31), Open[0], Color.Pink);
    			
    				
    			
    					
    				    }
    	} //	if(BarsInProgress == 1 )
    				
    	
    					
    				
    	}//on bar update

    #2
    Hello shipolito,

    Thank you for reaching out to us. I see you are using an additional data series for these calculations. To clarify, could you please provide the code you are creating the additional data series with? It will be in the Initialize() method of your indicator and should look similar to:
    Add(PeriodType.Minute, 5);
    or
    Add("ES 12-06", PeriodType.Tick, 100);

    Thank you.
    Michael M.NinjaTrader Quality Assurance

    Comment


      #3
      Here you go:

      Code:
      protected override void Initialize()
      			{
      				CalculateOnBarClose	= false;
      				Overlay				= true;
      				PriceTypeSupported	= false;
      				Add(PeriodType.Week, 1);
      		
      			
      			}

      Comment


        #4
        Hello shipolito,

        Thank you for your response.

        Can you provide the full indicator file attached to your response?
        Patrick H.NinjaTrader Customer Service

        Comment


          #5
          Patrick,

          Thanks for your time--attached is the indicator. I hope you can replicate the issue on your side.
          Attached Files

          Comment


            #6
            Nevermind--solved. I abandoned use of BarsInProgress for the rectangle that represents the developing weekly bar and used Closes[1][0] etc., instead.

            Thank you for your time

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by TonyParisi, Today, 07:38 AM
            1 response
            4 views
            0 likes
            Last Post NinjaTrader_Kate  
            Started by tgn55, 09-24-2019, 06:34 AM
            11 responses
            44 views
            0 likes
            Last Post koganam
            by koganam
             
            Started by jasphere, Today, 07:37 AM
            3 responses
            19 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by w0lverine, Today, 07:06 AM
            1 response
            7 views
            0 likes
            Last Post NinjaTrader_PaulH  
            Started by aslane, Today, 07:17 AM
            3 responses
            8 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Working...
            X