Support Board
Date/Time: Sun, 11 May 2025 20:55:41 +0000
[Programming Help] - Programming Help: Tick Size and Scale Range Type
View Count: 287
[2024-08-29 09:45:37] |
User688525 - Posts: 284 |
Hello Sierra Chart, I have created a simple custom study to change the Tick Size and Scale Range Type using the code below. Can assistance please be provided for two issues: 1) The ScaleConstRange is not being applied to the main graph ("0"). If this is changed to "1" (graph 2), then it appears to work? 2) When sc.FlagToReloadChartData is set to "1", the chart continuously reloads/loops? #include "sierrachart.h"
SCDLLName("Ticks Range") SCSFExport scsf_TicksRange(SCStudyInterfaceRef sc) { sc.TickSize = 0.5; // Set the tick size to 0.5 sc.ScaleRangeType = SCALE_CONSTANT_RANGE; // Set this study to use a centered constant range scale sc.ScaleConstRange = 30; // Set the range of the scale to 30 points sc.GraphRegion = 0; // Use the main price graph region sc.FlagToReloadChartData = 1; // Reload the chart data } Thank you |
[2024-08-29 12:22:17] |
emmanuel - Posts: 63 |
Try this: SCDLLName("Ticks Range")
SCSFExport scsf_TicksRange(SCStudyInterfaceRef sc) { int& IsTickSizeSet = sc.GetPersistentInt(0); if(sc.SetDefaults) { sc.ScaleRangeType = SCALE_CONSTANT_RANGE; // Set this study to use a centered constant range scale sc.ScaleConstRange = 30; // Set the range of the scale to 30 points sc.GraphRegion = 0; // Use the main price graph region } if(sc.Index == 0 && IsTickSizeSet == 0) { sc.TickSize = 0.5; // Set the tick size to 0.5 IsTickSizeSet = 1; sc.FlagToReloadChartData = 1; } } |
[2024-08-29 19:20:46] |
User688525 - Posts: 284 |
Hello emmanuel , Thanks for your help. When I build and run the study, no errors appear, however, neither the scale or ticksize change? Update: the following code changes the tick size but not the scale range: #include "sierrachart.h"
SCDLLName("Ticks Range") SCSFExport scsf_TicksRange(SCStudyInterfaceRef sc) { int& IsTickSizeSet = sc.GetPersistentInt(0); // track if tick size has been set // Set chart properties if(sc.SetDefaults) { sc.ScaleRangeType = SCALE_CONSTANT_RANGE; // set scale range type to constant range sc.ScaleConstRange = 30; // set constant range value to 30 sc.GraphRegion = 0; // set study Graph Name return; } // Check and set tick size if(sc.Index == 0) { // check tick size if(sc.TickSize != 0.5) { // if tick size is not 0.5 sc.TickSize = 0.5; // set tick size to 0.5 IsTickSizeSet = 1; // mark that tick size has been set sc.FlagToReloadChartData = 1; // reload chart } } } Date Time Of Last Edit: 2024-08-29 19:33:30
|
[2024-08-29 19:36:44] |
emmanuel - Posts: 63 |
OK, then you can apply the same concept to the scale range. When the sc.Index is 0: 1. Check if the scale range type is correct, if not, set it. 2. Same for the scale range. Note: You can remove the IsTickSizeSet stuff since the comparison you're doing to 0.5 is effectively doing the same thing. |
[2024-08-29 22:00:19] |
User688525 - Posts: 284 |
Hi, Thanks for the suggestions. I will make a few changes and see if this works. |
[2024-08-30 08:05:10] |
User431178 - Posts: 672 |
The ScaleConstRange is not being applied to the main graph ("0"). If this is changed to "1" (graph 2), then it appears to work?
For setting the main graph to a specific constant range, did you try these? ACSIL Interface Members - Variables and Arrays: sc.BaseGraphScaleRangeType ACSIL Interface Members - Variables and Arrays: sc.BaseGraphScaleConstRange |
[2024-08-30 09:30:02] |
User688525 - Posts: 284 |
For setting the main graph to a specific constant range, did you try these?
Hi, Thanks for the help and the links. Yes, I did and have now managed to get the study working. I was using "sc.ScaleConstRange" instead of "sc.BaseGraphScaleConstRange". Thanks again! |
To post a message in this thread, you need to log in with your Sierra Chart account: