Support Board
Date/Time: Sat, 10 May 2025 20:52:26 +0000
Post From: Entering TickSize and Price Display Format using a Control Bar button or Keyboard shortcul
[2016-05-31 14:38:11] |
SSS - Posts: 16 |
Sorry User365411, been in and out of hospital again. Here's what I came up with. In addition to loading this study on your chart, you'll need to put some of the reserved Buttons on one of the Control Bars. For example, go to Window->Control Bars and select Control Bar 8 (in order not to disturb your existing toolbar setup). When the control bar appears, right-click on it and choose "Customize". From the window that opens, scroll down to the branch "Tools - Advanced Custom Study Buttons". Add at least buttons CS1, CS2, CS3, and CS4 because these are the ones called by the study. Not that it matters, but it may be helpful to empty the control bar from any buttons already there first. I also set the control bar to Float and enlarged its window so I could have long-ish labels on the buttons. I hope this helps. SCSFExport scsf_ButtonExample(SCStudyInterfaceRef sc) { //Study adapted from the code for the "Menu and Pointer Interaction Example" scsf_MenuAndPointerExample . NOTE: Study is NOT listed in the main Studies (F6) window. //It must be accessed through: Studies (F6) --> Add Custom Study --> Sierrachart Custom Studies & Examples --> Menu and Pointer Interaction Example //Source code is in "studies.cpp" file, function "scsf_MenuAndPointerExample" (starts at line 2697 in the studies.cpp that comes with SC v1414. Could be different in newer versions) float& initialTickSize = sc.GetPersistentFloat(1); initialTickSize = sc.TickSize; SCString MessageText; // Set configuration variables if (sc.SetDefaults) { sc.GraphName = "Button Example"; sc.StudyDescription = "Working with Buttons placed on Control Bars (i.e. toolbars) to act as shortcuts"; sc.GraphRegion = 0; //During development set this flag to 1, so the DLL can be modified. When development is completed, set it to 0 to improve performance. sc.FreeDLL = 1; // We have expressly set Autolooping to off because we are not filling // in any of the Subgraph[].Data[] arrays. Since Autolooping will // cause this function to be called for every bar in the chart and all // we are doing is using tools to do drawings, it would be inefficient // to use Autolooping. sc.AutoLoop = 0; // Indicate to receive the pointer events sc.ReceivePointerEvents = 0; sc.Input[10].Name = "My preset inputs"; sc.Input[10].SetCustomInputStrings("option1; option2; thridOption;"); sc.Input[10].SetCustomInputIndex(0); return; } if (sc.LastCallToFunction) { //When study is removed, this resets buttons in the toolbar to their original names (CS1, CS2, CS3, etc) sc.SetACSToolButtonText(1, ""); sc.TickSize = initialTickSize; sc.SetACSToolButtonText(2, ""); sc.SetACSToolButtonText(3, ""); sc.SetACSToolButtonText(4, ""); return; } if (sc.UpdateStartIndex == 0) { // Set the ACS Control Bar button 1 hover text sc.SetACSToolToolTip(1, "This is the custom hover text for ACS Control Bar button 1"); // Set the ACS Control Bar button 1 text sc.SetACSToolButtonText(1, "ACS1"); sc.SetACSToolButtonText(2, "Tick Size 100"); sc.SetACSToolToolTip(2, "Hardwired change to Tick Size = 100"); sc.SetACSToolButtonText(3, "TickSize 200"); //nothing appears on this button when we hover over it because no "tooltip" has been set sc.SetACSToolButtonText(4, "First Input Option"); } // wait for an event if (sc.MenuEventID != 0) { if (sc.MenuEventID >= SC_ACS_TOOL1 && sc.MenuEventID <= SC_ACS_TOOL50) { MessageText.Format("Got event id %i, ", sc.MenuEventID); if (sc.PointerEventType == SC_ACS_TOOL_ON) { MessageText.Append("ACS Tool On Event, "); if (sc.MenuEventID == SC_ACS_TOOL2) { sc.TickSize = 100; sc.FlagToReloadChartData = 1; //reloads the chart //sc.ACSToolBlocksChartValuesTool(true); sc.SetACSToolEnable(SC_ACS_TOOL2, true); //This should make Button CS2 stick after being clicked. With button stuck, SC will continue monitoring events, and report them if sc.ReceivePointerEvents = 1 in the sc.SetDefaults block } if (sc.MenuEventID == SC_ACS_TOOL3) { sc.TickSize = 200; sc.FlagToReloadChartData = 1; sc.SetACSToolEnable(SC_ACS_TOOL3, false); //This should make Button CS3 NOT stick after being clicked. //sc.ACSToolBlocksChartValuesTool(true); } if (sc.MenuEventID == SC_ACS_TOOL4) { sc.Input[10].SetCustomInputIndex(0); //assuming I have an input with preset selections, this should select the first present (index 0) sc.FlagToReloadChartData = 1; sc.SetACSToolEnable(SC_ACS_TOOL4, false); } } else if (sc.PointerEventType == SC_ACS_TOOL_OFF) { MessageText.Append("ACS Tool Off Event, "); if (sc.MenuEventID == SC_ACS_TOOL2) sc.ACSToolBlocksChartValuesTool(false); if (sc.MenuEventID == SC_ACS_TOOL2) { sc.TickSize = initialTickSize; sc.FlagToReloadChartData = 1; } } // reset tool 1. tool 1 will only get single down click if (sc.MenuEventID == SC_ACS_TOOL1) sc.SetACSToolEnable(SC_ACS_TOOL1, false); } // MessageText.Append("Y Value="); // MessageText += sc.FormatGraphValue(sc.ActiveToolYValue, sc.GetValueFormat()); // MessageText.Append(", Bar Index="); // MessageText += sc.FormatGraphValue(sc.ActiveToolIndex, 0); sc.AddMessageToLog(MessageText, 0); } } |