Support Board
Date/Time: Sun, 22 Dec 2024 11:36:02 +0000
UseTool Text bug
View Count: 935
[2015-08-04 16:01:44] |
User431614 - Posts: 4 |
I am running SC Build 1280 on Windows 8.1 (64-bit). I built a study to display average values on the left side of my chart. The problem is that they are randomly over-written by other values. This seems to be some kind of memory or pointer issue in SC, since I can reproduce the problem with static values for my averages. float EMA_Value1 = 20.0;
float EMA_Value2 = 40.0; float Simple_Avg1_Value = 60.0; float Simple_Avg2_Value = 80.0; float Simple_Avg3_Value = 100.0; float Simple_Avg4_Value = 120.0; float Previous_Close_Value = 140.0; // Character arrays const char* EMA_Value1Chars = sg.FormatGraphValue(EMA_Value1, sg.BaseGraphValueFormat).GetChars(); const char* EMA_Value2Chars = sg.FormatGraphValue(EMA_Value2, sg.BaseGraphValueFormat).GetChars(); const char* Simple_Avg1_ValueChars = sg.FormatGraphValue(Simple_Avg1_Value, sg.BaseGraphValueFormat).GetChars(); const char* Simple_Avg2_ValueChars = sg.FormatGraphValue(Simple_Avg2_Value, sg.BaseGraphValueFormat).GetChars(); const char* Simple_Avg3_ValueChars = sg.FormatGraphValue(Simple_Avg3_Value, sg.BaseGraphValueFormat).GetChars(); const char* Simple_Avg4_ValueChars = sg.FormatGraphValue(Simple_Avg4_Value, sg.BaseGraphValueFormat).GetChars(); const char* Previous_Close_ValueChars = sg.FormatGraphValue(Previous_Close_Value, sg.BaseGraphValueFormat).GetChars(); Please find the attached dll, which you can use to reproduce this issue; just load the study in one of your charts and hit "Insert" or "Cntl-Insert" repeatedly. You will see the pink values on the left change, which should be impossible (they are statically defined as floats). Date Time Of Last Edit: 2015-08-04 17:26:35
|
[2015-08-04 17:25:40] |
Sierra Chart Engineering - Posts: 104368 |
Lines of code like this are not safe: const char* EMA_Value1Chars = sg.FormatGraphValue(EMA_Value1, sg.BaseGraphValueFormat).GetChars(); It is remembering the pointer to the beginning of a string which is only in temporary existence. The code has to be like this: SCString EMA_Value1Chars = sg.FormatGraphValue(EMA_Value1, sg.BaseGraphValueFormat); Also, it is very rare we would ever work with a DLL file. We would only work with a simple code example that we would compile ourselves. 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, *change* to the Teton service: Sierra Chart Teton Futures Order Routing Date Time Of Last Edit: 2015-08-04 17:26:09
|
[2015-08-04 20:58:25] |
User431614 - Posts: 4 |
What should I use with Text.Format()? When I type Previous_Close_ValueChars as SCString (per suggestion above) and pass to Text.Format(), as shown: Tool1.Text.Format("Previous Close: %s\nHigh EMA: %s\nLow EMA: %s", Previous_Close_ValueChars, EMA_Value1Chars, EMA_Value2Chars); I get this error... C:\SierraChart\ACS_Source\dmp_TradingMedium.cpp: In function 'void scsf_DailyComplexStudy(SCStudyInterfaceRef)': C:\SierraChart\ACS_Source\dmp_TradingMedium.cpp:238:153: error: cannot pass objects of non-trivially-copyable type 'class SCString' through '...' Tool1.Text.Format("Previous Close: %s\nHigh EMA: %s\nLow EMA: %s", Previous_Close_ValueChars, EMA_Value1Chars, EMA_Value2Chars); Oddly enough, I don't have this problem when I type Previous_Close_ValueChars as 'const char*' Date Time Of Last Edit: 2015-08-04 21:04:06
|
[2015-08-04 22:06:36] |
Sierra Chart Engineering - Posts: 104368 |
Use: Previous_Close_ValueChars.GetChars() Use GetChars() with any SCString where a character pointer is required. 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, *change* to the Teton service: Sierra Chart Teton Futures Order Routing |
To post a message in this thread, you need to log in with your Sierra Chart account: