Login Page - Create Account

Support Board


Date/Time: Sat, 10 May 2025 17:07:20 +0000



Bar Range Function

View Count: 1302

[2016-01-15 15:52:00]
Johnny - Posts: 99
Hi, is there an ACSIL function that calculates the maximum/minimum bar range over a specified number of bars?
[2016-01-15 17:30:46]
Sierra Chart Engineering - Posts: 104368
Not that we can think of. But this is easy enough for you to calculate.
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
[2016-01-15 19:14:03]
Johnny - Posts: 99
I have tried to create my own function for this but I get the error: a function-definition is not allowed here before '{' token.
[2016-01-15 19:21:46]
Sierra Chart Engineering - Posts: 104368
Obviously this is meaningless to us without actually seeing the code.
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
[2016-01-15 20:08:31]
Johnny - Posts: 99
Here's the code:

int Index = sc.Index;
SCFloatArrayRef High = sc.High;
SCFloatArrayRef Low = sc.Low;


float MaxBarRange(int NumberOfBars, int Shift)
{
if(Shift <= Index)
{
MaxValue = High[Index - Shift] - Low[Index - Shift];

for(int i = Index - Shift - 1; i >= 0 && i > Index - Shift - NumberOfBars; i--)
{
if(High - Low > MaxValue) MaxValue = High - Low;
}

return MaxValue;
}
}


I also get the error: expected '}' at end of input.

[2016-01-15 20:34:19]
Sierra Chart Engineering - Posts: 104368
This code seems fine:
  float MaxBarRange(int NumberOfBars, int Shift)
  {
    if(Shift <= Index)
    {
      MaxValue = High[Index - Shift] - Low[Index - Shift];

      for(int i = Index - Shift - 1; i >= 0 && i > Index - Shift - NumberOfBars; i--)
      {
        if(High - Low > MaxValue)
          MaxValue = High - Low;
      }

      return MaxValue;
    }
  }

Therefore, just make sure that it is located above the function where it is being called from and we would not expect there to be a compiler error.
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

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

Login

Login Page - Create Account