Login Page - Create Account

Support Board


Date/Time: Sun, 16 Mar 2025 15:22:58 +0000



[Programming Help] - Ascil SecondaryColor doesn't work

View Count: 430

[2022-08-11 08:44:39]
BenjFlame - Posts: 335
I expected to implement this in a few minutes and it's been hours i'm on this and now posting on this board.
Wherever SecondaryColor is implemented in this code it is completely ignored on the chart.
I implemented this on numerous studies in exact same way and always had it working. Why on earth is it not working this time?

The SubGraph_currentDeltaText is set with DRAWSTYLE_TEXT_WITH_BACKGROUND so it should work.


/*============================================================================
1 second chart delta on single line.
----------------------------------------------------------------------------*/
SCSFExport scsf_ShortTimeFrameDelta(SCStudyInterfaceRef sc)
{

// Graphs
SCSubgraphRef Subgraph_currentDelta = sc.Subgraph[0];
SCSubgraphRef SubGraph_Price_Line = sc.Subgraph[1];
SCSubgraphRef SubGraph_currentDeltaText = sc.Subgraph[2];
SCSubgraphRef SubGraph_topBb = sc.Subgraph[3];
SCSubgraphRef SubGraph_BottomBb = sc.Subgraph[4];


// Inputs
SCInputRef Input_StudyId_Delta = sc.Input[0];
SCInputRef Input_SubgraphId_delta = sc.Input[1];

SCInputRef Input_StudyId_BBtop = sc.Input[2];
SCInputRef Input_SubgraphId_BBtop = sc.Input[3];

SCInputRef Input_StudyId_BBbotom = sc.Input[4];
SCInputRef Input_SubgraphId_BBbotom = sc.Input[5];

SCInputRef Input_StudyId_OffsetPositiveDelta = sc.Input[6];
SCInputRef Input_SubgraphId_OffsetNegativeDelta = sc.Input[7];


if (sc.SetDefaults)
{


// Set the defaults
sc.MaintainAdditionalChartDataArrays = 0;
sc.CalculationPrecedence = LOW_PREC_LEVEL;
sc.GraphName = "SHORT TIMEFRAME DELTA";
sc.GraphRegion = 0;
sc.ScaleRangeType = SCALE_SAMEASREGION;
sc.AutoLoop = 1;


// Graphs
Subgraph_currentDelta.Name = "Current Delta";
Subgraph_currentDelta.DrawStyle = DRAWSTYLE_HIDDEN;

SubGraph_Price_Line.Name = "Price Color";
SubGraph_Price_Line.DrawStyle = DRAWSTYLE_COLOR_BAR_CANDLE_FILL;
SubGraph_Price_Line.LineWidth = 6;

SubGraph_currentDeltaText.Name = "Current Delta Text";
SubGraph_currentDeltaText.DrawStyle = DRAWSTYLE_TEXT_WITH_BACKGROUND;
SubGraph_currentDeltaText.PrimaryColor = RGB(255, 255, 255);
SubGraph_currentDeltaText.LineWidth = 12;
SubGraph_currentDeltaText.GraphicalDisplacement = 2;

SubGraph_topBb.Name = "Top Bollinger Band";
SubGraph_topBb.DrawStyle = DRAWSTYLE_HIDDEN;

SubGraph_BottomBb.Name = "Top Bollinger Band";
SubGraph_BottomBb.DrawStyle = DRAWSTYLE_HIDDEN;

// Inputs
Input_StudyId_Delta.Name = "Delta ref study Id";
Input_StudyId_Delta.SetInt(10);
Input_SubgraphId_delta.Name = "Delta ref subgraph Id";
Input_SubgraphId_delta.SetInt(3);


Input_StudyId_BBtop.Name = "BBtop ref study Id";
Input_StudyId_BBtop.SetInt(11);
Input_SubgraphId_BBtop.Name = "BBtop ref subgraph Id";
Input_SubgraphId_BBtop.SetInt(0);


Input_StudyId_BBbotom.Name = "BBbottom ref study Id";
Input_StudyId_BBbotom.SetInt(11);
Input_SubgraphId_BBbotom.Name = "BBbottom ref subgraph Id";
Input_SubgraphId_BBbotom.SetInt(2);

Input_StudyId_OffsetPositiveDelta.Name = "Offset positive Delta";
Input_StudyId_OffsetPositiveDelta.SetInt(4);
Input_SubgraphId_OffsetNegativeDelta.Name = "Offset negative Delta";
Input_SubgraphId_OffsetNegativeDelta.SetInt(-2);


return;
}

// Only draw projection on current bar
// Make sure it is added after moving average calculations, or any calculation that will produce array values needed to be used over several bars back.
if (sc.Index != sc.ArraySize - 1)
{
return;
}

// Top BB
SCFloatArray topBB;
if (sc.GetStudyArrayUsingID(Input_StudyId_BBtop.GetInt(), Input_SubgraphId_BBtop.GetInt(), topBB) >= 0 && topBB.GetArraySize() > 0)
{

SubGraph_topBb[sc.Index] = topBB[sc.Index];

}

// Bottom BB
SCFloatArray bottomBB;
if (sc.GetStudyArrayUsingID(Input_StudyId_BBbotom.GetInt(), Input_SubgraphId_BBbotom.GetInt(), bottomBB) >= 0 && bottomBB.GetArraySize() > 0)
{

SubGraph_BottomBb[sc.Index] = bottomBB[sc.Index];

}


// Get delta
SCFloatArray delta;
if (sc.GetStudyArrayUsingID(Input_StudyId_Delta.GetInt(), Input_SubgraphId_delta.GetInt(), delta) >= 0 && delta.GetArraySize() > 0)
{

Subgraph_currentDelta[sc.Index] = delta[sc.Index];
}




// Delta text
SCString deltaText;
deltaText.Format("%.0f", Subgraph_currentDelta[sc.Index]);
SubGraph_currentDeltaText.TextDrawStyleText = deltaText;

// Normal positive
if (Subgraph_currentDelta[sc.Index] > 0 && Subgraph_currentDelta[sc.Index] < SubGraph_topBb[sc.Index])
{
SubGraph_currentDeltaText.DataColor[sc.Index] = RGB(27, 188, 155);
SubGraph_currentDeltaText.SecondaryColor = RGB(0, 0, 0);

SubGraph_currentDeltaText[sc.Index] = sc.Close[sc.Index] + Input_StudyId_OffsetPositiveDelta.GetInt();
}
// High positive
else if (Subgraph_currentDelta[sc.Index] > 0 && Subgraph_currentDelta[sc.Index] > SubGraph_topBb[sc.Index])
{
SubGraph_currentDeltaText.DataColor[sc.Index] = RGB(250, 250, 110);
SubGraph_currentDeltaText.SecondaryColor = RGB(0, 0, 0);

SubGraph_currentDeltaText[sc.Index] = sc.Close[sc.Index] + Input_StudyId_OffsetPositiveDelta.GetInt();
}
// Normal negative
else if (Subgraph_currentDelta[sc.Index] < 0 && Subgraph_currentDelta[sc.Index] > SubGraph_BottomBb[sc.Index])
{
SubGraph_currentDeltaText.DataColor[sc.Index] = RGB(188, 27, 60);
SubGraph_currentDeltaText.SecondaryColor = RGB(0, 0, 0);

SubGraph_currentDeltaText[sc.Index] = sc.Close[sc.Index] - Input_SubgraphId_OffsetNegativeDelta.GetInt();
}
// High negative
else if (Subgraph_currentDelta[sc.Index] < 0 && Subgraph_currentDelta[sc.Index] < SubGraph_BottomBb[sc.Index])
{
SubGraph_currentDeltaText.DataColor[sc.Index] = RGB(224, 163, 255);
SubGraph_currentDeltaText.SecondaryColor = RGB(0, 0, 0);

SubGraph_currentDeltaText[sc.Index] = sc.Close[sc.Index] - Input_SubgraphId_OffsetNegativeDelta.GetInt();
}
else
{
SubGraph_currentDeltaText.DataColor[sc.Index] = RGB(255, 255, 255);
}





int& PriorArraySize = sc.GetPersistentInt(1);

if (sc.Index == 0)
{
PriorArraySize = sc.ArraySize;
}

if (PriorArraySize < sc.ArraySize)
{

Subgraph_currentDelta[sc.Index - 1] = 0;
SubGraph_currentDeltaText[sc.Index - 1] = 0;

}

PriorArraySize = sc.ArraySize;




}



Date Time Of Last Edit: 2022-08-11 08:46:21
[2022-08-11 09:42:59]
BenjFlame - Posts: 335
DRAWSTYLE_TEXT_WITH_BACKGROUND was ignored by default setting of study that used TEXT draw style.
Changing the default study to Text with background fixed the issue.
Date Time Of Last Edit: 2022-08-11 09:44:05

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account