Support Board
Date/Time: Fri, 16 Jan 2026 03:29:02 +0000
[Programming Help] - Hello - Request for a Button to toggle 1/0 or 1/-1 in a Subgraph value
View Count: 219
| [2025-11-26 16:33:09] |
| HumblyTrading - Posts: 217 |
|
Hello John and Team, Happy Thanksgiving to those in USA. Feature request: A way to toggle an ACS button or similar such that it would have the button status update as a subgraph value 0/1 or -1/1 or whatever. Rationale: This could then be monitored for all kinds of customizations in auto spreadsheets, trade by alert studies, and so on. It could even be used in auto trading to help turn on and off long or short side, while maintaining the other. In summary, any manual interventions that need to be applied to auto systems based on price action interpretations. Thank you, Mike |
| [2025-11-26 17:44:10] |
| John - SC Support - Posts: 44021 |
|
We are not really understanding this request. The point of a Control Bar Button is to toggle some action. The buttons will update if the particular item that it monitors changes, so if you have a button to set a subgraph to 0 when depressed or 1 when not depressed, then the button will change state as the item it monitors changes. A good example of this is the "Trade Management by Study" and the "Enabled" option. If you enable/disable from the study, the Control Bar button updates to reflect this. So we think the Control Bars already do what you are asking for. But maybe we are not understanding, so please give us more information on what exactly you are looking for if not the above. Also, there are better ways to get notifications of the status of something other than the Control Bar buttons. Drawing something to the Graphics Area, in particular, is a good way to have the information. For the most reliable, advanced, and zero cost futures order routing, use the Teton service: Sierra Chart Teton Futures Order Routing |
| [2025-11-27 19:11:35] |
| HumblyTrading - Posts: 217 |
|
Sorry for the confusion. What I'm after is a manual intervention that toggles a subgraph value on and off, such that it can be referenced in the spreadsheets and other alerts. If button is depressed (active), the subgraph would read 1, if button is inactive, it would have a subgraph reading of zero (or whatever). This way, for auto trading, I could temporarily disable and enable longs or shorts, or I could make many other changes based on an active button that the spreadsheet could now read. Currently, unless I have missed it, there is no way to make a manual button change the status of a subgraph so that it can be read by other alerts, studies and spreadsheets. This would give all kinds of creative control to the user. Thank you and Happy Thanksgiving! :) Mike |
| [2025-11-28 20:34:36] |
| HumblyTrading - Posts: 217 |
|
This code works, with the help of Grok... I can assign an ACS hotkey and it will maintain the toggle now as a subgraph Value: For anyone else interested, just save it in the usual file and run the remote build... #include "sierrachart.h" SCDLLName("Toggle Subgraph - Perfect ACS Sync") SCSFExport scsf_ToggleSubgraphPerfect(SCStudyInterfaceRef sc) { SCInputRef ButtonNumberInput = sc.Input[0]; SCSubgraphRef ToggleValue = sc.Subgraph[0]; if (sc.SetDefaults) { sc.GraphName = "Toggle Subgraph - Perfect ACS Sync"; sc.StudyDescription = "One-click toggle. Button depressed = 1, released = 0. Perfect sync."; sc.AutoLoop = 0; ButtonNumberInput.Name = "ACS Button Number (1-150)"; ButtonNumberInput.SetInt(1); ButtonNumberInput.SetIntLimits(1, 150); ToggleValue.Name = "Toggle State"; ToggleValue.DrawStyle = DRAWSTYLE_LINE; ToggleValue.PrimaryColor = RGB(0,255,0); ToggleValue.LineWidth = 2; ToggleValue.DrawZeros = true; // Required for ACS button events sc.ReceivePointerEvents = ACS_RECEIVE_POINTER_EVENTS_ALWAYS; // Initialize button state to off (matches default persistent 0) int InitialTargetID = ACS_BUTTON_1; // Default to button 1 sc.SetCustomStudyControlBarButtonEnable(InitialTargetID, false); return; } int SelectedBtn = ButtonNumberInput.GetInt(); if (SelectedBtn < 1 || SelectedBtn > 150) SelectedBtn = 1; int TargetID = ACS_BUTTON_1 + (SelectedBtn - 1); // === Detect and process ACS button toggle event === if ((sc.PointerEventType == SC_ACS_BUTTON_ON || sc.PointerEventType == SC_ACS_BUTTON_OFF) && sc.MenuEventID == TargetID) { int NewState = (sc.PointerEventType == SC_ACS_BUTTON_ON) ? 1 : 0; sc.SetPersistentInt(1, NewState); SCString Msg; Msg.Format("ACS Button %d → %s", SelectedBtn, NewState ? "ON" : "OFF"); sc.AddMessageToLog(Msg, 1); } // === Synchronize button visual state to persistent value === int CurrentState = sc.GetPersistentInt(1); // 0 or 1 sc.SetCustomStudyControlBarButtonEnable(TargetID, CurrentState != 0); // === Output to subgraph === for (int i = sc.UpdateStartIndex; i < sc.ArraySize; i++) ToggleValue = static_cast<float>(CurrentState); } |
To post a message in this thread, you need to log in with your Sierra Chart account:
