Login Page - Create Account

Support Board


Date/Time: Sun, 24 Nov 2024 01:07:36 +0000



Post From: Custom Study Trade DOM

[2024-07-22 11:58:01]
User357489 - Posts: 72
Hi again,

after some more messing around and using the advice above; i have (almost) got what i wanted.
#include "sierrachart.h"

SCDLLName("Custom DOM Study")

/*==========================================================================*/
// Drawing function declaration
void DrawToChart(HWND WindowHandle, HDC DeviceContext, SCStudyInterfaceRef sc);

/*==========================================================================*/
SCSFExport scsf_CustomDOMStudy(SCStudyInterfaceRef sc)
{
if (sc.SetDefaults)
{
// Set the configuration and defaults
sc.GraphName = "Custom DOM Highlighting Study";
sc.GraphRegion = 0;

sc.AutoLoop = 0; // Auto-loop disabled

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

// Ensure the drawing function is called
sc.p_GDIFunction = DrawToChart;
}


void DrawToChart(HWND WindowHandle, HDC DeviceContext, SCStudyInterfaceRef sc)
{
int threshold = sc.Input[0].GetInt();
int numLevels = sc.Input[1].GetInt();
s_MarketDepthEntry depthEntry;

for (int level = 0; level < numLevels; ++level)
{
// Ask side
if (sc.GetAskMarketDepthEntryAtLevel(depthEntry, level))
{
int askVolume = depthEntry.Quantity;
float askPrice = depthEntry.Price;

if (askVolume >= threshold)
{
// Set the drawing color to red for ask
n_ACSIL::s_GraphicsColor color;
color.SetRGB(255, 0, 0);

RECT rect;
int yPixelCoordinate = sc.RegionValueToYPixelCoordinate(askPrice, 0);
SetRect(&rect, sc.StudyRegionLeftCoordinate, yPixelCoordinate - 5, sc.StudyRegionRightCoordinate, yPixelCoordinate + 5);

HBRUSH brush = CreateSolidBrush(RGB(255, 200, 200)); // Light red for ask
FillRect(DeviceContext, &rect, brush);
DeleteObject(brush);
}
}

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

if (bidVolume >= threshold)
{
// Set the drawing color to green for bid
n_ACSIL::s_GraphicsColor color;
color.SetRGB(0, 255, 0);

RECT rect;
int yPixelCoordinate = sc.RegionValueToYPixelCoordinate(bidPrice, 0);
SetRect(&rect, sc.StudyRegionLeftCoordinate, yPixelCoordinate - 5, sc.StudyRegionRightCoordinate, yPixelCoordinate + 5);

HBRUSH brush = CreateSolidBrush(RGB(200, 255, 200)); // Light green for bid
FillRect(DeviceContext, &rect, brush);
DeleteObject(brush);
}
}
}
}
please see attached the outcome; instead of highlight the price column, it highlight the column to the left if it (which i can live with) and attached and crudely outlined is the result, i set the levels to 30 and the volume threshold to 100 to test, however it seems that the code is using data from the buy/ sell column as opposed to the bid/ ask pulling/ stacking columns specifically. My difficulty is substituting the depth columns for the pulling/stacking columns data. Hope this has made sense and thank you in advance.
imagedom.png / V - Attached On 2024-07-22 11:57:54 UTC - Size: 94.24 KB - 118 views