- ago
The semi-converted WL6 to WL7 code below is placing a "right corner" message on the chart. To do this, it needs to compute a vertical yPosition for this message, which avoids the most recent bars plotted (Remember, this is a "right" corner message.). To do that, it needs to know the horizontal "InView" range of the chart. And to do that, it calls chart.LeftEdgeBar in WL6 (see below).

Simple question: What's the equivalent of chart.LeftEdgeBar in WL7? I can figure the rest out from there.

CODE:
public void ShowCornerMsg(string cornerMsg, TimeSeries ts2frame, string messagePane, double hue = 0.5, int fontSize = 11) { if (usb.ExecutionMode == StrategyExecutionModes.Strategy) //avoid annotating multiple symbol runs; single charts only { //var chart = (CandleChartStyle)usb.ChartStyle; double hueChked = Math.Max(hue, 0.0); //disallow negative hue values double lowestInView = Lowest.Value(ts2frame.Count - 1, ts2frame, ts2frame.Count - chart.LeftEdgeBar); double highestInView = Highest.Value(ts2frame.Count - 1, ts2frame, ts2frame.Count - chart.LeftEdgeBar); double recentValues = SMA.Value(ts2frame.Count - 1, ts2frame, 17); double yPosition = (recentValues - lowestInView > highestInView - recentValues) ? (lowestInView + recentValues) * 0.5 + (highestInView - lowestInView) * 0.09 : highestInView; Color msgColor = Color.FromArgb(255 - (int)(hueChked * 255.0), (int)(hueChked * 110.0), 0); //msg hue from red (hue=0) to dark green (hue=1) //Font cornerFont = new Font("Arial", fontSize, FontStyle.Bold); usb.DrawText(cornerMsg, ts2frame.Count - 11, yPosition, msgColor, fontSize, messagePane); } }

If one can figure out another way to place a right corner message on a Pane of choice while avoiding the plot on that Pane, I would also be interested in that solution. Perhaps WL7 (and WPF) has some tricks WL6 (and Windows.Forms) doesn't know about.

One alternative approach would be to get WPF to return the yMinValue and yMaxValue of the message Pane in question. Then yPosition could be easily determined. That was the original approach I wanted to use with WL6, but it wouldn't support it.
0
213
2 Replies

Reply

Bookmark

Sort
- ago
#2
So I simply want to float a right corner message around a bar plot on a Chart pane. The code above works well with WL6, but I need the equivalent to chart.LeftEdgeBar in WL7 to make this code work again. Any thoughts?

Another approach would be to get WPF to return yMinValue and yMaxValue chart values for the pane in question so a yPosition can be computed from that. That feature was missing in WL6.

The really fancy approach would be to do it as is typically done with CSS (on a responsive design website) using XAML. Simply float the corner message box around the right-end bounding box of the plot. But I would probably have to write some C# code to find the centroid of the right-end plot and place an ellipse at that centroid, which the corner message can float around. That sounds more complicated.
0

Reply

Bookmark

Sort