Login Page - Create Account

Support Board


Date/Time: Fri, 07 Feb 2025 18:18:11 +0000



Post From: color background based on alert condition and the ACSIL equivalent don't update the same!?

[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.