Support Board
Date/Time: Sat, 01 Mar 2025 03:56:32 +0000
Post From: Executing orders at bar close
[2020-12-19 15:07:49] |
User907968 - Posts: 833 |
I would greatly appreciate a response as to whether the above interpretation is correct.
This is explained here - ACSIL Interface Members - Functions: sc.GetBarHasClosedStatus()Specifically this paragraph: The very last bar in the chart is never considered a closed bar until there is a new bar added to the chart. It is not possible to know otherwise because of the following reasons: The chart bars are based upon a variable timeframe like Number of Trades or Volume and the ending can never be known until there is a new bar, or because there is not a trade at the very final second of a fixed time bar.
Is it possible to provide an explicit example?
You could try: n_ACSIL::s_BarPeriod barPeriod; sc.GetBarPeriodParameters(barPeriod); int barClosed = 0; if (barPeriod.ChartDataType == INTRADAY_DATA && barPeriod.IntradayChartBarPeriodType == IBPT_DAYS_MINS_SECS) { int secondsPerBar = barPeriod.IntradayChartBarPeriodParameter1; SCDateTime barDateTime = sc.BaseDateTimeIn[sc.Index]; barDateTime.AddSeconds(secondsPerBar); if (sc.GetCurrentDateTime() >= barDateTime) barClosed = 1; } if (barClosed) { /// do some stuff if the bar is closed } else { /// do some other stuff if the bar is not closed } |