Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Attempted to read or write protected memory. This is often an indication that other m
Collapse
X
-
Attempted to read or write protected memory. This is often an indication that other m
I am getting the following error and have exhausted all ideas on what might be the issue:
Code:Last edited by swcooke; 09-04-2018, 08:15 AM.Tags: None
-
Hello swooke,
Thanks for your post.
This error is typically seen with an issue with SharpDX resource management. At first glance, I see that you are (re)creating brushes in OnRenderTargetChange() and then disposing them immediately after. Brushes should be disposed of and then recreated in OnRenderTargetChange().
If you do not wish to re-use brushes (advised best practice) and create the brushes in OnRender() before they are used, the brushes would need to be disposed of at the end of the OnRender() pass.
I've provided links to further reading on SharpDX rendering and an example which draws candlesticks which could be used for further direction.
SharpDX Rendering - https://ninjatrader.com/support/help..._rendering.htm
HeikenAshi8 - https://ninjatrader.com/support/foru...tid=-1&lpage=1
Additional examples on re-using SharpDX brushes can be found here - https://ninjatrader.com/support/foru...144#post509144
Please let us know if there is anything else we can do to help.JimNinjaTrader Customer Service
-
On a related note, I noticed that the HeikenAshi example you provided uses, for example, this for a down bar color:
Code:[XmlIgnore] [Display(Name="BarColorDown", Description="Color of Down bars", Order=2, GroupName="Visual")] public Brush BarColorDown { get { return barColorDown;} set { barColorDown = value;} }
Code:[XmlIgnore] [Display(Name = "Down Candle", GroupName = "Technology(XLK)", Order = 2)] public System.Windows.Media.Brush XlkDownCandleBrush { get { return xlkDownCandleBrush; } set { xlkDownCandleBrush = value; if (xlkDownCandleBrush != null) { if (xlkDownCandleBrush.IsFrozen) { xlkDownCandleBrush = xlkDownCandleBrush.Clone(); xlkDownCandleBrush.Freeze(); } } } }
Comment
-
Hello swooke,
You may observe the syntax the NinjaScript code generators create for Brush properties for a minimalist implementation.
For example, right click on the indicators folder in the NinjaScript Editor and select New Indicator. From the New Indicator Wizard, add a Brush property under Input parameters and then click Generate.
Further reading on the syntax generated for Brushes and how they can be serialized can be found in the tip article below. Serialization is necessary to save the Brush to xml files. (So they can be saved in Templates and Workspaces)
User Defined Brushes - https://ninjatrader.com/support/help...lor_inputs.htm
I've also included reference for working with brushes to better understand when a brush would need to be frozen.
Working with Brushes - https://ninjatrader.com/support/help...th_brushes.htm
Please let us know if we can be of further assistance.JimNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by ETFVoyageur, 05-07-2024, 07:05 PM
|
19 responses
147 views
0 likes
|
Last Post
by ETFVoyageur
Today, 09:14 PM
|
||
Started by ETFVoyageur, Yesterday, 10:13 PM
|
3 responses
26 views
0 likes
|
Last Post
by ETFVoyageur
Today, 09:08 PM
|
||
Started by ETFVoyageur, Yesterday, 12:52 AM
|
3 responses
33 views
0 likes
|
Last Post
by ETFVoyageur
Today, 09:05 PM
|
||
Started by ETFVoyageur, Today, 02:10 AM
|
2 responses
27 views
0 likes
|
Last Post
by ETFVoyageur
Today, 08:55 PM
|
||
Started by ryan_21, Today, 08:46 PM
|
1 response
2 views
0 likes
|
Last Post Today, 08:52 PM |
Comment