Login Page - Create Account

Support Board


Date/Time: Tue, 24 Dec 2024 12:28:26 +0000



Post From: Recording and Referencing the Highest Bid and Ask Sizes

[2015-10-23 17:47:24]
User126996 - Posts: 30
I believe the issue I have encountered is that I'm using a SCFloatArray to record and reference my highest Bid/Ask Size variables. When I go to reference the Bid/Ask Sizes I'm using [sc.ArraySize] and comparing it to [sc.ArraySize - 1]. [sc.ArraySize - 1] references the previous high Bid/Ask of the previous candle or index. I would like to reference the previous high Bid/Ask on the current candle or index. How can I record and reference the previous High of the Bid/Ask Size on the current index, and compare them to consistently see which one is Higher bid or ask size? My code is below.



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];
SCFloatArray BigBid1;
  SCFloatArray BigAsk1;

float Max = sc.GetPersistentFloat(0);

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;
return;
  }


int& PriorIndex = sc.GetPersistentInt(1);

for (int Level = 0; Level < 5; Level++)
  {
    if (sc.ArraySize - 1 - 5 < 0)
      break;

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(BidSize, BigBid1, 5);
sc.Highest(AskSize, BigAsk1, 5);

if (BigBid1[sc.ArraySize] > BigAsk1[sc.ArraySize])
    {
      BigBid1[sc.ArraySize] = Max;
      Max = BidValue[sc.ArraySize - 1 - Level];
      DrawMax(sc, BidValue[sc.ArraySize - 1 - Level], Max);
    }

if (BigAsk1[sc.ArraySize] > BigBid1[sc.ArraySize])
    {
      BigAsk1[sc.Index] = Max;
      Max = AskValue[sc.ArraySize - 1 - Level];
      DrawMax(sc, AskValue[sc.ArraySize - 1 - Level], Max);
    }
}


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;

}