Login Page - Create Account

Support Board


Date/Time: Tue, 06 May 2025 12:58:21 +0000



Post From: ACSIL Control Background and Transparency in

[2025-01-06 15:39:27]
cmet - Posts: 690
Not sure if this helps but take a look. Custom study that plots three text values in subgraph based on your inputs. If you're still getting the full secondary color background, could possibly be something in chart graphic settings. Just go down the list and see if the same shade of green shows up and see what it corresponds to.


#include "sierrachart.h"

SCDLLName("Custom Text Display")

SCSFExport scsf_TextDisplay(SCStudyInterfaceRef sc)
{
SCSubgraphRef Subgraph_TextDisplay = sc.Subgraph[0];

SCInputRef Input_HorizontalPosition = sc.Input[0];
SCInputRef Input_VerticalPosition = sc.Input[1];
SCInputRef Input_TransparentLabelBackground = sc.Input[2];
SCInputRef Input_UseBoldFont = sc.Input[3];
SCInputRef Input_TextValue1 = sc.Input[4];
SCInputRef Input_TextValue2 = sc.Input[5];
SCInputRef Input_TextValue3 = sc.Input[6];

if (sc.SetDefaults)
{
sc.GraphName = "Custom Text Display";

Subgraph_TextDisplay.Name = "Text Display";
Subgraph_TextDisplay.DrawStyle = DRAWSTYLE_CUSTOM_TEXT;
Subgraph_TextDisplay.PrimaryColor = RGB(0, 0, 0); // Black text
Subgraph_TextDisplay.SecondaryColor = RGB(255, 255, 221); // Pale yellow (backup)
Subgraph_TextDisplay.SecondaryColorUsed = false; // Disable secondary color
Subgraph_TextDisplay.LineWidth = 12; // Font size

Input_HorizontalPosition.Name = "Horizontal Position";
Input_HorizontalPosition.SetInt(50); // Default position

Input_VerticalPosition.Name = "Vertical Position";
Input_VerticalPosition.SetInt(50); // Default position

Input_TransparentLabelBackground.Name = "Transparent Background";
Input_TransparentLabelBackground.SetYesNo(true); // Default to transparent

Input_UseBoldFont.Name = "Use Bold Font";
Input_UseBoldFont.SetYesNo(false); // Default to non-bold

Input_TextValue1.Name = "Text Value 1";
Input_TextValue1.SetString("Value 1");

Input_TextValue2.Name = "Text Value 2";
Input_TextValue2.SetString("Value 2");

Input_TextValue3.Name = "Text Value 3";
Input_TextValue3.SetString("Value 3");

sc.AutoLoop = 0;
return;
}

// Define transparent background flag
int TransparentLabelBackground = Input_TransparentLabelBackground.GetYesNo();

// Retrieve text values from inputs
SCString TextValue1 = Input_TextValue1.GetString();
SCString TextValue2 = Input_TextValue2.GetString();
SCString TextValue3 = Input_TextValue3.GetString();

// Combine text values for display
SCString CombinedText;
CombinedText.Format("%s\n%s\n%s", TextValue1.GetChars(), TextValue2.GetChars(), TextValue3.GetChars());

// Forcefully ensure secondary color is not used
Subgraph_TextDisplay.SecondaryColorUsed = false;

// Add and manage the text drawing with specified properties
sc.AddAndManageSingleTextDrawingForStudy(
sc,
false, // Do not display in fill space
Input_HorizontalPosition.GetInt(),
Input_VerticalPosition.GetInt(),
Subgraph_TextDisplay,
TransparentLabelBackground, // Use transparency setting
CombinedText,
sc.DrawStudyUnderneathMainPriceGraph ? 0 : 1, // Draw below the main price graph
Input_UseBoldFont.GetYesNo() // Use bold font if enabled
);

// Ensure no solid green background when transparency is selected
if (TransparentLabelBackground)
{
Subgraph_TextDisplay.PrimaryColor = RGB(0, 0, 0); // Default to black text
Subgraph_TextDisplay.SecondaryColorUsed = false; // Reinforce disabling secondary color
}

// Restore scaling for the chart
sc.ScaleRangeType = SCALE_SAMEASREGION;
}

Date Time Of Last Edit: 2025-01-06 15:40:07
imagecustom_text.jpg / V - Attached On 2025-01-06 15:39:19 UTC - Size: 27.29 KB - 50 views