Login Page - Create Account

Support Board


Date/Time: Sat, 10 May 2025 03:46:10 +0000



[User Discussion] - Finding the Highest Number from a Subgraph

View Count: 1043

[2015-10-22 20:35:12]
User126996 - Posts: 30
I'm trying to find the highest BidSize from the first 5 levels of the DOM. Here is my code. It won't seem to work.



SCSFExport scsf_DepthOfMarketData(SCStudyInterfaceRef sc)
{
SCSubgraphRef BidValue = sc.Subgraph[0];
SCSubgraphRef AskValue = sc.Subgraph[1];
SCSubgraphRef BidSize = sc.Subgraph[2];
SCSubgraphRef AskSize = sc.Subgraph[3];

SCSubgraphRef BigBid1 = sc.Subgraph[4];


if (sc.SetDefaults)
  {
sc.GraphName = "Depth of Market Data";
    sc.FreeDLL = 1;
    sc.StudyDescription = "This is a study to display current market depth data. When adding this study, also add the Spreadsheet study to your chart to view the market depth data in a table form on the spreadsheet.";
    sc.GraphRegion = 0;
    sc.UsesMarketDepthData = 1;
    sc.AutoLoop = 1;

BigBid1.Name = "BigBid1";
    BigBid1.DrawStyle = DRAWSTYLE_LINE;
    BigBid1.PrimaryColor = COLOR_HOTPINK;
    BigBid1.DrawZeros = false;

return;
  }

int& PriorIndex = sc.GetPersistentInt(1);

/**********************************************************************
Start - DOM Calculation
*/
for (int Level = 0; Level < 5; Level++)
  {
    if (sc.ArraySize - 1 - 5 < 0)
      brea
    BidSize[sc.ArraySize - 1 - Level] = (float)sc.SymbolData->BidDOM[Level].Volume;
    BidValue[sc.ArraySize - 1 - Level] = (float)sc.SymbolData->BidDOM[Level].Price;
    AskValue[sc.ArraySize - 1 - Level] = (float)sc.SymbolData->AskDOM[Level].Price;
    AskSize[sc.ArraySize - 1 - Level] = (float)sc.SymbolData->AskDOM[Level].Volume;

sc.Highest(BigBid1, BidSize, Level); // Find the Highest BidSize of the first 5 Levels

}
/* End - DOM Calculation
*****************************************************************************************************/


int LastIndex = sc.ArraySize - 1 - MAX_NUM_DOM_LEVELS;

  sc.EarliestUpdateSubgraphDataArrayIndex = LastIndex;

  if (PriorIndex < LastIndex)
  {
    for (int ClearIndex = LastIndex; ClearIndex >= PriorIndex; ClearIndex--)
    {
      
      BidValue[ClearIndex] = 0;
      AskValue[ClearIndex] = 0;
      BidSize[ClearIndex] = 0;

      

    }
  }


PriorIndex = (LastIndex >= 0) ? LastIndex : 0;



  
  
}


Any thoughts?
[2015-10-22 20:37:20]
User126996 - Posts: 30
The

break;

is properly written in my code. Just a copy and paste error. The study builds and loads but the BidSize for sc.Highest is 0.0.
[2015-10-22 23:11:47]
User126996 - Posts: 30
I figure it out. Here is the correct code.

sc.Highest(BidSize, BigBid1, 5);

The out and In reference subgraphs were reversed.

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account