Support Board
Date/Time: Sat, 23 Nov 2024 17:56:13 +0000
Post From: Determing Day of week for each bar on the chart
[2024-08-11 04:13:45] |
Dryheat31 - Posts: 13 |
just by reading the code, it seems that you do have a lot of misunderstanding about ACSIL, your code would probably look like this:
Nope, that does not work either. I appreciate your efforts but the solution you suggested does not work. But you did give me an idea that helped me to solve it. I have developed many solutions for Sierra Chart and every time I have to work in this trading platform I absolutely dread it. I find it easier to build a trading tool in a language and trading platform I have never seen before. ACSIL is just about as complicated as NinjaTrader. The reason I had those "extra steps" was because the documentation for "GetDayOfWeek()" does not tell us whether it returns a String or an Integer. It merely tells us that it returns SUNDAY... well... what exactly is that? Is it a constant? If so, what is the value of those constants? Is it a string? If so, why is SUNDAY not in quotes. There is lot of essential details lacking in the language reference for this function. So I thank you for pointing out that we can trust that the output is integers of 0 through 6. If that language reference had stated that clearly it would have saved me two hours of wasted effort (that's a note to Sierra Chart engineers to update that section). But if that function does indeed return integers of 0 through 6, then my original solution would have worked, and I would have eventually reduced the complexity of the code to only the essential elements. It seems the fix that actually made this work was to replace SCDateTime.GetDayOfWeek() with sc.BaseDateTimeIn[sc.Index].GetDayOfWeek(). But where is the documentation for this? Here is the final solution that works, based on the idea I got from Tony's suggestion (thank you Tony): #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.AutoLoop = 1; sc.FreeDLL = 1; return; } sc.DataStartIndex = 1; // indicator metrics begin here... testPlot[sc.Index] = sc.BaseDateTimeIn[sc.Index].GetDayOfWeek(); } |