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 cre8able, 02-11-2023, 05:43 PM
              3 responses
              236 views
              0 likes
              Last Post rhubear
              by rhubear
               
              Started by frslvr, 04-11-2024, 07:26 AM
              8 responses
              113 views
              1 like
              Last Post NinjaTrader_BrandonH  
              Started by stafe, 04-15-2024, 08:34 PM
              10 responses
              46 views
              0 likes
              Last Post stafe
              by stafe
               
              Started by rocketman7, Today, 09:41 AM
              3 responses
              11 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by traderqz, Today, 09:44 AM
              2 responses
              10 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Working...
              X