I don't see any breakpoints being hit by my code when it is lagging. When commenting out the drawings using the Stroke and FillRectangle, everything runs normally. I'm not sure what I am doing wrong. I'm using OnRenderTargetChanged() example. Any idea how to fix this?
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
OnRender Lag using Stroke
Collapse
X
-
OnRender Lag using Stroke
When drawing using Stroke i'm getting a lot of lag. The chart seems unresponsive and takes several seconds to render but NT8 is not crashing. I followed the instructions here: https://ninjatrader.com/support/help...roke_class.htm
I don't see any breakpoints being hit by my code when it is lagging. When commenting out the drawings using the Stroke and FillRectangle, everything runs normally. I'm not sure what I am doing wrong. I'm using OnRenderTargetChanged() example. Any idea how to fix this?Tags: None
-
-
Hi habibalex, thank you for your patience.
I added a Print within OnRender and found a performance issue is coming from somewhere outside of OnRender. The file loading seems to be gumming up the system. Please look at this section of the code and optimize as much as possible.
Please let me know if I can assist any further.Chris L.NinjaTrader Customer Service
Comment
-
File.ReadAllLines is part of .NET Framework so there shouldn't be any bugs there. Since it only occurs while dashed style was being drawn, I was able to narrow it down. This fixed the issue:
Code:int endXpos = lev.barEnd == int.MaxValue ? (int)chartScale.Width : chartControl.GetXByBarIndex(ChartBars,lev.barEnd);
Comment
-
Hello habibalex,
I would not expect GetXByBarIndex() to return a value when supplied with int.MaxValue.
GetXByBarIndex() returns an x value for a specified bar number. If you are supplying a bar number that does not exist, this will cause an error.
The value supplied needs to be less than or equal to the value of CurrentBar.
When supplying a value that is less than or equal to CurrentBar does this error still occur?Chelsea B.NinjaTrader Customer Service
Comment
-
Hello habibalex,
When you have mentioned:
"Seems like GetXByBarIndex can't handle int.MaxValue w/ the FillRectangle and non-solid StrokeStyle. I think this is a bug."
You are specifically saying that GetXByBarIndex() is failing when supplying int.MaxValue, is this correct?Chelsea B.NinjaTrader Customer Service
Comment
-
Hello habibalex,
The issue may be caused by GetXByBarIndex() being misused.
You may be requesting the x value from bar indexes that do not exist.
Possibly, correcting the logic to prevent GetXByBarIndex() from being called with invalid indexes may correct the behavior.Chelsea B.NinjaTrader Customer Service
- Likes 1
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by businessman1929, 04-29-2024, 01:28 PM
|
2 responses
21 views
0 likes
|
Last Post Today, 05:38 PM | ||
Started by bltdavid, 03-27-2023, 05:32 AM
|
18 responses
346 views
0 likes
|
Last Post
by ETFVoyageur
Today, 05:28 PM
|
||
Started by NM_eFe, Today, 05:15 PM
|
0 responses
4 views
0 likes
|
Last Post
by NM_eFe
Today, 05:15 PM
|
||
Started by vitaly_p, Today, 05:09 PM
|
0 responses
3 views
0 likes
|
Last Post
by vitaly_p
Today, 05:09 PM
|
||
Started by cmtjoancolmenero, Today, 05:05 PM
|
0 responses
2 views
0 likes
|
Last Post Today, 05:05 PM |
Comment