Support Board
Date/Time: Sat, 30 Nov 2024 07:25:38 +0000
Post From: ACSIL study in real-time vs slow market replay
[2022-12-12 08:06:44] |
User907967 - Posts: 54 |
Thanks for your messages. I narrowed down the source of the issue. If anyone wishes to create a new study with the code below, search for a succession of two candles where [0] is the latest and [1] is the one before the latest, where the latest one is both lower and higher than the one before it, i.e. Low[0]<Low[1] && High[0]>High[1]. You will see the second rectangle (associated with the low end of the latest candle does not end where required. However, if one suspends this code, it will see that the second rectangle does end where it should. /* 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.Index]; DrawingObject2.BeginValue=DrawingObject.BeginValue; DrawingObject2.EndValue=DrawingObject.EndValue; DrawingObject2.SecondaryColor = RGB(200, 100, 220); DrawingObject2.DrawingType = DRAWING_RECTANGLEHIGHLIGHT; sc.UseTool(DrawingObject2); sc.DeleteACSChartDrawing(0, TOOL_DELETE_CHARTDRAWING, DrawingObject.LineNumber); } */ I am sorry to labour the point. Perhaps it has something to do with the use of persistent values. 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.Index]; DrawingObject2.BeginValue=DrawingObject.BeginValue; DrawingObject2.EndValue=DrawingObject.EndValue; DrawingObject2.SecondaryColor = RGB(200, 100, 220); DrawingObject2.DrawingType = DRAWING_RECTANGLEHIGHLIGHT; 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.Index]; DrawingObject2.BeginValue=DrawingObject.BeginValue; DrawingObject2.EndValue=DrawingObject.EndValue; DrawingObject2.SecondaryColor = RGB(50, 150, 110); DrawingObject2.DrawingType = DRAWING_RECTANGLEHIGHLIGHT; sc.UseTool(DrawingObject2); sc.DeleteACSChartDrawing(0, TOOL_DELETE_CHARTDRAWING, DrawingObject.LineNumber); } } } } Date Time Of Last Edit: 2022-12-12 08:14:49
|
Screenshot 2022-12-12 081320.png / V - Attached On 2022-12-12 08:14:40 UTC - Size: 178.55 KB - 94 views Screenshot 2022-12-12 081418.png / V - Attached On 2022-12-12 08:14:44 UTC - Size: 187.2 KB - 93 views |