Login Page - Create Account

Support Board


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



Post From: Custom Study Trade DOM

[2024-07-22 13:35:02]
User357489 - Posts: 68
Thanks again!

I also wanted to calculate the active range, if you like, ie the lowest ask price thats highlighted minus highest bid price highlighted- as well as a calc that gives a sort of tethered % of bid vs ask orders,
// Calculate the bid and ask stacked sums
double bidStackedSum = sc.GetBidMarketDepthStackPullSum();
double askStackedSum = sc.GetAskMarketDepthStackPullSum();

if (bidStackedSum + askStackedSum > 0) // Ensure there is no division by zero
{
double bidPercentage = (bidStackedSum / (bidStackedSum + askStackedSum)) * 100;
double askPercentage = (askStackedSum / (bidStackedSum + askStackedSum)) * 100;

// Display the percentage information

// Display B% anchored to the highest bid price
SCString bidPercentageText;
bidPercentageText.Format("B%%: %.2f%%", bidPercentage);

s_UseTool bidPercentageTool;
bidPercentageTool.Clear();
bidPercentageTool.ChartNumber = sc.ChartNumber;
bidPercentageTool.DrawingType = DRAWING_TEXT;
bidPercentageTool.AddAsUserDrawnDrawing = 1;
bidPercentageTool.BeginDateTime = sc.BaseDateTimeIn[sc.ArraySize - 1];
bidPercentageTool.BeginValue = highestBidPrice; // Position the text at the highest bid price
bidPercentageTool.Color = RGB(255, 255, 255); // White text
bidPercentageTool.Text = bidPercentageText;
bidPercentageTool.FontSize = 12;
bidPercentageTool.LineNumber = 1; // Unique identifier for updating
bidPercentageTool.AddMethod = UTAM_ADD_OR_ADJUST;

sc.UseTool(bidPercentageTool);

// Display S% anchored to the lowest ask price
SCString askPercentageText;
askPercentageText.Format("S%%: %.2f%%", askPercentage);

s_UseTool askPercentageTool;
askPercentageTool.Clear();
askPercentageTool.ChartNumber = sc.ChartNumber;
askPercentageTool.DrawingType = DRAWING_TEXT;
askPercentageTool.AddAsUserDrawnDrawing = 1;
askPercentageTool.BeginDateTime = sc.BaseDateTimeIn[sc.ArraySize - 1];
askPercentageTool.BeginValue = lowestAskPrice; // Position the text at the lowest ask price
askPercentageTool.Color = RGB(255, 255, 255); // White text
askPercentageTool.Text = askPercentageText;
askPercentageTool.FontSize = 12;
askPercentageTool.LineNumber = 2; // Unique identifier for updating
askPercentageTool.AddMethod = UTAM_ADD_OR_ADJUST;

sc.UseTool(askPercentageTool);
}

// Calculate and display the range
if (lowestAskPrice != FLT_MAX && highestBidPrice != -FLT_MAX)
{
double rangeTicks = (lowestAskPrice - highestBidPrice) / 0.25;
double rangePoints = rangeTicks / 4.0;

// Display the range information
SCString rangeText;
rangeText.Format("Active Range: %.0f ticks (%.2f points)", rangeTicks, rangePoints);

s_UseTool rangeTool;
rangeTool.Clear();
rangeTool.ChartNumber = sc.ChartNumber;
rangeTool.DrawingType = DRAWING_TEXT;
rangeTool.AddAsUserDrawnDrawing = 1;
rangeTool.BeginDateTime = sc.BaseDateTimeIn[sc.ArraySize - 1];
rangeTool.BeginValue = highestBidPrice; // Position the text near the highest bid price
rangeTool.Color = RGB(255, 255, 255); // White text
rangeTool.Text = rangeText;
rangeTool.FontSize = 12;
rangeTool.LineNumber = 3; // Unique identifier for updating
rangeTool.AddMethod = UTAM_ADD_OR_ADJUST;

sc.UseTool(rangeTool);
}
}
being a cpp novice, having several difficulties in noticing something 'obvious' in terms of errors. This addition to the bottom of the previous code that now works, gives a really crummy output, and it "duplicates" the text and overlays it making it look like a snakes wedding. so i wondered, is it possible to display text information such as the above examples, in a seperate chart window, like a little "attachment" to the dom, similar to how T&S is? Apologies if anyone is having difficulties decoding my idea, novice developer, so just learning 'on the job', helpers/tips welcomed!