Login Page - Create Account

Support Board


Date/Time: Sun, 24 Nov 2024 00:56:38 +0000



Post From: DOM Totals Questions

[2024-07-19 11:50:35]
User357489 - Posts: 72
Hi there

I want to create a study for the Trade Dom, whereby prices in the price column are highlighted where pulling/stacking column volume is >=100 on both Bid pull/stack and Ask pull/stack.
#include "sierrachart.h"

SCDLLName("Custom DOM Study");

// Define the study function
SCSFExport scsf_CustomDOMStudy(SCStudyInterfaceRef sc)
{
// Initialization
if (sc.SetDefaults)
{
sc.GraphName = "Custom DOM Highlighting Study";
sc.StudyDescription = "Highlights prices in the DOM based on bid/ask volume conditions in pulling/stacking columns.";
sc.AutoLoop = 1; // Auto-loop enabled

// Define subgraphs for bid and ask highlights
sc.Subgraph[0].Name = "Bid Highlighted Prices";
sc.Subgraph[0].PrimaryColor = RGB(0, 255, 0); // Green for bid
sc.Subgraph[0].DrawStyle = DRAWSTYLE_TEXT; // Use DRAWSTYLE_TEXT to color text
sc.Subgraph[0].LineWidth = 2;

sc.Subgraph[1].Name = "Ask Highlighted Prices";
sc.Subgraph[1].PrimaryColor = RGB(255, 0, 0); // Red for ask
sc.Subgraph[1].DrawStyle = DRAWSTYLE_TEXT; // Use DRAWSTYLE_TEXT to color text
sc.Subgraph[1].LineWidth = 2;

// Input for volume threshold
sc.Input[0].Name = "Volume Threshold";
sc.Input[0].SetInt(100); // Default threshold value

// Input for number of levels to consider
sc.Input[1].Name = "Number of Levels";
sc.Input[1].SetInt(5); // Default number of levels

return;
}

// Main calculation
int threshold = sc.Input[0].GetInt();
int numLevels = sc.Input[1].GetInt();

// Ensure we have market depth data
if (sc.UpdateStartIndex == 0)
{
// Initialize the subgraph to default values
for (int i = 0; i < sc.ArraySize; ++i)
{
sc.Subgraph[0][i] = 0.0;
sc.Subgraph[1][i] = 0.0;
}
}

s_MarketDepthEntry depthEntry;

// Loop through market depth data for ask and bid sides
for (int level = 0; level < numLevels; ++level)
{
// Ask side
if (sc.GetAskMarketDepthEntryAtLevel(depthEntry, level))
{
int askVolume = depthEntry.Quantity;
float askPrice = depthEntry.Price;

// Check if ask volume is greater than or equal to threshold
if (askVolume >= threshold)
{
// Highlight ask price in the subgraph
for (int i = sc.UpdateStartIndex; i < sc.ArraySize; ++i)
{
if (sc.BaseData[SC_LAST][i] == askPrice)
{
sc.Subgraph[1][i] = askPrice; // Highlight ask price
}
}
}
}

// Bid side
if (sc.GetBidMarketDepthEntryAtLevel(depthEntry, level))
{
int bidVolume = depthEntry.Quantity;
float bidPrice = depthEntry.Price;

// Check if bid volume is greater than or equal to threshold
if (bidVolume >= threshold)
{
// Highlight bid price in the subgraph
for (int i = sc.UpdateStartIndex; i < sc.ArraySize; ++i)
{
if (sc.BaseData[SC_LAST][i] == bidPrice)
{
sc.Subgraph[0][i] = bidPrice; // Highlight bid price
}
}
}
}
}
}

Please see above my current attempt, with some screenshots of the current state of affairs.

I wondered if someone could help me as I'm at a loss as to how I make it function lol

Thank you in advance to anyone
imageimage.png / V - Attached On 2024-07-19 11:48:13 UTC - Size: 33.54 KB - 42 views
imageimage.png / V - Attached On 2024-07-19 11:48:26 UTC - Size: 48.9 KB - 36 views
Attachment Deleted.