Login Page - Create Account

Support Board


Date/Time: Sun, 07 Sep 2025 18:55:19 +0000



[Programming Help] - Request for a new ACSIL function

View Count: 391

[2025-06-10 21:42:03]
Meklon - Posts: 247
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: 247
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: 247
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: 247
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: 247
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: 247
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: 771
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).

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

Login

Login Page - Create Account