Login Page - Create Account

Support Board


Date/Time: Fri, 07 Feb 2025 17:45:19 +0000



[Programming Help] - color background based on alert condition and the ACSIL equivalent don't update the same!?

View Count: 762

[2022-03-09 18:49:15]
User133994 - Posts: 80
Support,

I have 2 identical indicators:
Color Bar based on alert condition:

<snip>
And the ACSIL equivalent:
<snip>
However, ONLY the "Color Background based on Alert Condition" updates as expected...i.e. paints the background in "real-time" as the updates occur.

The ACSIL study when compiled and added to the chart--doesn't paint background in "real-time"; however, if I select Chart->Recalculate, the ACSIL study then paints the highlights exactly as the Color Background study. ?

Please help. I need the "real-time" painting of background highlights, but I want to use an ACSIL study to do it.

Why don't these "identical" studies have the same behaviour? How can I make the ACSIL one behave like the other?

I have already tried adding sc.UpdateAlways =1; in the sc.Defaults of the ACSIL study block--and recompiled..but it still isn't working.

I have applied the Chart Recalculation-Periodic study and that works...but is not manageable. Recalculating the chart every 1 second is not a good practice.

Important note: ID64 is a reference to a study on a higher timeframe chart.

Thanks again for your assistance.
Date Time Of Last Edit: 2022-03-11 14:54:30
[2022-03-09 19:14:19]
1+1=10 - Posts: 270
You need to send the part of the code where you actually are writing data to the subgraphs. Otherwise, this question is impossible to answer.

Actually, sending all the code for the study would be ideal.
Date Time Of Last Edit: 2022-03-09 19:14:43
[2022-03-09 22:26:09]
User133994 - Posts: 80
Ok. Here you go.

SCSFExport scsf_jjcSqueezeBackground(SCStudyInterfaceRef sc)
{
jjcSqueeze jsq;
int o_s=0;
SCSubgraphRef Subgraph_Background = sc.Subgraph[o_s]; o_s++;

int i_i=0;

//%{{% sd1Squeeze inputs
// MUST PUT THIS CODE BLOCK BEFORE THE MAIN "if (sc.SetDefaults)" block

//%{{% PF42_SD1_top
SCInputRef Input_StudySubgraph_PF42_SD1_top = sc.Input[i_i]; i_i++;
if(sc.SetDefaults){
Input_StudySubgraph_PF42_SD1_top.Name = "Input Study: P&F 4-2 SD1 top study on my chart--ID64 SG1";
Input_StudySubgraph_PF42_SD1_top.SetStudySubgraphValues(64, 0);
}
SCFloatArray ID64SG1_PF42_SD1_top_array;
sc.GetStudyArrayUsingID(Input_StudySubgraph_PF42_SD1_top.GetStudyID(), Input_StudySubgraph_PF42_SD1_top.GetSubgraphIndex(), ID64SG1_PF42_SD1_top_array);
// i.e. ID64SG1_PF42_SD1_top_array[sc.Index-1]
//%}}%

//%{{% PF42_SD1_bottom
SCInputRef Input_StudySubgraph_PF42_SD1_bottom = sc.Input[i_i]; i_i++;
if(sc.SetDefaults){
Input_StudySubgraph_PF42_SD1_bottom.Name = "Input Study: P&F 4-2 SD1 bottom study on my chart--ID64 SG2";
Input_StudySubgraph_PF42_SD1_bottom.SetStudySubgraphValues(64, 1);
}
SCFloatArray ID64SG2_PF42_SD1_bottom_array;
sc.GetStudyArrayUsingID(Input_StudySubgraph_PF42_SD1_bottom.GetStudyID(), Input_StudySubgraph_PF42_SD1_bottom.GetSubgraphIndex(), ID64SG2_PF42_SD1_bottom_array);
// i.e. ID64SG2_PF42_SD1_bottom_array[sc.Index-1]
//%}}%

//%}}%

if (sc.SetDefaults)
{
//%{{%
// Set the configuration and defaults
sc.GraphName = "jjc Color Background when Squeeze is found";
sc.StudyDescription = "Like the simple color background Alert indicator--but in ACSIL--much better";
sc.UpdateAlways = 1;   //for some reason, the highlights aren't showing in time--it doesn't update as expected unless I do a Chart->recalculate; so this should remedy that problem

sc.AutoLoop = true;

sc.GraphRegion = 0;
sc.DrawStudyUnderneathMainPriceGraph = 1; // not required in studies, but want color behind price for this study

Subgraph_Background.Name = "Background";
Subgraph_Background.DrawStyle = DRAWSTYLE_BACKGROUND_TRANSPARENT;
Subgraph_Background.PrimaryColor = COLOR_YELLOW;
// Subgraph_Background.SecondaryColor = COLOR_LIGHTPINK;
// Subgraph_Background.SecondaryColorUsed = true; // turn on if both colors are to be used
// Subgraph_Background.AutoColoring = AUTOCOLOR_POSNEG; // use positive/negative values to signify colors

return;
//%}}%
}

// Do data processing
if ( jsq.sd1Squeeze(sc, ID64SG1_PF42_SD1_top_array, ID64SG2_PF42_SD1_bottom_array ) )
Subgraph_Background[sc.Index] = 1; // 1 use primary color

}

note: jsq.sd1Squeeze is what I posted above...

Thanks for your help in advance.
[2022-03-09 22:58:10]
1+1=10 - Posts: 270
It all looks fine to me and I write ACSIL quite a bit. I imagined perhaps you had an issue with your looping but everything with the AutoLooping approach looks good. I'm stumped. Perhaps other commentators will have ideas.
[2022-03-09 23:28:13]
User431178 - Posts: 582
Probably relates to calculation order, so I would suggest trying setting to lower calculation precedence.

Here is the relevant link: ACSIL Interface Members - Variables and Arrays: sc.CalculationPrecedence
[2022-03-10 02:01:49]
User133994 - Posts: 80
Friends,

Thanks so much. This seemed to fix it (as of my initial test...I'll post again if something goes awry):

sc.CalculationPrecedence = LOW_PREC_LEVEL;

Excellent.
Have a great day.
[2022-03-10 02:14:18]
1+1=10 - Posts: 270
Nice catch on the calculation order, User431178.

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

Login

Login Page - Create Account