Is there something I am missing?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Force Refresh() not working?
Collapse
X
-
Force Refresh() not working?
I am using a custom rendering which draws a text character label to the right of plots, you see in the image. The text char is a variable. The character gets updated by a method called by OnbarUpdate and it corresponds to the color of the plot. I call the ForceRefresh() method after the change of the variable but the the custom rendering never changes the text label. The color of the plot corresponds to the label. As you can see the ForceRefresh() never makes the changes.
Is there something I am missing?
Tags: None
-
Hello cutzpr,
The ForceRefresh method only queues a refresh but won't actually force anything. Are you certain that this is rendering related? For example when you see that this does not work correctly, can you resize the chart or click and drag the chart to see it update? If so that would indicate you do need to re render to have the change visible, if not that would indicate the problem is somewhere else.
I look forward to being of further assistance.eJesseNinjaTrader Customer Service
-
Hello Jesse,
Yes it is rendering related. I resized the chart and moved the chart, minimized, maximized, and it never renders the new value. The character to the left (closest to the boxes) was drawn with Draw.Text inside OnBarUpdate and it work perfectly. The letter "Z" to the right was drawn using custom rendering using the same char variable. When Drawing the text using custom rendering it does not update. You can take a look at the highlighted image. I would rather not mix both custom rendering and the Draw.Text. Can you provide an example with custom rendering where the rendered text variable changes on OnBarUpdate but it renders correctly after ForceRefresh()
Comment
-
Code for reference
Code:protected override void OnRender(ChartControl chartControl, ChartScale chartScale) { // call the base.OnRender() to ensure standard Plots work as designed base.OnRender(chartControl, chartScale); ChartControlProperties chartProperties = chartControl.Properties; //--Setup panel if(chartScale.Properties.YAxisScalingType != YAxisScalingType.Linear) chartScale.Properties.YAxisScalingType = YAxisScalingType.Linear; if(chartScale.Properties.YAxisRangeType != YAxisRangeType.Fixed) chartScale.Properties.YAxisRangeType = YAxisRangeType.Fixed; if(chartScale.Properties.FixedScaleMax != 7) chartScale.Properties.FixedScaleMax = 7; if(chartScale.Properties.FixedScaleMin != 0) chartScale.Properties.FixedScaleMin = 0; //-- if(!IsInHitTest) // Text Labels { NinjaTrader.Gui.Tools.SimpleFont simpleFont1= new NinjaTrader.Gui.Tools.SimpleFont("Verdana", 10) { Bold = false }; NinjaTrader.Gui.Tools.SimpleFont simpleFont2= new NinjaTrader.Gui.Tools.SimpleFont("Verdana", 10) { Bold = false }; float demi1YPoint; float demi2YPoint; float demi3YPoint; float demi4YPoint; padX = 20; padY = 6; endBarX = chartControl.GetXByBarIndex(ChartBars, ChartBars.ToIndex) + padX ; // Same X Coordinate for all text labels, only Y coordinate changes //--Base Period - Inverted label SharpDX.Direct2D1.SolidColorBrush textBrushDx = new SharpDX.Direct2D1.SolidColorBrush(RenderTarget,SharpDX.Color.Black); SharpDX.DirectWrite.TextFormat textFormat1 = simpleFont1.ToDirectWriteTextFormat(); SharpDX.DirectWrite.TextLayout textLayoutInvert; textLayoutInvert = new SharpDX.DirectWrite.TextLayout(NinjaTrader.Core.Globals.DirectWriteFactory,label1, textFormat1, ChartPanel.X + ChartPanel.W, textFormat1.FontSize); SharpDX.Vector2 lowerTextPoint = new SharpDX.Vector2(ChartPanel.W - textLayoutInvert.Metrics.Width, ChartPanel.Y + (ChartPanel.H - textLayoutInvert.Metrics.Height)); //SharpDX.Vector2 lowerTextPoint = new SharpDX.Vector2(endBarX - textLayoutInvert.Metrics.Width , ChartPanel.Y + (ChartPanel.H - textLayoutInvert.Metrics.Height)); RenderTarget.DrawTextLayout(lowerTextPoint, textLayoutInvert, textBrushDx, SharpDX.Direct2D1.DrawTextOptions.NoSnap); //--demi Labels SharpDX.DirectWrite.TextFormat textFormat2 = simpleFont2.ToDirectWriteTextFormat(); //demi1 SharpDX.DirectWrite.TextLayout textLayout1 = new SharpDX.DirectWrite.TextLayout(NinjaTrader.Core.Globals.DirectWriteFactory,demi1trendchar[0] + " " + demi1Label, textFormat2, ChartPanel.X + ChartPanel.W, textFormat2.FontSize); demi1YPoint = chartScale.GetYByValue(5) - textLayout1.Metrics.Height; SharpDX.Vector2 demi1TextPoint = new SharpDX.Vector2(endBarX, demi1YPoint + padY); //demi2 SharpDX.DirectWrite.TextLayout textLayout2 = new SharpDX.DirectWrite.TextLayout(NinjaTrader.Core.Globals.DirectWriteFactory,demi2trendchar[0] + " " + demi2Label, textFormat2, ChartPanel.X + ChartPanel.W, textFormat2.FontSize); demi2YPoint = chartScale.GetYByValue(4) - textLayout2.Metrics.Height; SharpDX.Vector2 demi2TextPoint = new SharpDX.Vector2(endBarX, demi2YPoint + padY); //demi3 SharpDX.DirectWrite.TextLayout textLayout3 = new SharpDX.DirectWrite.TextLayout(NinjaTrader.Core.Globals.DirectWriteFactory, demi3trendchar[0] + " " + demi3Label, textFormat2, ChartPanel.X + ChartPanel.W, textFormat2.FontSize); demi3YPoint = chartScale.GetYByValue(3) - textLayout3.Metrics.Height; SharpDX.Vector2 demi3TextPoint = new SharpDX.Vector2(endBarX, demi3YPoint + padY); //demi4 SharpDX.DirectWrite.TextLayout textLayout4 = new SharpDX.DirectWrite.TextLayout(NinjaTrader.Core.Globals.DirectWriteFactory,demi4trendchar[0] + " " + demi4Label, textFormat2, ChartPanel.X + ChartPanel.W, textFormat2.FontSize); demi4YPoint = chartScale.GetYByValue(2) - textLayout4.Metrics.Height; SharpDX.Vector2 demi4TextPoint = new SharpDX.Vector2(endBarX, demi4YPoint + padY); RenderTarget.DrawTextLayout(demi1TextPoint, textLayout1, textBrushDx, SharpDX.Direct2D1.DrawTextOptions.NoSnap); RenderTarget.DrawTextLayout(demi2TextPoint, textLayout2, textBrushDx, SharpDX.Direct2D1.DrawTextOptions.NoSnap); RenderTarget.DrawTextLayout(demi3TextPoint, textLayout3, textBrushDx, SharpDX.Direct2D1.DrawTextOptions.NoSnap); RenderTarget.DrawTextLayout(demi4TextPoint, textLayout4, textBrushDx, SharpDX.Direct2D1.DrawTextOptions.NoSnap); textLayoutInvert.Dispose(); textBrushDx.Dispose(); textLayout1.Dispose(); textLayout2.Dispose(); textLayout3.Dispose(); textLayout4.Dispose(); //Custom Lines }
Comment
-
Hello cutzpr,
Thanks for checking that and confirming its related to the render pass.
There is technically no way to force a render besides causing an event which needs a render such as resizing or clicking. One item you can try is drawing a drawing object and immediately removing it. Removing an object forces a render so that technically should update the chart. This was a workaround found during beta so I am unsure if that still works today but is something you can quickly try.
Code:Draw.Dot(this, "renderdummy", false, 0, 0, Brushes.Transparent); RemoveDrawObject("renderdummy");
I look forward to being of further assistance.JesseNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by adeelshahzad, Today, 11:49 AM
|
2 responses
3 views
0 likes
|
Last Post
by adeelshahzad
Today, 12:15 PM
|
||
Started by spottysallrite, Today, 11:31 AM
|
1 response
5 views
0 likes
|
Last Post Today, 11:43 AM | ||
Started by johnMoss, 03-04-2024, 01:53 PM
|
2 responses
32 views
0 likes
|
Last Post
by Overnhou
Today, 11:21 AM
|
||
Started by Padan, Today, 02:02 AM
|
5 responses
17 views
0 likes
|
Last Post Today, 11:14 AM | ||
Started by Lele2k24, Yesterday, 11:24 AM
|
8 responses
29 views
0 likes
|
Last Post
by Lele2k24
Today, 11:00 AM
|
Comment