Support Board
Date/Time: Sun, 19 Jan 2025 03:17:01 +0000
[Programming Help] - Draw rectangle highlighting new york session
View Count: 970
[2018-03-07 16:39:21] |
pnf101 - Posts: 7 |
I would like to highlight the ny session with a rectangle. I see the example for DRAWING_RECTANGLEHIGHLIGHT, however, I can't figure out how to specify the 9:30:00 - 4:30:00 start/end times as this example uses the start/endpoint relative to the chart. Please advise. #include "sierrachart.h" SCDLLName("MySessionHighlight") SCSFExport scsf_MyHighlightSession(SCStudyInterfaceRef sc) { // Draw a rectangle highlight // Set configuration variables if (sc.SetDefaults) { sc.GraphName = "MySessionHighlight"; sc.GraphRegion = 0; sc.FreeDLL = 0; sc.AutoLoop = 0; //No automatic looping return; } // Do data processing SCDateTime dtNySessionBegin; SCDateTime dtNySessionEnd; dtNySessionBegin.SetDateTimeYMDHMS(2018, 3, 6, 9, 30, 00); dtNySessionEnd.SetDateTimeYMDHMS(2018, 3, 6, 4, 30, 00); int BarIndex; int& r_LineNumber = sc.GetPersistentInt(1); s_UseTool Tool; Tool.ChartNumber = sc.ChartNumber; Tool.DrawingType = DRAWING_RECTANGLEHIGHLIGHT; //int &LineNumber12 = sc.GetPersistentInt(12); if (r_LineNumber != 0) Tool.LineNumber = r_LineNumber; // Update BarIndex to 30 bars from the end BarIndex = max(sc.ArraySize - 25, 0); // Tool.BeginDateTime = sc.BaseDateTimeIn[BarIndex]; // <- original Tool.BeginDateTime = sc.BaseDateTimeIn[dtNySessionBegin]; // <- not correct BarIndex = max(sc.ArraySize - 15, 0); // Tool.EndDateTime = sc.BaseDateTimeIn[BarIndex]; // <- original Tool.EndDateTime = sc.BaseDateTimeIn[dtNySessionEnd]; // <- not correct Tool.BeginValue = sc.GetHighest(sc.Low, BarIndex, 10); Tool.EndValue = sc.GetLowest(sc.Low, BarIndex, 10); Tool.Color = RGB(255, 0, 0); // Red Tool.LineWidth = 1; //To see the outline this must be 1 or greater. Tool.SecondaryColor = RGB(0, 255, 0); Tool.TransparencyLevel = 50; Tool.AddMethod = UTAM_ADD_OR_ADJUST; sc.UseTool(Tool); r_LineNumber = Tool.LineNumber;//Remember line number which has been automatically set } |
To post a message in this thread, you need to log in with your Sierra Chart account: