Support Board
Date/Time: Sun, 19 Jan 2025 06:35:05 +0000
[User Discussion] - Angle Study
View Count: 1059
[2018-03-22 22:30:57] |
User228927 - Posts: 55 |
I am trying to do an angle study. It does not appear to be charting correctly. I have 2 angle studies on chart, each charting angles of the 2 moving averages on the chart.
|
UploadImage.png / V - Attached On 2018-03-22 22:29:53 UTC - Size: 77.95 KB - 381 views |
[2018-03-23 07:16:36] |
JoseyWales - Posts: 67 |
Post your ACSIL C++ code or maybe use the study "Study Angle" as inspiration. Found in Studies6.cpp around line 534: SCSFExport scsf_StudyAngle(SCStudyInterfaceRef sc) { SCSubgraphRef Angle = sc.Subgraph[0]; SCSubgraphRef ZeroLine = sc.Subgraph[1]; SCInputRef InInputData = sc.Input[0]; SCInputRef InLength = sc.Input[1]; SCInputRef InValuePerPoint = sc.Input[2]; SCInputRef InSkipCalculationAtStartOfTradingDay = sc.Input[3]; if (sc.SetDefaults) { // Set the configuration and defaults sc.GraphName = "Study Angle"; sc.AutoLoop = 1; //During development set this flag to 1, so the DLL can be modified. When development is completed, set it to 0 to improve performance. sc.FreeDLL = 0; Angle.Name = "Angle"; Angle.DrawStyle = DRAWSTYLE_LINE; Angle.PrimaryColor = RGB(0, 255, 0); Angle.DrawZeros = false; ZeroLine.Name = "Zero Line"; ZeroLine.DrawStyle = DRAWSTYLE_LINE; ZeroLine.PrimaryColor = RGB(255, 0, 255); ZeroLine.DrawZeros = true; InInputData.Name = "Input Data"; InInputData.SetInputDataIndex(0); InLength.Name = "Length"; InLength.SetInt(10); InLength.SetIntLimits(1, MAX_STUDY_LENGTH); InValuePerPoint.Name = "Value Per Point"; InValuePerPoint.SetFloat(1.0f); InSkipCalculationAtStartOfTradingDay.Name = "Skip Calculation at Start of Trading Day"; InSkipCalculationAtStartOfTradingDay.SetYesNo(false); return; } int Length = InLength.GetInt(); sc.DataStartIndex = Length; if (InValuePerPoint.GetFloat() == 0.0f) InValuePerPoint.SetFloat(0.01f); int &r_IndexOfNewDay = sc.GetPersistentInt(1); if (sc.IsFullRecalculation && sc.Index == 0) r_IndexOfNewDay = -1; // Do data processing bool SkipCalculation = false; if (InSkipCalculationAtStartOfTradingDay.GetYesNo()) { if (sc.IsNewTradingDay(sc.Index)) { r_IndexOfNewDay = sc.Index; } SkipCalculation = r_IndexOfNewDay == sc.Index || (sc.Index - Length) < r_IndexOfNewDay; } if (!SkipCalculation) { SCFloatArrayRef InData = sc.BaseData[InInputData.GetInputDataIndex()]; float BackValue = InData[sc.Index - Length]; float CurrentValue = InData[sc.Index]; float PointChange = (CurrentValue - BackValue) / InValuePerPoint.GetFloat(); Angle[sc.Index] = (float)(atan2((double)PointChange, (double)Length) * 180.0 / M_PI); } else { Angle[sc.Index] = 0; } } |
To post a message in this thread, you need to log in with your Sierra Chart account: