Support Board
Date/Time: Wed, 26 Feb 2025 19:57:18 +0000
Post From: Illogical ACS study button - forced choice
[2021-05-17 01:53:08] |
ertrader - Posts: 681 |
SC support, when you make the changes you are proposing, can you please provide update examples/guidance and the SC version needed and how to change current code? It took lots of trial and error to get the below ACS Control bar code working (it is reliable but does have some performance issues). Also, the below code was documented in the other User-supported SC link (can't remember the exact link name) for coding help but the link no longer appears in the support board. This code has 4 buttons that toggle to enable or disable an action in my autotrade study: 1) Study enable/disable, 2) Long enable/disable, 3) Short enable/disable and 4) Send enable/disable. For each instrument I trade, there are 4 buttons. Each button gets it's own unique number per chart that I set in my autotrade study. When used, I usually set to enable all but the enabled button per instrument... then when the conditions are right, immediately toggle the button so the autotrade study takes over and enters the order based on my other preset triggers and conditions. // set ACS Tool Control Bar tool tip
sc.SetCustomStudyControlBarButtonHoverText(Input_ACSButtonNumber.GetInt(), "Trade Enable/Disable"); sc.SetCustomStudyControlBarButtonHoverText(Input_ACSButtonNumber1.GetInt(), "Long"); sc.SetCustomStudyControlBarButtonHoverText(Input_ACSButtonNumber2.GetInt(), "Short"); sc.SetCustomStudyControlBarButtonHoverText(Input_ACSButtonNumber3.GetInt(), "Send"); // set Custom Study Control Bar button text if the input to allow custom properties is not true. Otherwise, rely upon what the user sets. if (!Input_AllowCustomPropertiesForControlBarButton.GetYesNo()) sc.SetCustomStudyControlBarButtonText(Input_ACSButtonNumber.GetInt(), "Trade"); if (!Input_AllowCustomPropertiesForControlBarButton1.GetYesNo()) sc.SetCustomStudyControlBarButtonText(Input_ACSButtonNumber1.GetInt(), "Long"); if (!Input_AllowCustomPropertiesForControlBarButton2.GetYesNo()) sc.SetCustomStudyControlBarButtonText(Input_ACSButtonNumber2.GetInt(), "Short"); if (!Input_AllowCustomPropertiesForControlBarButton3.GetYesNo()) sc.SetCustomStudyControlBarButtonText(Input_ACSButtonNumber3.GetInt(), "Send"); // set buttons to disabled i.e. not pushed in state sc.SetCustomStudyControlBarButtonEnable(Input_ACSButtonNumber.GetInt(), 0); sc.SetCustomStudyControlBarButtonEnable(Input_ACSButtonNumber1.GetInt(), 0); sc.SetCustomStudyControlBarButtonEnable(Input_ACSButtonNumber2.GetInt(), 0); sc.SetCustomStudyControlBarButtonEnable(Input_ACSButtonNumber3.GetInt(), 0); // set button color to show enabled / disabled state if (Enabled.GetYesNo()) sc.SetCustomStudyControlBarButtonColor(Input_ACSButtonNumber.GetInt(), RGB(0, 128, 255)); else sc.SetCustomStudyControlBarButtonColor(Input_ACSButtonNumber.GetInt(), COLOR_RED); if (Long.GetYesNo()) sc.SetCustomStudyControlBarButtonColor(Input_ACSButtonNumber1.GetInt(), RGB(0, 128, 255)); else sc.SetCustomStudyControlBarButtonColor(Input_ACSButtonNumber1.GetInt(), COLOR_RED); if (Short.GetYesNo()) sc.SetCustomStudyControlBarButtonColor(Input_ACSButtonNumber2.GetInt(), RGB(0, 128, 255)); else sc.SetCustomStudyControlBarButtonColor(Input_ACSButtonNumber2.GetInt(), COLOR_RED); if (SendOrdersToService.GetYesNo()) sc.SetCustomStudyControlBarButtonColor(Input_ACSButtonNumber3.GetInt(), RGB(0, 128, 255)); else sc.SetCustomStudyControlBarButtonColor(Input_ACSButtonNumber3.GetInt(), COLOR_RED); if (sc.MenuEventID != 0) { if (sc.MenuEventID == Input_ACSButtonNumber.GetInt()) { // reset button to disabled i.e. not pushed in state sc.SetCustomStudyControlBarButtonEnable(Input_ACSButtonNumber.GetInt(), 0); if (Enabled.GetYesNo()) { // change state of input to disabled and set color accordingly Enabled.SetYesNo(0); sc.SetCustomStudyControlBarButtonColor(Input_ACSButtonNumber.GetInt(), COLOR_RED); } else { // change state of input to disabled and set color accordingly Enabled.SetYesNo(1); sc.SetCustomStudyControlBarButtonColor(Input_ACSButtonNumber.GetInt(), RGB(0, 128, 255)); } } else if (sc.MenuEventID == Input_ACSButtonNumber1.GetInt()) { sc.SetCustomStudyControlBarButtonEnable(Input_ACSButtonNumber1.GetInt(), 0); if (Long.GetYesNo()) { Long.SetYesNo(0); sc.SetCustomStudyControlBarButtonColor(Input_ACSButtonNumber1.GetInt(), RGB(0, 128, 255)); } else { Long.SetYesNo(1); sc.SetCustomStudyControlBarButtonColor(Input_ACSButtonNumber1.GetInt(), COLOR_RED); } } else if (sc.MenuEventID == Input_ACSButtonNumber2.GetInt()) { sc.SetCustomStudyControlBarButtonEnable(Input_ACSButtonNumber2.GetInt(), 0); if (Short.GetYesNo()) { Short.SetYesNo(0); sc.SetCustomStudyControlBarButtonColor(Input_ACSButtonNumber2.GetInt(), RGB(0, 128, 255)); } else { Short.SetYesNo(1); sc.SetCustomStudyControlBarButtonColor(Input_ACSButtonNumber2.GetInt(), COLOR_RED); } } else if (sc.MenuEventID == Input_ACSButtonNumber3.GetInt()) { sc.SetCustomStudyControlBarButtonEnable(Input_ACSButtonNumber3.GetInt(), 0); if (SendOrdersToService.GetYesNo()) { SendOrdersToService.SetYesNo(0); sc.SetCustomStudyControlBarButtonColor(Input_ACSButtonNumber3.GetInt(), RGB(0, 128, 255)); } else { SendOrdersToService.SetYesNo(1); sc.SetCustomStudyControlBarButtonColor(Input_ACSButtonNumber3.GetInt(), COLOR_RED); } } } Date Time Of Last Edit: 2021-05-17 02:23:20
|
![]() ![]() |