Support Board
Date/Time: Wed, 27 Nov 2024 22:50:27 +0000
[User Discussion] - Trying to use Study data in an ACSIL function
View Count: 1355
[2014-10-21 17:36:58] |
NickH09 - Posts: 10 |
Hello! Im try to use the ADXVMA study's output data to generate the actual color (Red, Yellow and Blue) in my study and then coloring the price, but im having trouble. I see the three colors drawn(i use the color bar draw style) but they are disordered and without a patron. I don't know if it can be disable the setting (Based On: ) that the studies have as default. Can have any impact on data?. I don't know if the problem is in the color logic or getting the data from the ADXVMA. I'd greatly appreciate someone's help, here it is the code: #include "sierrachart.h" #include <string> using namespace std; SCDLLName("STDref") SCSFExport scsf_STDref(SCStudyGraphRef sc) { SCSubgraphRef ColorBar = sc.Subgraph[1]; if (sc.SetDefaults) { sc.GraphName = "STDref"; sc.StudyDescription = "STDref"; sc.FreeDLL = 0; sc.AutoLoop = 1; sc.GraphRegion = 0; sc.Subgraph[0].Name = "STDref"; sc.Subgraph[0].PrimaryColor = RED; sc.Subgraph[0].DrawStyle = DRAWSTYLE_COLORBAR; sc.Subgraph[0].LineWidth = 2; sc.CalculationPrecedence = LOW_PREC_LEVEL; sc.Input[0].Name = "Study Reference 1"; sc.Input[0].SetStudyID(1); return; } SCFloatArray StudyReference1; sc.GetStudyArrayUsingID(sc.Input[0].GetStudyID(), 4, StudyReference1); // It's the same to point to ADXVMA sg.Subgraph[0] or ma sg.Subgraph[4] ? int ValueStudy1 = StudyReference1[sc.Index]; int ValueStudy1b = StudyReference1[sc.Index - 1]; int ColorSt1 = WHITE; if (ValueStudy1 > ValueStudy1b) { ColorSt1 = BLUE; } else if (ValueStudy1 < ValueStudy1b) { ColorSt1 = RED; } else if (ValueStudy1 == ValueStudy1b) { ColorSt1 = YELLOW; } sc.Subgraph[0][sc.Index] = sc.BaseData[SC_LAST][sc.Index]; sc.Subgraph[0].DataColor[sc.Index] = ColorSt1; } |
[2014-10-21 18:04:48] |
eRamone - Posts: 1 |
You need to change data type of variables ValueStudy to float float ValueStudy1 = StudyReference1[sc.Index]; float ValueStudy1b = StudyReference1[sc.Index - 1]; Regards |
To post a message in this thread, you need to log in with your Sierra Chart account: