Login Page - Create Account

Support Board


Date/Time: Mon, 24 Feb 2025 15:27:02 +0000



Post From: Accessing Cumulative Volume at Peak/Valley in a VbP Study

[2021-03-11 22:39:09]
User99735 - Posts: 234
This is the code used. Returns volume which does not match with what is displayed on chart.


int GetVolumeAtPriceForProfile(SCStudyGraphRef sc, int chartID, int studyID, float inPrice, unsigned int& volAtPrice)
{
  float price;
  int peakValleyType = 0;
  int startIndex = 0;
  int peakValleyExtensionChartColumnEndIndex = 0;
  int profileIndex = 0;
  int peakValleyIndex = 0;
  int result = 1;
  int resultVol = 1;
  int error = 0;
  s_VolumeAtPriceV2 volumeAtPriceV2;

  volAtPrice = 0;
  while (result)
  {
    if (sc.GetNumPriceLevelsForStudyProfile(studyID, profileIndex) == 0)
    {
      profileIndex++;
      if (profileIndex > startIndex)
        break;
      continue;
    }

    price = 0;
    result = sc.GetStudyPeakValleyLine(chartID, studyID, price, peakValleyType, startIndex, peakValleyExtensionChartColumnEndIndex, profileIndex, peakValleyIndex);

    if (!result)
      break;

    if (result && (price == inPrice))
    {
      resultVol = sc.GetVolumeAtPriceDataForStudyProfile(studyID, profileIndex, peakValleyIndex, volumeAtPriceV2);
      sc.AddMessageToLog(SCString().Format("Volume %i, Profile Index %i, startIndex %i, peakValleyExtensionChartColumnEndIndex %i, peakValleyIndex %i, Price Level Count %i, price %f, inPrice %f",
        volumeAtPriceV2.Volume, profileIndex, startIndex, peakValleyExtensionChartColumnEndIndex, peakValleyIndex, sc.GetNumPriceLevelsForStudyProfile(studyID, profileIndex), price, inPrice), 0);

      profileIndex++;
      peakValleyIndex = -1;
      if (resultVol)
      {
        error = 1;
        volAtPrice += volumeAtPriceV2.Volume;
      }
      //else
      //  return error;

      //continue;
    }

    peakValleyIndex++;
  }

  return error;
}