Support Board
Date/Time: Sat, 30 Nov 2024 07:23:20 +0000
Post From: ACSIL study in real-time vs slow market replay
[2022-12-13 02:02:19] |
User907967 - Posts: 54 |
Mystery solved. If one attempts to process two drawings with the same starting bar, if using the above code, somehow, by the time the second drawing is reviewed sc.Index is incremented. I don't know why this happens because, as I said, the replay mode causes no issues. So I amended this: DrawingObject2.EndDateTime = sc.BaseDateTimeIn[sc.Index];
into thisDrawingObject2.EndDateTime = sc.BaseDateTimeIn[sc.GetIndexOfHighestValue(sc.High, sc.Index-Bar)]; orDrawingObject2.EndDateTime = sc.BaseDateTimeIn[sc.GetIndexOfLowestValue(sc.Low, sc.Index-Bar)]; Depending on the case.All in all, here is the demo code for those that hit the same thread. SCSFExport scsf_Demo(SCStudyInterfaceRef sc)
{ // Section 1 - Set the configuration variables and defaults if (sc.SetDefaults) { sc.GraphName = "Demo"; sc.AutoLoop = 1; sc.UpdateAlways = 1; sc.GraphRegion = 0; return; } // Section 2 - Do data processing here if (sc.GetBarHasClosedStatus() == BHCS_BAR_HAS_CLOSED){ if (sc.GetACSDrawingsCount(0, 1) < 100 && sc.Index % 5 == 0){ s_UseTool DrawingObject; DrawingObject.Clear(); DrawingObject.DrawingType = DRAWING_RECTANGLE_EXT_HIGHLIGHT; DrawingObject.BeginDateTime = sc.BaseDateTimeIn[sc.Index]; DrawingObject.EndDateTime = sc.BaseDateTimeIn[sc.Index]; DrawingObject.SecondaryColor = RGB(10, 200, 120); DrawingObject.BeginValue=sc.High[sc.Index]; DrawingObject.EndValue=sc.High[sc.Index]-10; sc.UseTool(DrawingObject); DrawingObject.Clear(); DrawingObject.DrawingType = DRAWING_RECTANGLE_EXT_HIGHLIGHT; DrawingObject.BeginDateTime = sc.BaseDateTimeIn[sc.Index]; DrawingObject.EndDateTime = sc.BaseDateTimeIn[sc.Index]; DrawingObject.SecondaryColor = RGB(100, 20, 50); DrawingObject.BeginValue=sc.Low[sc.Index]+10; DrawingObject.EndValue=sc.Low[sc.Index]; sc.UseTool(DrawingObject); } } s_UseTool DrawingObject; for (int Counter=0; Counter<(sc.GetACSDrawingsCount(sc.ChartNumber, 1)); Counter++){ sc.GetACSDrawingByIndex(sc.ChartNumber, Counter, DrawingObject, 1); int Bar = sc.GetNearestMatchForSCDateTime(sc.ChartNumber, DrawingObject.BeginDateTime.GetAsDouble()); s_UseTool DrawingObject2; if (DrawingObject.DrawingType==DRAWING_RECTANGLE_EXT_HIGHLIGHT){ if (sc.High[Bar]==DrawingObject.BeginValue && sc.GetHighest(sc.High, sc.Index-Bar)>DrawingObject.BeginValue){ DrawingObject2.Clear(); DrawingObject2.BeginDateTime = DrawingObject.BeginDateTime; DrawingObject2.EndDateTime = sc.BaseDateTimeIn[sc.GetIndexOfHighestValue(sc.High, sc.Index-Bar)]; DrawingObject2.BeginValue=DrawingObject.BeginValue; DrawingObject2.EndValue=DrawingObject.EndValue; DrawingObject2.SecondaryColor = RGB(200, 100, 220); DrawingObject2.DrawingType = DRAWING_RECTANGLEHIGHLIGHT; DrawingObject2.Text = Text; DrawingObject2.Color = RGB(200, 100, 220); sc.UseTool(DrawingObject2); sc.DeleteACSChartDrawing(0, TOOL_DELETE_CHARTDRAWING, DrawingObject.LineNumber); } if (sc.Low[Bar]==DrawingObject.EndValue && sc.GetLowest(sc.Low, sc.Index-Bar)<DrawingObject.EndValue){ DrawingObject2.Clear(); DrawingObject2.BeginDateTime = DrawingObject.BeginDateTime; DrawingObject2.EndDateTime = sc.BaseDateTimeIn[sc.GetIndexOfLowestValue(sc.Low, sc.Index-Bar)]; DrawingObject2.BeginValue=DrawingObject.BeginValue; DrawingObject2.EndValue=DrawingObject.EndValue; DrawingObject2.SecondaryColor = RGB(50, 150, 110); DrawingObject2.DrawingType = DRAWING_RECTANGLEHIGHLIGHT; DrawingObject2.Text = Text; DrawingObject2.Color = RGB(200, 100, 220); sc.UseTool(DrawingObject2); sc.DeleteACSChartDrawing(0, TOOL_DELETE_CHARTDRAWING, DrawingObject.LineNumber); } } } } Wishing everyone a productive rest of the week. Date Time Of Last Edit: 2022-12-13 02:03:08
|