Login Page - Create Account

Support Board


Date/Time: Tue, 26 Nov 2024 17:25:17 +0000



Post From: GDI w/2551 and study updates (manual vs auto looping implications)

[2023-11-11 17:18:07]
User133994 - Posts: 80
Thanks for your response. Yes, it appear as though the upwards counting is simply counting the 'redraw' events that SC is initiating...isn't related to autoloop =1 or not.

I've confirmed this, by making these changes:
sc.AutoLoop = 0;
and
void DrawToChart(HWND WindowHandle, HDC DeviceContext, SCStudyInterfaceRef sc )
{
//%{{% demo showing repaints

auto& someNum = sc.GetPersistentInt(26); // this reveals repaints
if (sc.UpdateStartIndex == 0 ){
//%{{% intialize someNum
someNum = 1; // starting y position
return;
//%}}%
}

  sc.Graphics.SetTextAlign(TA_NOUPDATECP);

  n_ACSIL::s_GraphicsFont GraphicsFont;

  GraphicsFont.m_Height = 16;
  GraphicsFont.m_Weight = FW_BOLD;
  sc.Graphics.SetTextFont(GraphicsFont);

  n_ACSIL::s_GraphicsColor GraphicsColor;
  GraphicsColor.SetRGB(64, 128, 0);

  sc.Graphics.SetBackgroundColor(GraphicsColor);

SCString text;
text.Format("Hello manual update %d", someNum++);

  sc.Graphics.DrawTextAt(text, 350, 200);


  return;
//%}}%
}

So, this version also repaints with numbers incrementing even though I'm not doing a replay and the market isn't open. I must have simply found the SC (or windows) internal redrawing activity.

In fact, when I add a condition that returns immediately unless it is the 1st tick of the new bar and do a replay, the GDI text draws for only that moment for the 1st tick of the new bar, and then disappears for the other 100+ ticks. So, repainting is required to be visible to the user *on every tick* whether it is autoloop=1 or autoloop=0.

Thus, manual looping is optimal, since repainting is needed to view the actual GDI drawing. Using autoloop adds all the repeated function call overhead (on every bar). At least that is what I think is happening.

My experience is different.
-- might be related to your charts' update interval. I'm not sure why you aren't seeing an incrementing numbers.
Date Time Of Last Edit: 2023-11-11 17:18:31