Login Page - Create Account

Support Board


Date/Time: Wed, 24 Apr 2024 20:21:23 +0000



[Programming Help] - Question about how sc.GetBarHasClosedStatus() works

View Count: 1477

[2017-07-21 20:21:58]
CustomIndicators - Posts: 126
In order to optimize performance in my custom study, I'm trying to use sc.GetBarHasClosedStatus() in order to only check if a pivot point has locked on a subgraph once a candle closes.

For example:


if (sc.GetBarHasClosedStatus(sc.UpdateStartIndex) == BHCS_BAR_HAS_CLOSED)
{

if (OSC[sc.Index - 3] < OSC[sc.Index - 2] && OSC[sc.Index - 2] > OSC[sc.Index - 1]) // Locked Pivot
{
// Draws a dot on the subgraph in order to show me that it has found the pivot at OSC[sc.Index - 2].
}

}

Before using sc.GetBarHasClosedStatus(), dots appear where the pivot points are on my chart. After putting in the if statement with the sc.GetBarHasClosedStatus(), I'm lucky if it finds 1 pivot when I can clearly see 20+ go by on the chart.

I've tried using sc.UpdateStartIndex in the parameter, and not using it. Both don't work the way I intend.

Perhaps I'm miss-understanding how sc.GetBarHasClosedStatus() works? Does it return BHCS_BAR_HAS_CLOSED once the current candle locks and becomes sc.Index - 1?
Date Time Of Last Edit: 2017-07-21 20:22:20
[2017-07-21 20:54:49]
Sierra Chart Engineering - Posts: 104368
Does it return BHCS_BAR_HAS_CLOSED once the current candle locks and becomes sc.Index - 1?
Yes.

You should not use sc.UpdateStartIndex in the way that you are. Does the study use automatic looping?
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2017-07-21 21:51:18]
CustomIndicators - Posts: 126
Yes, my study does use automatic looping.

I wasn't sure if I should use sc.UpdateStartIndex or not, even after reading the documentation on that a few times. I assume from your comment, its only needed in manual looping?

I've recompiled and added the version to the chart not using sc.UpdateStartIndex. It still isn't finding my pivot points. Any idea why? The only thing different, is having my pivot point finding if statements inside an if statement checking for the end of the bar.
[2017-07-21 23:56:36]
Sierra Chart Engineering - Posts: 104368
Even with manual looping the way that you are using sc.UpdateStartIndex does not make sense. It simply does not make sense to use it with this function.

For automatic looping use:
sc.GetBarHasClosedStatus()
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2017-07-22 00:20:21]
CustomIndicators - Posts: 126
As I was trying to say in my last post, sc.UpdateStartIndex has been removed from my code. I'm not using it anymore.

I an attempt to get my code finding pivot points, I did change the if statement to:

if (sc.GetBarHasClosedStatus() == BHCS_BAR_HAS_NOT_CLOSED)

Interestingly, when I went to apply the study to the charts (16 linked charts with study linking selected), they loaded onto the charts much faster then when I didn't use this if statement at all. It usually freezes SierraChart for a good 1-2 minutes while applying the studies to each chart. When using BHCS_BAR_HAS_NOT_CLOSED, all studies were applied successfully within 5 seconds. Perhaps you have BHCS_BAR_HAS_CLOSED and BHCS_BAR_HAS_NOT_CLOSED switched around? I expected their effects to be completely reversed due to their names, but using BHCS_BAR_HAS_NOT_CLOSED in my if statement, I've gotten a massive performance boost over all. With this change, I'm finding all pivot points successfully in backtests.

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

Login

Login Page - Create Account