I modified a copy of @CandleStyle to replace the solid brush FillRectangle with a LinearGradientBrush fill. Using this GradientCandleStyle on a TickReplay chart often throws a fatal error, locking NT:
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Gradient throws External component exception
Collapse
X
-
Gradient throws External component exception
Using RC1 on a Win7 64 machine:
I modified a copy of @CandleStyle to replace the solid brush FillRectangle with a LinearGradientBrush fill. Using this GradientCandleStyle on a TickReplay chart often throws a fatal error, locking NT:System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception.So, I enclosed the modified code within try/catch. This changes the error somewhat:
TROUBLE! GradientCandleStyle.OnRender External component has thrown an exception.I've attached a zip file with the code and two log files. Is there something I'm doing wrong?
-
Hello tradesmart, and thank you for your question. In order to help you track down what was occurring, I have added some additional logging code immediately before the code which locked your thread. If you review the output of this code, it should steer you in the correct direction. It may be beneficial to refactor your code so that you are initializing sdx_lgbrush completely before attempting to call FillRectangle. Please let us know if there are any other ways we can help.Attached FilesJessica P.NinjaTrader Customer Service
-
After adding your log code:
First had to prepend NinjaTrader.Cbi to all the LogLevel.Information due to error 'System.LogLevel' is inaccessible due to its protection level.
Then, after compiling, loading a workspace with a single chart using the GradientCandleStyle resulted in a hard crash:
Problem signature:
Problem Event Name: CLR20r3
Problem Signature 01: NinjaTrader.exe
Problem Signature 02: 8.0.0.13
Problem Signature 03: 57c552c3
Problem Signature 04: mscorlib
Problem Signature 05: 4.0.30319.34209
Problem Signature 06: 53489fcf
Problem Signature 07: 378e
Problem Signature 08: 44
Problem Signature 09: FatalError
OS Version: 6.1.7601.2.1.0.256.1
Locale ID: 1033
Additional Information 1: 594f
Additional Information 2: 594f36fe22b44083bdf587f105863cb3
Additional Information 3: 140b
Additional Information 4: 140b1b4a3c9f9295f40ef8b6530960b5
Then it built 5 more bars before returning to rebuild the first bar, repeating through all the bars, again and again until the crash.
Restarting NT and opening the workspace does not cause the error. So, it's intermittent.
The log file does not give me any reason that I can see.
Please explain what you mean by "refactor your code so that you are initializing sdx_lgbrush completely before attempting to call FillRectangle".Attached Files
Comment
-
Steps to reproduce:
(not connected to any data feed)
1. Create a new TickReplay chart, e.g., ES 3 minute with built-in Candlestick style
2. Change to GradientCandlestick style
3. Add VolumeProfile indicator
4. Add BuySellVolume indicator
5. Save workspace
6. Shut down NT8
7. Restart NT8
8. Load the saved workspace
Comment
-
Hello Tradesmart,
Pulling all the DirectX code out of your sample produces a ChartStyle which does not crash Ninja with the procedure you outlined. This leads me to believe that your DirectX code is the code that needs to be modified to avoid the behavior we were seeing.
By "refactor your code so that you are initializing sdx_lgbrush completely before attempting to call FillRectangle", I mean that you have a code block attached to a using declaration, and it is my opinion that if you take your call to FillRectangle out of that block and place it later in your code - while still making sure that everything you need survives the scope of the using declaration - that this will shine more light on what is happening and potentially resolve your query. At the very least, such a refactor will allow you two breakpoints in your code where you can at least put Print statements in, which should lead to a solution.
Please let us know if there are any other ways we can help.Jessica P.NinjaTrader Customer Service
Comment
-
Originally posted by NinjaTrader_JessicaP View PostBy "refactor your code so that you are initializing sdx_lgbrush completely before attempting to call FillRectangle", I mean that you have a code block attached to a using declaration, and it is my opinion that if you take your call to FillRectangle out of that block and place it later in your code - while still making sure that everything you need survives the scope of the using declaration - that this will shine more light on what is happening and potentially resolve your query. At the very least, such a refactor will allow you two breakpoints in your code where you can at least put Print statements in, which should lead to a solution.
I notice that in your @CandleStyle code, you declare Brush brush = closeValue >= openValue ? UpBrushDX : DownBrushDX; and do not perform brush.Dispose(). So, perhaps ChartStyles do automatic garbage collection making Dispose() and/or using() unnecessary? Can you confirm this?
Comment
-
Hello again tradesmart,
While there are objects that are not cleaned up - see LineOnClose and Mountain styles' source - it appears from the documentation for UpBrushDX and DownBrushDX that these do not need to be cleaned up.
In addition, the release notes for RC1 state "The Stroke object .Dispose() method was removed due to technical redundancy. To remove memory resources from any stroke objects, simply set the stroke to null" .
It appears the objects that are being cleaned up under ChartStyles are user created SharpDX objects, such as LineOnClose's SharpDX.Direct2D1.PathGeometry lineGeometry object or Mountain's SharpDX.Direct2D1.SolidColorBrush fillOutline object.
Finally, the examples for ChartStyles in the documentation do not contain a Dispose call in OnTerminated the way e.g. PriceLevelContainers do in source.
Therefore you should be safe if you avoid calls to Dispose except with regard to DirectX objects you create.
Please let us know if there are any other ways we can help.Jessica P.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by geddyisodin, Today, 05:20 AM
|
5 responses
32 views
0 likes
|
Last Post Today, 11:39 AM | ||
Started by bmartz, Today, 09:30 AM
|
2 responses
12 views
0 likes
|
Last Post
by bltdavid
Today, 11:24 AM
|
||
Started by f.saeidi, Today, 11:02 AM
|
1 response
4 views
0 likes
|
Last Post Today, 11:08 AM | ||
Started by geotrades1, Today, 10:02 AM
|
4 responses
12 views
0 likes
|
Last Post
by geotrades1
Today, 11:08 AM
|
||
Started by rajendrasubedi2023, Today, 09:50 AM
|
3 responses
16 views
0 likes
|
Last Post Today, 10:57 AM |
Comment