Login Page - Create Account

Support Board


Date/Time: Sun, 25 May 2025 01:00:29 +0000



Post From: VbP study request

[2023-07-02 13:42:18]
ertrader - Posts: 684
Here is the study. It works and returns correct values. However, it's performance is about 70-100ms on an NQ chart with a 60 minute VbP study applied.

Do you have any suggestions on ways to improve performance?

PositiveDeltaSum and NegativeDeltaSum are not available within the GetStudyProfileInformation function so they have to be summed from:
ACSIL Interface Members - Functions: sc.GetVolumeAtPriceDataForStudyProfile()


#include "sierrachart.h"

SCDLLName("VatPriceDataV3")
SCSFExport scsf_VatPriceDataV3(SCStudyInterfaceRef sc)
{
  SCSubgraphRef PositiveDeltaSum      = sc.Subgraph[0];  
  SCSubgraphRef NegativeDeltaSum      = sc.Subgraph[1];  

  SCInputRef INStudyID           = sc.Input[0];


  if (sc.SetDefaults)
  {
    // Set the configuration and defaults

    sc.GraphName = "VbP Delta Sum V3";

    sc.AutoLoop = true;
    sc.GraphRegion = 1;

    INStudyID.Name="Study ID";
    INStudyID.SetInt(0);
    INStudyID.SetIntLimits(0,10000);  

    PositiveDeltaSum.Name = "Positive Delta Sum";
    PositiveDeltaSum.DrawStyle = DRAWSTYLE_IGNORE;
    PositiveDeltaSum.LineWidth = 2;    

    NegativeDeltaSum.Name = "Negative Delta Sum";
    NegativeDeltaSum.DrawStyle = DRAWSTYLE_IGNORE;
    NegativeDeltaSum.LineWidth = 2;      

    return;
  }
  
  const int StudyID             = INStudyID.GetInt();
  int PricesCount = sc.GetNumPriceLevelsForStudyProfile(StudyID, 0);

  int PositiveDeltaSumValue, NegativeDeltaSumValue;

  SCFloatArrayRef BidVolume      = sc.Subgraph[1].Arrays[0];  
  SCFloatArrayRef AskVolume      = sc.Subgraph[1].Arrays[1];    
  SCFloatArrayRef AskBidDelta      = sc.Subgraph[1].Arrays[2];      

  for (int PriceIndex = 0; PriceIndex < PricesCount; PriceIndex++)
  {

    s_VolumeAtPriceV2 VolumeAtPrice;

    int Result = sc.GetVolumeAtPriceDataForStudyProfile
    (StudyID
      , 0
      , PriceIndex
      , VolumeAtPrice
    );
    
    if(PriceIndex ==0)
    {
      PositiveDeltaSumValue = 0;
      NegativeDeltaSumValue = 0;
    }      

    BidVolume[PriceIndex] = VolumeAtPrice.BidVolume;
    AskVolume[PriceIndex] = VolumeAtPrice.AskVolume;  
    AskBidDelta[PriceIndex] = AskVolume[PriceIndex] - BidVolume[PriceIndex];
    
    if(AskBidDelta[PriceIndex]>0) PositiveDeltaSumValue = PositiveDeltaSumValue + AskBidDelta[PriceIndex];
    else NegativeDeltaSumValue = NegativeDeltaSumValue + AskBidDelta[PriceIndex];    

  }

    PositiveDeltaSum[sc.Index] = PositiveDeltaSumValue;
    NegativeDeltaSum[sc.Index] = NegativeDeltaSumValue;  
}

Date Time Of Last Edit: 2023-07-04 17:15:39