Login Page - Create Account

Support Board


Date/Time: Thu, 16 Oct 2025 01:06:08 +0000



Post From: Issues with sc.Graphics functions

[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.