Support Board
Date/Time: Wed, 07 May 2025 16:59:51 +0000
[Programming Help] - Subgraph does not match refrence value
View Count: 160
[2024-11-22 13:40:31] |
User353369 - Posts: 17 |
I am trying to use built in function code for intermediary I am hoping someone can help me understand the following code. I have brought up a new study template from Analysis>> New /Open then copy and pasted the RSI function code from https://www.sierrachart.com/index.php?page=doc/ACSIL_Members_Functions.html#scRSI. As per the example the RSI to output to subgraph[0] produces the correct result but when I refrence the Subgraph[0][sc.Index] or "RSI" to write to the message log the result is a handful of repeating multi -digit integers or 0. Hopefully this all makes sense. What am I doing wrong or not understanding. Thank you for your time BTÂ SCDLLName("Custom Study DLL")
}
//This is the basic framework of a study function. Change the name 'TemplateFunction' to what you require. SCSFExport scsf_TemplateFunction(SCStudyInterfaceRef sc) { SCString msg; // Section 1 - Set the configuration variables and defaults if (sc.SetDefaults) { sc.GraphName = "FunctionTest"; sc.AutoLoop = 1; //Automatic looping is enabled. sc.Subgraph[0].Name = "Out"; sc.Subgraph[0].DrawStyle = DRAWSTYLE_LINE; sc.Subgraph[0].PrimaryColor = RGB (0, 255, 0); sc.Input[0].Name = "Int Input"; sc.Input[0].SetInt(21); return; } // Section 2 - Do data processing here sc.RSI(sc.BaseDataIn[SC_LAST], sc.Subgraph[0],sc.Index, MOVAVGTYPE_SIMPLE, 20); float RSI = sc.Subgraph[0][sc.Index]; //Access the study value at the current index msg.Format("func = %d", RSI); ////////////// msg.Format("func = %d", sc.Subgraph[0][sc.Index];); Yields the same result as expected sc.AddMessageToLog(msg, 1); |
[2024-11-22 13:50:29] |
User431178 - Posts: 667 |
This is wrong. msg.Format("func = %d", RSI); %d is for integer %f is for float You need to used %f |
[2024-11-22 14:02:06] |
User353369 - Posts: 17 |
Ahh the basics. Thank you!!
|
To post a message in this thread, you need to log in with your Sierra Chart account: