Go Back   NinjaTrader Support Forum > Historical Beta Archive > Version 8 Beta

Version 8 Beta Historical archive for NinjaTrader 8 beta.

NinjaTrader
Reply
 
Thread Tools Display Modes
Old 04-26-2016, 01:14 AM   #1
funk101
Senior Member
 
Join Date: Jan 2006
Location: Margate, Florida, USA
Posts: 586
Thanks: 40
Thanked 12 times in 11 posts
Default 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);
			}
		}
funk101 is offline  
Reply With Quote
Old 04-26-2016, 06:28 AM   #2
NinjaTrader_PatrickH
NinjaTrader Customer Service
 
NinjaTrader_PatrickH's Avatar
 
Join Date: Jul 2011
Location: Denver, CO
Posts: 11,761
Thanks: 792
Thanked 2,034 times in 1,957 posts
Default

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.
NinjaTrader_PatrickH is offline  
Reply With Quote
Old 04-26-2016, 10:06 AM   #3
-=Edge=-
Vendor
 
-=Edge=-'s Avatar
 
Join Date: Feb 2011
Location: USA
Posts: 420
Thanks: 98
Thanked 230 times in 162 posts
Default

Quote:
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
-=Edge=- is offline  
Reply With Quote
The following user says thank you to -=Edge=- for this post:
Old 04-26-2016, 10:16 AM   #4
funk101
Senior Member
 
Join Date: Jan 2006
Location: Margate, Florida, USA
Posts: 586
Thanks: 40
Thanked 12 times in 11 posts
Default

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?
funk101 is offline  
Reply With Quote
Old 04-26-2016, 10:41 AM   #5
funk101
Senior Member
 
Join Date: Jan 2006
Location: Margate, Florida, USA
Posts: 586
Thanks: 40
Thanked 12 times in 11 posts
Default 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);
funk101 is offline  
Reply With Quote
Old 04-26-2016, 10:49 AM   #6
-=Edge=-
Vendor
 
-=Edge=-'s Avatar
 
Join Date: Feb 2011
Location: USA
Posts: 420
Thanks: 98
Thanked 230 times in 162 posts
Default

Quote:
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
-=Edge=- is offline  
Reply With Quote
The following user says thank you to -=Edge=- for this post:
Old 04-26-2016, 11:17 AM   #7
funk101
Senior Member
 
Join Date: Jan 2006
Location: Margate, Florida, USA
Posts: 586
Thanks: 40
Thanked 12 times in 11 posts
Default

Oy, sorry 'bout that. I guess I need a break ;-(
funk101 is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
OnRender -=Edge=- Version 8 Beta 11 10-31-2016 02:35 PM
help with OnRender palinuro Version 8 Beta 8 05-30-2016 10:16 PM
OnRender Error on Bar -1 ? palinuro Version 8 Beta 2 03-23-2016 11:34 AM
CandleStick OnRender Error -=Edge=- Version 8 Beta 1 10-29-2015 03:40 AM
Chart style 'Candlestick': Error on calling 'OnRender' method: SharpDX.SharpDXExcepti MicroTrends Version 8 Beta 1 05-08-2015 07:19 AM


All times are GMT -6. The time now is 11:49 AM.

Futures, foreign currency and options trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing ones financial security or lifestyle. Only risk capital should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results. View Full Risk Disclosure.

CFTC Rules 4.41 - Hypothetical or Simulated performance results have certain limitations, unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.

This website is hosted and operated by NinjaTrader, LLC (“NT”), a software development company which owns and supports all proprietary technology relating to and including the NinjaTrader trading platform. NT is an affiliated company to NinjaTrader Brokerage (“NTB”), which is a NFA registered introducing broker (NFA #0339976) providing brokerage services to traders of futures and foreign exchange products. This website is intended for educational and informational purposes only and should not be viewed as a solicitation or recommendation of any product, service or trading strategy. No offer or solicitation to buy or sell securities, securities derivative or futures products of any kind, or any type of trading or investment advice, recommendation or strategy, is made, given, or in any manner endorsed by any NT affiliate and the information made available on this Web site is not an offer or solicitation of any kind. Specific questions related to a brokerage account should be sent to your broker directly. The content and opinions expressed on this website are those of the authors and do not necessarily reflect the official policy or position of NT or any of its affiliates. 

Vendors along with their websites, products and services, collectively referred to as (“Vendor Content”), are independent persons or companies that are in no manner affiliated with NT or any if its affiliates. NT or any of its affiliates are not responsible for, do not approve, recommend or endorse any Vendor Content referenced on this website and it’s your sole responsibility to evaluate Vendor Content. Please be aware that any performance information provided by a vendor should be considered hypothetical and must contain the disclosures required by NFA Rule 2-29(c). If you are interested in learning more about, or investigating the quality of, any such Vendor Content you must contact the vendor, provider or seller of such Vendor Content. No person employed by, or associated with, NT or any of its affiliates is authorized to provide any information about any such Vendor Content.