Login Page - Create Account

Support Board


Date/Time: Sat, 30 Nov 2024 02:41:24 +0000



Post From: ACSIL Calculate Bar Duration in Seconds

[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