Login Page - Create Account

Support Board


Date/Time: Sun, 02 Nov 2025 18:58:50 +0000



[Programming Help] - Inconsistent results with GetNearestMatchForSCDateTime

View Count: 41

[2025-11-01 16:20:19]
skalaydzhiyski - Posts: 86
Hi SC,

I just want to report some incosistency I found with sc.GetNearestMatchForSCDateTime when used with high replay speeds (anything above 120) and fast update interval (15 ms). Basically it gives back the wrong index for the xame exact SCDAteTime

Logs below for 120x speed replay, accurate trading system back test mode, 15 ms update interval, bar period 1 min

2025-11-01 16:23:24.982 | Chart: Replay 120X: ESZ25-CME [CBV][M] 1 Min | Study: Indicator_OrderFills | dt, index -> 2025-10-31 15:22:40.945, 202 | Number times message added: 33
2025-11-01 16:23:25.113 | Chart: Replay 120X: ESZ25-CME [CBV][M] 1 Min | Study: Indicator_OrderFills | dt, index -> 2025-10-31 15:22:40.945, 203

I would love to know how to work around this or how to resolve it.


All the best,
Spas
Date Time Of Last Edit: 2025-11-01 16:24:03
[2025-11-01 17:22:42]
User431178 - Posts: 805
What is the array size each time you call GetNearestMatchForSCDateTime?

If, when the first message, index 202 is last bar in chart (sc.ArraySize-1), then it would be expected to give different answer when a new bar (203) is added, as your timestamp is then nearer to start time of the next bar.

ACSIL Interface Members - Functions: sc.GetNearestMatchForSCDateTime()


Matching Rules for a Nearest Date-Time Match

1. If an exact match can be done, then the index with the exact match will be returned. If there are repeating timestamps, then the first index in the repeating times is given.
2. If there is not an exact match, then the index of the nearest matching date-time is given.
3. If the given date-time is equidistant between two date-times, then the index for the higher date-time is given.

rule 2 applies as you don't have an exact time match to the start of the bar.



I would love to know how to work around this or how to resolve it.

Don't use sc.GetNearestMatchForSCDateTime, use sc.GetContainingIndexForSCDateTime instead?

ACSIL Interface Members - Functions: sc.GetContainingIndexForSCDateTime()


Or I might be totally wrong.

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account