Login Page - Create Account

Support Board


Date/Time: Fri, 18 Oct 2024 06:16:23 +0000



Post From: Custom Study Trade DOM

[2024-07-22 12:10:51]
User357489 - Posts: 68
EDIT: done it :)

for anyone that wants to see what i was doing, here you are! :) enjoy do with it what you will
#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;
}

/*==========================================================================*/
// This is the actual drawing function. This function is specified by the
// "sc.p_GDIFunction" member in the main study function above. This drawing
// function is called when Sierra Chart draws the study on the chart.

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 pulling/stacking
if (sc.GetAskMarketDepthEntryAtLevel(depthEntry, level))
{
double pullingStackingAsk = sc.GetAskMarketDepthStackPullValueAtPrice(depthEntry.Price);

if (pullingStackingAsk >= 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(depthEntry.Price, 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 pulling/stacking
if (sc.GetBidMarketDepthEntryAtLevel(depthEntry, level))
{
double pullingStackingBid = sc.GetBidMarketDepthStackPullValueAtPrice(depthEntry.Price);

if (pullingStackingBid >= 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(depthEntry.Price, 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);
}
}
}
}