Login Page - Create Account

Support Board


Date/Time: Fri, 29 Mar 2024 01:12:16 +0000



Post From: ACSIL - A function that returns the Bar Period Type and Setting

[2017-11-27 12:17:08]
DabbaDo - Posts: 146
Not a very good solution, but I parse GetStudyName(0). See SCExtensions.h/SCExtension.cpp at my public Github at https://github.com/dalebrubaker/BruSierraChart

void GetContinuousContractAndBarsPeriodTypeCodes(SCStudyInterfaceRef sc, SCString& ccCode, SCString& barsPeriodType)
  {
    SCString thisName = sc.GetStudyName(0); // like ESM7 [CB] Flex Renko 32-31-1 #5 --but Continuous None gives no []
    std::vector<char*> tokens;
    thisName.Tokenize(" ", tokens);
   const SCString token0 = tokens[0];
    if (tokens.size() < 3
      || token0 != sc.Symbol)
    {
      ccCode = barsPeriodType = "INVALID";
      return;
    }
   const auto token1 = tokens[1];
    int barsPeriodStartIndex;
    if (token1[0] == '[')
    {
      ccCode = token1;
      barsPeriodStartIndex = 2;
    }
    else
    {
      ccCode = "[C0]";
      barsPeriodStartIndex = 1;
    }
    for (size_t i = barsPeriodStartIndex; i < tokens.size() - 2; i++)
    {
     const auto token = tokens[i];
      const int len = strlen(token);
      if (len > 0)
      {
        barsPeriodType += tokens[i];
      }
    }
  }