• 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

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.
    Patrick H.NinjaTrader Customer Service

    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));
          				RenderTarget.DrawText("hello world", textFormat, atOfferRect, stroke.BrushDX);

          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 Conall, Today, 01:51 PM
              3 responses
              17 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by Tenfold, Yesterday, 11:38 PM
              8 responses
              46 views
              0 likes
              Last Post NinjaTrader_PaulH  
              Started by Seneca, Today, 10:50 AM
              2 responses
              23 views
              0 likes
              Last Post Seneca
              by Seneca
               
              Started by antrux, Today, 09:47 AM
              3 responses
              15 views
              0 likes
              Last Post NinjaTrader_Jim  
              Started by wtfalfred, Today, 06:04 AM
              1 response
              14 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Working...
              X