Support Board
Date/Time: Wed, 15 Oct 2025 22:49:50 +0000
[Programming Help] - Issues with sc.Graphics functions
View Count: 50
[2025-10-15 14:43:21] |
User695730 - Posts: 9 |
Hi, I am implementing a sudy with GDIFunction. It is working fine if I directly use the wingdi interface. I am on a mac with crossover using sierra 54254. The code is just to create circles colored based on bid/ask direction for time-and-sales trades: sc.Graphics.ResetBrush(); sc.Graphics.ResetPen(); int y_coord; auto x_coord = first_x_coordinate; int r = 0; for (auto & trade : *trades) { y_coord = sc.RegionValueToYPixelCoordinate(trade.price, sc.GraphRegion); auto size = trade.volume >= volume_thresh ? 30 : 6; auto half_size = size / 2; switch (trade.type) { case SC_TS_BID: // SelectObject(DeviceContext, brush_bid); // SelectObject(DeviceContext, pen_bid) sc.Graphics.ResetBrush(); sc.Graphics.SetBrush(brush_bid); sc.Graphics.SetPen(pen_bid); break; case SC_TS_ASK: // SelectObject(DeviceContext, brush_ask); // SelectObject(DeviceContext, pen_ask); sc.Graphics.ResetBrush(); sc.Graphics.SetBrush(brush_ask); sc.Graphics.SetPen(pen_ask); break; } if (trade.volume >= volume_thresh) { x_coord -= 12; } // Ellipse(DeviceContext, x_coord - half_size, y_coord - half_size, x_coord + half_size, y_coord + half_size); sc.Graphics.FillEllipse(x_coord - half_size, y_coord - half_size, x_coord + half_size, y_coord + half_size, trade.type == SC_TS_BID ? brush_bid : brush_ask); // sc.Graphics.DrawEllipse(x_coord - half_size, y_coord - half_size, x_coord + half_size, y_coord + half_size); if (trade.volume >= volume_thresh) { sc.Graphics.DrawTextAt(SCString().Format("%d", trade.volume), x_coord - 0, y_coord - 10); x_coord -= 12; } x_coord -= 8; // sc.Graphics.ResetPen(); // sc.Graphics.ResetBrush(); } // DeleteObject(brush_bid); // DeleteObject(brush_ask); // DeleteObject(pen_bid); // DeleteObject(pen_ask); sc.Graphics.ResetPen(); sc.Graphics.ResetBrush(); sc.Graphics.ResetTextFont(); sc.Graphics.ResetTextColor(); sc.Graphics.ResetTextAlign(); sc.Graphics.ResetBackgroundMode(); Default study colors are red and green, but the brush never changes color. As can be seen in the screenshot: https://www.sierrachart.com/image.php?Image=1760538971798.png The same is true for the "DrawToChart" example in the sierra-chart provided example studies. https://www.sierrachart.com/image.php?Image=1760539048887.png From reading the example code, the top-left rectangle should be yellow filled and the other one should be outline only. Again, with just using wingdi directly, I don't have that problem. Please advise. Thanks, Omer. |
[2025-10-15 14:50:10] |
User431178 - Posts: 801 |
You can read about it here - Discrepancies in GDI Drawings Output with OpenGL Enabled/Disabled in Sierra Chart - to my knowledge it is not resolved.
|
[2025-10-15 14:59:10] |
User695730 - Posts: 9 |
Yes. Thanks for replying. I saw that thread, but I though maybe it's not the same thing since it's a thread from more than a year ago. Also, the workaround in that thread won't help me, since I need to draw circles, not rectangles. Additionally, if more users are affected, maybe sierra-chart engineers will decide it's worth their while. |
[2025-10-15 15:07:37] |
User431178 - Posts: 801 |
Yes, it's the same thing, when not using OpenGL brush color change only works once. For me the answer was to use sc.Graphics when OpenGL is enabled and win GDI when not. |
[2025-10-15 15:07:55] |
Sierra_Chart Engineering - Posts: 21141 |
For the record, the user in the first post could not be using OpenGL.
Sierra Chart Support - Engineering Level Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy: https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation For the most reliable, advanced, and zero cost futures order routing, use the Teton service: Sierra Chart Teton Futures Order Routing Date Time Of Last Edit: 2025-10-15 15:08:26
|
To post a message in this thread, you need to log in with your Sierra Chart account: