Login Page - Create Account

Support Board


Date/Time: Mon, 08 Sep 2025 16:13:44 +0000



[Programming Help] - Request for a new ACSIL function

View Count: 442

[2025-06-10 21:42:03]
Meklon - Posts: 248
Dear Support,

I would like to ask if it would be possible to add a new ACSIL function to your already extended and available list.

Specifically, I would like to get the Bar Has Closed status from a remote chart.

i.e.: int GetBarHasClosedStatusFromChart(int ChartNumber, int BarIndex);

This would be very useful and quite helpful in development of a custom studies which reference remote charts and need to make a logic decision based on the status of the closed current bar of the remote chart.

Much appreciate it in advance.
Date Time Of Last Edit: 2025-06-10 21:42:45
[2025-06-11 12:16:05]
JohnR - User831573 - Posts: 333
This might work.

In the remote chart, do the check for bar has closed. If yes, set a persistent variable.
Then in this chart something like this - int g_RemoteBarClosed = sc.GetPersistentIntFromChartStudy(sc.ChartNumber,2,1) ;

I have not done this, but saw it in another post. Reading Persistent variable in other study

JohnR
[2025-06-11 14:58:29]
Meklon - Posts: 248
JohnR - thank you, this may work as a workaround, but will still require a study on the remote chart to be referenced (not very efficient and adding another layer). What would be really effective is to have an ACSIL function that would be possible to call directly from the code and just receive the status.
Date Time Of Last Edit: 2025-06-11 14:59:39
[2025-06-11 18:59:16]
User719512 - Posts: 321
Your question implies the remote chart is running on a different timeframe than your main chart otherwise you'd already have the answer since the bar index would be the same.

So for your question about "GetBarHasClosedStatusFromChart", what bar index value would you be passing to this function?
How would you know what index to use without calling some API to know the number of bars in the remote chart/etc?

I would think some combination of GetStudyArrayFromChart() and ArraySize() and/or mapping a DateTime form the main chart to bars on the remote chart/etc would be in order.

Reference:
ACSIL Interface Members - Functions: sc.GetStudyArrayFromChart()
[2025-06-11 20:05:17]
Meklon - Posts: 248
I am only interested in the status of the very last bar on remote chart (has it closed or still developing) so I can compare it to the LastBar(-1).
Date Time Of Last Edit: 2025-06-11 20:17:25
[2025-06-11 20:25:39]
User719512 - Posts: 321
Have you looked at this from sierrachart.h?


  int GetBarHasClosedStatus(int BarIndex)
  {
    if (SetDefaults)
      return BHCS_SET_DEFAULTS;

    if (BarIndex != ArraySize - 1)
      return BHCS_BAR_HAS_CLOSED;
    else
      return BHCS_BAR_HAS_NOT_CLOSED;
  }

The last bar on the chart will never be closed. Why? Because you don't know a bar is closed until a new one opens.

Post #4 has all the info to get started on this and get the bars from the other chart, keep track of the ArraySize (last BarIndex you've processed) and when the index grows/etc.
Date Time Of Last Edit: 2025-06-11 20:27:35
[2025-06-11 22:24:42]
Meklon - Posts: 248
User719512 - I am attempting to monitor a real-time status of the currently developing bar on the remote chart and capture the exact moment it closes to determine if the trend is continuing by comparing HLOC as well as other values (i.e. Renko) to the bar before that. What you referring to in the header code provides a static status of the prior bar, not the currently developing bar. Am I missing something?
[2025-09-06 21:18:30]
OctoPi - Posts: 45
I am only interested in the status of the very last bar on remote chart (has it closed or still developing) so I can compare it to the LastBar(-1).

Flawed logic there. Once the bar has closed, it is already a bar -1. Can't have a status of a current bar that is both still open and has already closed.


Based on your last message though, you would need to trigger your logic based on bar INDEX since entry, and eval bar -1 once that index increments since your trade open.
[2025-09-06 21:47:12]
Meklon - Posts: 248
Flawed logic there. Once the bar has closed, it is already a bar -1. Can't have a status of a current bar that is both still open and has already closed.


Based on your last message though, you would need to trigger your logic based on bar INDEX since entry, and eval bar -1 once that index increments since your trade open.

Thank you for your comment, but in this particular case the reference of interest is for RENKO bar, not a standard bar. Renko Open, Close other stats are different from the regulars bar.
[2025-09-06 21:58:42]
OctoPi - Posts: 45
You can still use index counter to track if bar is closed, right?
[2025-09-06 22:01:47]
Meklon - Posts: 248
Yes, but the critical question is to pinpoint the exact moment when the bar has closed, not just the status (Open / Closed) of it. The challenge is that it a status of the bar on the REMOTE chart.
Date Time Of Last Edit: 2025-09-06 22:05:27
[2025-09-07 10:46:51]
User431178 - Posts: 772
but the critical question is to pinpoint the exact moment when the bar has closed

You can't know the "exact moment", that would require the charts to be updating on each and every tick, rather than on a timer based update.
You can know whether a bar was open on one update and then closed on the next, which is why people are suggesting tracking the index (or the other chart array size).

The fact that the chart is remote doesn't really have much bearing on the situation, the method for determining open vs. closed is the same, as is the exactness of determining when the bar closed i.e. you can detect that the state has changed, but not the exact moment that the change occurred (just some time in the last x ms).
[2025-09-07 20:51:49]
Meklon - Posts: 248
You can't know the "exact moment", that would require the charts to be updating on each and every tick, rather than on a timer based update.
You can know whether a bar was open on one update and then closed on the next, which is why people are suggesting tracking the index (or the other chart array size).

The fact that the chart is remote doesn't really have much bearing on the situation, the method for determining open vs. closed is the same, as is the exactness of determining when the bar closed i.e. you can detect that the state has changed, but not the exact moment that the change occurred (just some time in the last x ms).

There is more involved here with respect to my original request than simply determining if the bar is closed or open. Obtaining this status from the remote chart compared to the same chart where the custom study running is entirely different and there is a delay, which is critically impacting the strategy (especially in the case when Renko bar type is involved). The remote chart runs the higher time frame (not necessary time interval) compared to the execution (local) chart with a custom study and the delay in obtaining the close / open bar status from the remote chart is significantly impacting the lead time for the execution instructions on the local chart. I need to be able to obtain the status of open / close bar on the remote chart and use that status as one of the variables in additional calculation on the same remote chart. So far, this functionality is only available on the local chart, NOT on remote. Hence is my original request to add the similar ACSIL function so I could do this on the remote chart.
Date Time Of Last Edit: 2025-09-07 20:52:58
[2025-09-07 21:33:48]
User431178 - Posts: 772
Yes, maybe an acsil function would be easier, but like someone said before, what index are you using?
Calling such a function on the last bar in the remote chart will never signal closed bar, as the bar is not considered closed until a new one is added. Which brings us back to the index/array size tracking mentioned earlier in the thread, i.e. the same way that GetBarHasClosedStatus works on the local chart.

If there is a delay in obtaining the open/close status from another chart, then whatever method you have created for doing so is probably flawed.

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account