Support Board
Date/Time: Fri, 10 Jan 2025 17:29:22 +0000
Post From: Plotting Daily Open
[2016-06-06 04:19:43] |
User29662 - Posts: 76 |
I tried two ways of plotting the daily open from a historical chart onto an intraday chart, and both failed to give me the accurate open levels. Can someone tell me what is wrong? Here is my code: #include "sierrachart.h"
SCDLLName("MAIN") SCSFExport scsf_DailyOpen(SCStudyGraphRef sc) { SCSubgraphRef OP1 = sc.Subgraph[0]; SCSubgraphRef OP2 = sc.Subgraph[1]; SCInputRef ChartNumber = sc.Input[0]; if (sc.SetDefaults) { sc.GraphName = "DailyOpen"; sc.GraphRegion = 0; sc.FreeDLL = 1; sc.AutoLoop = 1; OP1.Name = "OP1"; OP1.DrawStyle = DRAWSTYLE_LINE; OP1.PrimaryColor = RGB(255, 0, 0); OP2.Name = "OP2"; OP2.DrawStyle = DRAWSTYLE_LINE; OP2.PrimaryColor = RGB(0, 255, 0); ChartNumber.Name = "ChartNumber"; ChartNumber.SetInt(1); return; } SCGraphData BaseGraphData; sc.GetChartBaseData(ChartNumber.GetInt(), BaseGraphData); SCFloatArrayRef OpenArray = BaseGraphData[SC_OPEN]; int RefIndex = sc.GetContainingIndexForDateTimeIndex(ChartNumber.GetInt(), sc.Index); int RefIndex2 = sc.GetNearestMatchForDateTimeIndex(ChartNumber.GetInt(), sc.Index); OP1[sc.Index] = OpenArray[RefIndex]; OP2[sc.Index] = OpenArray[RefIndex2]; } The correct new daily open should plot at 15:00:00 each day. Get Containing Index (in red) starts a new day at midnight. Get Nearest Match (in green) starts a new day at noon for reasons unknown. |
F.US.EPM16 30 Min #2 2016-06-05 21_17_38.182.png / V - Attached On 2016-06-06 04:18:02 UTC - Size: 100.7 KB - 368 views |