Login Page - Create Account

Support Board


Date/Time: Thu, 23 Jan 2025 15:31:37 +0000



Post From: Problem with s_VolumeAtPriceV2 in latest versions of SC

[2018-11-18 16:21:21]
User517260 - Posts: 97
Dear support,

in latest version of SC 1842 64 bit I found my old code, used s_VolumeAtPriceV2 data, does not work as before. I also found - if I will apply on same chart "TPO Profile Chart" study and then remove it - my code sart works good. You may see it on short video https://youtu.be/xXgMzxWO39A . As I understand, TPO Profile Chart is uploading data into s_VolumeAtPriceV2 structure and that is why I can get this data after TPO study was applied. My code is following:

  int MaxVolume = 0;
  int Volume1TickOverPOC = 0;
  int Volume1TickUnderPOC = 0;
  float VolumePOCPrice = 0;
  int TotalAskVol = 0;
  int TotalBidVol = 0;
  
  s_VolumeAtPriceV2 *p_VolumeAtPriceAtIndex;
  int Count = sc.VolumeAtPriceForBars-> GetSizeAtBarIndex(sc.Index);
  for (int ElementIndex = Count-1;ElementIndex >= 0; ElementIndex --){
    sc.VolumeAtPriceForBars->GetVAPElementAtIndex(sc.Index, ElementIndex, &p_VolumeAtPriceAtIndex);
    if (p_VolumeAtPriceAtIndex){
      int AskVol = p_VolumeAtPriceAtIndex->AskVolume;
      int BidVol = p_VolumeAtPriceAtIndex->BidVolume;
      int NumOfTrades = p_VolumeAtPriceAtIndex->NumberOfTrades;
      float Price = p_VolumeAtPriceAtIndex->PriceInTicks * sc.TickSize;
      TotalAskVol = TotalAskVol + AskVol;
      TotalBidVol = TotalBidVol + BidVol;
      
      if(AskVol + BidVol > MaxVolume){
        MaxVolume = AskVol + BidVol;
        VolumePOCPrice = Price;

        if(ElementIndex < Count - 1){
          sc.VolumeAtPriceForBars->GetVAPElementAtIndex(sc.Index, ElementIndex + 1, &p_VolumeAtPriceAtIndex);
          AskVol = p_VolumeAtPriceAtIndex->AskVolume;
          BidVol = p_VolumeAtPriceAtIndex->BidVolume;
          Volume1TickOverPOC = AskVol + BidVol;
        }
        else Volume1TickOverPOC = 0;

        if(ElementIndex > 0){
          sc.VolumeAtPriceForBars->GetVAPElementAtIndex(sc.Index, ElementIndex - 1, &p_VolumeAtPriceAtIndex);
          AskVol = p_VolumeAtPriceAtIndex->AskVolume;
          BidVol = p_VolumeAtPriceAtIndex->BidVolume;
          Volume1TickUnderPOC = AskVol + BidVol;
        }
        else Volume1TickUnderPOC = 0;
      }
    }
  }
  
  POC_Sub[sc.Index]     = VolumePOCPrice;
  POCValue_Sub[sc.Index]   = (float)MaxVolume;
    
  float BARatio       = (float)(100*(TotalAskVol - TotalBidVol));    
  VolRatio_Sub[sc.Index]   = (float)BARatio/(TotalAskVol + TotalBidVol);


It was good before I updated SC. So, Could you tell me what I have to change in my code to get data from s_VolumeAtPriceV2 structure without TPO study appying before? Waiting for your reply as soon as possible, because it is a commercial project and customer is waiting for fixing of this bug. Thanks. Alex.