Login Page - Create Account

Support Board


Date/Time: Sat, 01 Mar 2025 06:55:06 +0000



Post From: Volume By Price access to data

[2021-09-19 21:34:36]
ertrader - Posts: 681
Success at last.... this version compiles and retains correct values. SC, can you please indicate if this is how you are expecting this function to be properly coded?

#include "sierrachart.h"

SCDLLName("VBPData")

SCSFExport scsf_VolumeByPriceData(SCStudyInterfaceRef sc)
{
  SCSubgraphRef Subgraph_Volume       = sc.Subgraph[0];
  SCSubgraphRef Subgraph_BidVolume     = sc.Subgraph[1];
  SCSubgraphRef Subgraph_AskVolume     = sc.Subgraph[2];  

  SCInputRef INStudyID           = sc.Input[0];
  SCInputRef INProfileIndex        = sc.Input[1];

  if (sc.SetDefaults)
  {
    // Set the configuration and defaults
    sc.GraphName = "Volume By Price Data";
    sc.StudyDescription = "This obtains data from Volume By Price";
    sc.AutoLoop = true;
    sc.MaintainVolumeAtPriceData = 1; // true
    
    Subgraph_Volume.Name = "Volume";
    Subgraph_Volume.DrawStyle = DRAWSTYLE_IGNORE;
    Subgraph_Volume.LineWidth = 2;
    
    Subgraph_BidVolume.Name = "Bid Volume";
    Subgraph_BidVolume.DrawStyle = DRAWSTYLE_IGNORE;
    Subgraph_BidVolume.LineWidth = 2;

    Subgraph_AskVolume.Name = "Ask Volume";
    Subgraph_AskVolume.DrawStyle = DRAWSTYLE_IGNORE;
    Subgraph_AskVolume.LineWidth = 2;    

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

    INProfileIndex.Name="Profile Index";
    INProfileIndex.SetInt(0);
    INProfileIndex.SetIntLimits(0,10000);      
    
    return;
  }

  // Do data processing
  const int StudyID             = INStudyID.GetInt();  
  const int ProfileIndex           = INProfileIndex.GetInt();  
  int Volume, BidVolume, AskVolume;
  
  n_ACSIL::s_StudyProfileInformation StudyProfileInformation;
  if(sc.GetStudyProfileInformation(StudyID, ProfileIndex, StudyProfileInformation))    
  {
    Volume = StudyProfileInformation.m_Volume;
    BidVolume = StudyProfileInformation.m_BidVolume;
    AskVolume = StudyProfileInformation.m_AskVolume;
    Subgraph_Volume[sc.Index] = Volume;
    Subgraph_BidVolume[sc.Index] = BidVolume;
    Subgraph_AskVolume[sc.Index] = AskVolume;    
  }  
}

Date Time Of Last Edit: 2021-09-19 21:40:42