Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnRender error...

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

    OnRender error...

    In my *indicator* I'm getting this error:

    Code:
    Indicator 'MyIndicator': Error on calling 'OnRender' method on bar -1: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
    I simply am trying to draw a rectangle at the current bar. Here's my code:

    Code:
    private Stroke stroke;
    
    ----
    else if (State == State.Configure)
    			{
    				stroke = new Stroke(Brushes.Black, 2f);
    			}
    protected override void OnBarUpdate()
    		{
    			if (State == State.Historical)
    				return;
    			
    		}	
    		
    		protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
    		{
    			if (Bars == null)
    				return;
    			
    			RectangleF rect = new RectangleF();
    				
    			try
    			{
    				rect.X = chartControl.GetXByBarIndex(ChartBars, 0);
    				rect.Y = chartScale.GetYByValue(Close[0]);
    				rect.Width = 100;
    				rect.Height = 100;
    				RenderTarget.DrawRectangle(rect, stroke.BrushDX);
    			}
    			catch (Exception e)
    			{
    				Print (e.Message);
    			}
    		}

    #2
    Hello funk101,

    Thank you for your post.

    Please try chartScale.GetYByValue(Close.GetValueAt(CurrentBar-1)) and advise if the message continues.

    If the message continues can you send us your log and trace files by going to Help > Email Support. Please list 'ATTN: Patrick H - 1505270' in the subject line.

    Comment


      #3
      Originally posted by funk101 View Post
      In my *indicator* I'm getting this error:
      Try..

      Code:
      RenderTarget.DrawRectangle(rect, stroke.Brush.ToDxBrush(RenderTarget);
      -=Edge=-
      NinjaTrader Ecosystem Vendor - High Tech Trading Analysis

      Comment


        #4
        Thanks that did the trick. Might I suggest that someone take the time and update some documentation? Specifically with regards to SharpDX, Stroke, RenderTarget, etc?

        Comment


          #5
          Same error when calling DrawText...

          Ok, so now I'm getting the same error as below, here, *only when I added the RenderTarget.DrawText()*. If I comment it out the rectangles draw properly. I'm missing something in the Brush parameter, and unless I'm missing something, the docs on this are frustratingly sparce:

          Code:
          atOfferRect.X = chartControl.GetXByBarIndex(ChartBars, CurrentBar+1);
          				atOfferRect.Y = chartScale.GetYByValue(Close.GetValueAt(CurrentBar-1)) - 20f;
          				atOfferRect.Width = 80;
          				atOfferRect.Height = 18;
          				RenderTarget.DrawRectangle(atOfferRect, stroke.Brush.ToDxBrush(RenderTarget));
          				[b]RenderTarget.DrawText("hello world", textFormat, atOfferRect, stroke.BrushDX);[/b]

          Comment


            #6
            Originally posted by funk101 View Post
            Ok, so now I'm getting the same error as below, here, *only when I added the RenderTarget.DrawText()*
            Same Problem, Same Solution.. stroke.Brush.ToDxBrush(RenderTarget)


            -=Edge=-
            NinjaTrader Ecosystem Vendor - High Tech Trading Analysis

            Comment


              #7
              Oy, sorry 'bout that. I guess I need a break ;-(

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by dappa, Today, 09:18 AM
              0 responses
              0 views
              0 likes
              Last Post dappa
              by dappa
               
              Started by bill2023, Yesterday, 08:51 AM
              4 responses
              22 views
              0 likes
              Last Post bltdavid  
              Started by trilliantrader, Today, 08:16 AM
              3 responses
              9 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Started by NinjaTrader_ChelseaB, 01-08-2017, 06:59 PM
              79 responses
              19,662 views
              5 likes
              Last Post zrobfrank  
              Started by funk10101, Today, 08:14 AM
              3 responses
              5 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Working...
              X