Support Board
Date/Time: Thu, 20 Mar 2025 19:47:31 +0000
[Programming Help] - How to center a chart from the ACSIL code ?
View Count: 623
[2022-11-15 15:42:28] |
User921987 - Posts: 239 |
My chart is set to a constant range and when I double click the Y-axis price the chart will be centered vertically. I would like to automate this so is there any methods to do it from the ACSIL code ? |
[2022-11-15 19:09:11] |
JohnR - User831573 - Posts: 320 |
There are APIs relative to scaling and one is to know what the Constant Range value is. It would be up to your code to decide how far or how often you wanted to center the price. ACSIL Interface Members - Variables and Arrays: sc.BaseGraphScaleConstRange sc.BaseGraphScaleConstRange --- Type: Read/write float variable. The sc.BaseGraphScaleConstRange variable gets and sets the grayscale range for the chart base graph when it is using a Scale Type of Constant Range. Also may want to verify scale type. sc.BaseGraphScaleRangeType There are also some options for re-centering as seen in my attachment of the scale settings pop up window within existing UI. Hope this helps, JohnR |
![]() |
[2022-11-16 07:55:35] |
User921987 - Posts: 239 |
By setting the sc.BaseGraphScaleConstRange doesn't center the price. It only changes the range. Is there an API method for the re-center ? I know the <End> key will do the thing. But don't know is it possible to generate a key stroke from the ACSIL code. Date Time Of Last Edit: 2022-11-16 07:57:19
|
[2022-11-16 16:30:02] |
JohnR - User831573 - Posts: 320 |
First, I have not done this in ASCIL or C++, but within your ACSIL code you would read the range and on some cycle (tick, time, etc) then determine if the last price or last bar is over a distance from the center. Then call some other function(s) to update / redraw. or use the C++ code to SendKey the 'End' key. I have not done this, but in a google search in C++ there is info on SendKey with example code and link to key definitions. It could be an easy way to get this done, by sending END key from within your ACSIL. https://stackoverflow.com/questions/5607849/how-to-simulate-a-key-press-in-c how to use sendinput function in C++. // ... INPUT ip; // ... // Set up a generic keyboard event. ip.type = INPUT_KEYBOARD; ip.ki.wScan = 0; // hardware scan code for key ip.ki.time = 0; ip.ki.dwExtraInfo = 0; // Press the "A" key ip.ki.wVk = 0x41; // virtual-key code for the "a" key ip.ki.dwFlags = 0; // 0 for key press SendInput(1, &ip, sizeof(INPUT)); // ... Virtual-Key Codes page is where the magic number 0x41 came from. Go to SendInput documentation page. Still don't understand where's the 0x41. Go to INPUT documentation and from there to KEYBDINPUT documentation. Still no magic 0x41. Finally go to Virtual-Key Codes page and understand that Microsoft has given the names for Ctrl (VK_CONTROL), Alt (VK_MENU), F1-F24 (VK_F1 - VK_F24, where are 13-24 is a mystery), but forgot to name characters. Actual characters have codes (0x41-0x5A), but don't have names like VK_A - VK_Z I was looking for in winuser.h header. JohnR |
To post a message in this thread, you need to log in with your Sierra Chart account: