Login Page - Create Account

Support Board


Date/Time: Wed, 05 Mar 2025 18:31:07 +0000



[User Discussion] - Renko Chart Time for candle to complete

View Count: 621

[2022-01-13 15:33:51]
RRIO - Posts: 1
Is there anyway to see how long it takes for a Renko Bar to complete? Sometime it could be 2sec or 2 hours would like to incorporate it into my auto trading study.
Thanks
[2022-01-14 05:19:03]
Tony - Posts: 552
1, You have access to both open and close time of each bar, to access close time
sc.MaintainAdditionalChartDataArrays has to be true;

2, Each subgraph has 12 arrays can be used as any purpose, you can use one of them
to store duration of each bar, (maybe you could just use subgraph array, I am not sure)

Something like this:

SCSFExport scsf_YourStudyName(SCStudyInterfaceRef sc)
{

SCFloatArrayRef BarDuration = sc.Subgraph[0].Arrays[0];

if (sc.SetDefaults) {
//other of your codes
sc.MaintainAdditionalChartDataArrays = 1; // has to be 1, in order for sc.BaseDataEndDateTime to work
}

//other of your codes

for (int IndexCount=sc.Index; IndexCount>=0; IndexCount--){

SCDateTime DateTimeVariable;
DateTimeVariable = sc.BaseDataEndDateTime[IndexCount] - sc.BaseDateTimeIn[IndexCount];
BarDuration[IndexCount] = DateTimeVariable.GetTimeInSeconds();

}
}

To find out how long it takes in seconds for Renko Bar No.xxx to complete, for example:
is the value of BarDuration[xxx], Sorry, I haven't test it, but fairly confident that
direction will lead to the result you want
(2-sec duration bar has the value of 2.00 and 2-hour duration bar has the value 7200.00)

If you just want to know the duration of last bar only, then it would be much simpler,
you don't need an array, just sc.BaseDataEndDateTime[sc.Index] - sc.BaseDateTimeIn[sc.Index],
which I have tested and works.
Date Time Of Last Edit: 2022-01-14 05:39:44

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

Login

Login Page - Create Account