Support Board
Date/Time: Sat, 30 Nov 2024 02:37:30 +0000
[Programming Help] - ACSIL Calculate Bar Duration in Seconds
View Count: 622
[2022-12-30 07:11:46] |
TriStar Trading - Posts: 142 |
Can anyone help with ACSIL code to calculate the duration of the current price bar in seconds? I'm using range bars. Thanks in advance, Mike
|
[2022-12-30 12:33:14] |
User431178 - Posts: 545 |
Take a look at sc.BaseDataEndDateTime and SCDateTimeSpan (in scdatetime.h). ACSIL Interface Members - Variables and Arrays: sc.BaseDataEndDateTime[] There is also the SCDateTime member function GetTimeInSeconds, so you could compare the start time in seconds vs. end time in seconds. Working with the SCDateTime Variables and Values: GetTimeInSeconds() |
[2022-12-31 18:57:41] |
TriStar Trading - Posts: 142 |
Here is how I did it after stealing some code here and there. :) Thanks. //Set the configuration variables and defaults. SCSubgraphRef BarSeconds = sc.Subgraph[0]; if (sc.SetDefaults) { //Set the configuration and defaults sc.GraphName = "Bar Duration In Seconds; sc.GraphRegion = 1; //Not Main graph region sc.AutoLoop = 1; sc.ValueFormat = 0; //Define the Subgraphs BarSeconds.Name = "Bar Seconds"; BarSeconds.DrawStyle = DRAWSTYLE_BAR; BarSeconds.LineWidth = 2; BarSeconds.PrimaryColor = RGB(128,128,128); return; } SCDateTimeMS BarEndDateTime = sc.GetEndingDateTimeForBarIndex(sc.Index); SCDateTimeMS ElapsedTime = static_cast<float>((BarEndDateTime - sc.BaseDateTimeIn[sc.Index] + SCDateTime::MICROSECONDS(1)).GetAsDouble()); BarSeconds[sc.Index] = ElapsedTime.GetTimeInSeconds(); Date Time Of Last Edit: 2022-12-31 18:58:30
|
[2023-01-01 01:14:34] |
User183724 - Posts: 183 |
thx for posting this
|
To post a message in this thread, you need to log in with your Sierra Chart account: