Support Board
Date/Time: Fri, 10 Jan 2025 14:23:18 +0000
Plotting Daily Open
View Count: 1819
[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 |
[2016-06-06 07:03:46] |
Sierra Chart Engineering - Posts: 104368 |
Use the Daily OHLC study which references a Historical Daily chart: https://www.sierrachart.com/index.php?page=doc/doc_TechnicalStudiesReference.html#s137 For the Study Subgraphs that you do not want to see, you need to set the Draw Style for those to Ignore. Sierra Chart Support - Engineering Level Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy: https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service: Sierra Chart Teton Futures Order Routing |
[2016-06-08 04:04:51] |
User29662 - Posts: 76 |
Thanks! Getting the proper code down for plotting the Daily Open on a lower time frame chart was a precursor for me to plotting higher timeframe moving averages on lower time frame charts. I was hoping to do this without having to use the interim price/study overlay method, but it appears that at least when it comes to Historical Charts, there are issues relating to session start times that impede the direct approach. At least there is some way to do it, though.
|
[2016-09-20 02:20:52] |
Infinite - Posts: 134 |
I use HIGH and Low for a Timeframe
|
To post a message in this thread, you need to log in with your Sierra Chart account: