Support Board
Date/Time: Sat, 23 Nov 2024 18:24:02 +0000
Post From: Determing Day of week for each bar on the chart
[2024-08-11 02:46:18] |
Dryheat31 - Posts: 13 |
I have spent the last 2 hours trying to work this out on my own and can't find a way to get the day of week for each bar on the chart. For each bar on the chart, I just want to know which day of the week it is. Then I want to be able to use that as a condition for resetting various metrics in my code. I tried using GetDayOfWeek(), but that is not working at all. Even after I built an if/then/else structure to convert SUNDAY to an int of zero. Nothing I have tried has worked. Here is the reference I found for GetDayOfWeek(): Working with the SCDateTime Variables and Values: GetDayOfWeek() But this does not work the way I would expect to work given the information provided in that link: #include "sierrachart.h" SCDLLName("Test Day Of Week") SCSFExport scsf_TestDayOfWeek(SCStudyInterfaceRef sc) { SCSubgraphRef testPlot = sc.Subgraph[0]; SCFloatArrayRef weekDay = sc.Subgraph[1]; if (sc.SetDefaults) { sc.GraphName = "Test Day Of Week"; sc.ValueFormat = 2; testPlot.Name = "Day Of Week"; testPlot.DrawStyle = DRAWSTYLE_LINE; testPlot.DrawZeros = true; sc.FreeDLL = 1; return; } sc.DataStartIndex = 1; // indicator metrics begin here... SCDateTime scWeekDayString; if (scWeekDayString.GetDayOfWeek() == SUNDAY) { weekDay[sc.Index] = 0; } else if (scWeekDayString.GetDayOfWeek() == MONDAY) { weekDay[sc.Index] = 1; } else if (scWeekDayString.GetDayOfWeek() == TUESDAY) { weekDay[sc.Index] = 2; } else if (scWeekDayString.GetDayOfWeek() == WEDNESDAY) { weekDay[sc.Index] = 3; } else if (scWeekDayString.GetDayOfWeek() == THURSDAY) { weekDay[sc.Index] = 4; } else if (scWeekDayString.GetDayOfWeek() == FRIDAY) { weekDay[sc.Index] = 5; } else { weekDay[sc.Index] = 6; } testPlot[sc.Index] = weekDay[sc.Index]; } When you try to plot that it only gives a value for the last bar on the chart. And the value it plots is the current day of week (based on computer date/time) and NOT the day of week for the last bar on the chart. It seem that I need an equivalent to GetDayOfWeek that works as an SCFloatArrayRef ??? But where is that found? Or does it even exist? This is so simple to do in other trading platforms. I really appreciate all the features that Sierra Chart offers. But trying to write custom tools for Sierra Chart always requires at least 10 times the time and effort as any other trading platform I work with. Ugh! Please help. |