diff --git a/ChartDisplay/ChartDisplayMain.pas b/ChartDisplay/ChartDisplayMain.pas index c71f1c9..432b0b1 100644 --- a/ChartDisplay/ChartDisplayMain.pas +++ b/ChartDisplay/ChartDisplayMain.pas @@ -117,8 +117,8 @@ type FDescriptionText: string; // User-friendly description public constructor Create(ATickCount: Integer); - function Init(const ADataSet: TArray>): Boolean; - function IsNewBar(AIndex: Integer; const ATick: TDataRecord): Boolean; + function Init(const ADataSet: TArray>): Boolean; + function IsNewBar(AIndex: Integer; const ATick: TDataPoint): Boolean; function GetCaption: string; // Returns the Description for UI property Caption: string read GetCaption; // Interface property uses GetCaption end; @@ -130,8 +130,8 @@ type FDescriptionText: string; // User-friendly description public constructor Create(ATargetTickVolume: Integer); - function Init(const ADataSet: TArray>): Boolean; - function IsNewBar(AIndex: Integer; const ATick: TDataRecord): Boolean; + function Init(const ADataSet: TArray>): Boolean; + function IsNewBar(AIndex: Integer; const ATick: TDataPoint): Boolean; function GetCaption: string; // Returns the Description for UI property Caption: string read GetCaption; // Interface property uses GetCaption end; @@ -147,12 +147,12 @@ begin FDescriptionText := Format('Every %d Ticks', [FTickCountForNewBar]); end; -function TEveryNTicksBuilder.Init(const ADataSet: TArray>): Boolean; +function TEveryNTicksBuilder.Init(const ADataSet: TArray>): Boolean; begin Result := True; end; -function TEveryNTicksBuilder.IsNewBar(AIndex: Integer; const ATick: TDataRecord): Boolean; +function TEveryNTicksBuilder.IsNewBar(AIndex: Integer; const ATick: TDataPoint): Boolean; begin Result := (AIndex mod FTickCountForNewBar = 0); end; @@ -173,13 +173,13 @@ begin FCurrentTickInBarCount := 0; end; -function TVolumeAccumulationBuilder.Init(const ADataSet: TArray>): Boolean; +function TVolumeAccumulationBuilder.Init(const ADataSet: TArray>): Boolean; begin FCurrentTickInBarCount := 0; Result := True; end; -function TVolumeAccumulationBuilder.IsNewBar(AIndex: Integer; const ATick: TDataRecord): Boolean; +function TVolumeAccumulationBuilder.IsNewBar(AIndex: Integer; const ATick: TDataPoint): Boolean; begin Inc(FCurrentTickInBarCount); if FCurrentTickInBarCount >= FTargetTickVolumePerBar then @@ -755,8 +755,8 @@ begin and (HoveredCandle.OriginalDataIndexEnd >= 0) and (HoveredCandle.OriginalDataIndexEnd < FDataController.GetTickDataLength) then // Use GetTickDataLength begin - UTCTimeStart := FDataController.GetTickDataItem(HoveredCandle.OriginalDataIndexStart).TimeStamp; - UTCTimeEnd := FDataController.GetTickDataItem(HoveredCandle.OriginalDataIndexEnd).TimeStamp; + UTCTimeStart := FDataController.GetTickDataItem(HoveredCandle.OriginalDataIndexStart).Time; + UTCTimeEnd := FDataController.GetTickDataItem(HoveredCandle.OriginalDataIndexEnd).Time; LocalTimeStart := TTimeZone.Local.ToLocalTime(UTCTimeStart); LocalTimeEnd := TTimeZone.Local.ToLocalTime(UTCTimeEnd); TimeZoneStr := TTimeZone.Local.GetAbbreviation(LocalTimeStart); // Get abbreviation for the local time zone @@ -1299,7 +1299,7 @@ begin if (CrosshairCandle.OriginalDataIndexStart >= 0) and (CrosshairCandle.OriginalDataIndexStart < FDataController.GetTickDataLength) then // Use GetTickDataLength begin - UTCTimeStart := FDataController.GetTickDataItem(CrosshairCandle.OriginalDataIndexStart).TimeStamp; + UTCTimeStart := FDataController.GetTickDataItem(CrosshairCandle.OriginalDataIndexStart).Time; LocalTimeStart := TTimeZone.Local.ToLocalTime(UTCTimeStart); TimeStr := FormatDateTime('hh:nn:ss', LocalTimeStart); // Display time part diff --git a/common/Myc.ChartDataController.pas b/common/Myc.ChartDataController.pas index e46c195..6dbfaf4 100644 --- a/common/Myc.ChartDataController.pas +++ b/common/Myc.ChartDataController.pas @@ -21,7 +21,7 @@ type TChartDataController = class private - FTickDataArray: TArray>; + FTickDataArray: TArray>; FOHLCCacheList: TList; FTimeframeSettingsArray: TArray; // Now includes registered generic builders FMemoLog: TStrings; @@ -48,7 +48,7 @@ type procedure ClearAllDataAndCaches; function GetTickDataCount: Integer; function GetTickDataLength: Integer; - function GetTickDataItem(AIndex: Integer): TDataRecord; + function GetTickDataItem(AIndex: Integer): TDataPoint; function HasData: Boolean; // ABuilderCaption is the unique key used for FTimeframeSettingsArray.Caption and FGenericBuilders key. @@ -512,7 +512,7 @@ begin Result := Length(FTickDataArray); end; -function TChartDataController.GetTickDataItem(AIndex: Integer): TDataRecord; +function TChartDataController.GetTickDataItem(AIndex: Integer): TDataPoint; begin if (AIndex >= 0) and (AIndex < Length(FTickDataArray)) then Result := FTickDataArray[AIndex] @@ -522,7 +522,7 @@ begin FMemoLog.Add( Format('DataController: Attempted to access invalid tick data index %d. Count is %d.', [AIndex, Length(FTickDataArray)]) ); - Result := Default(TDataRecord); + Result := Default(TDataPoint); end; end; diff --git a/common/Myc.OHLCCache.pas b/common/Myc.OHLCCache.pas index ab480f3..f38a885 100644 --- a/common/Myc.OHLCCache.pas +++ b/common/Myc.OHLCCache.pas @@ -56,8 +56,8 @@ type // Interface for generic candle building logic IGenericCandleBuilder = interface - function Init(const ADataSet: TArray>): Boolean; // Changed DataSet to ADataSet for clarity - function IsNewBar(AIndex: Integer; const ATick: TDataRecord): Boolean; // Changed Idx to AIndex, Tick to ATick + function Init(const ADataSet: TArray>): Boolean; // Changed DataSet to ADataSet for clarity + function IsNewBar(AIndex: Integer; const ATick: TDataPoint): Boolean; // Changed Idx to AIndex, Tick to ATick function GetCaption: string; // Method for the Caption property property Caption: string read GetCaption; end; @@ -80,7 +80,7 @@ type public constructor Create; procedure ClearCache; - procedure Build(const ATickData: TArray>; + procedure Build(const ATickData: TArray>; ASelectedTimeframeSeconds: Int64; AAutoAggCandleWidth: Integer; AAutoAggCandleSpacing: Integer; @@ -188,7 +188,7 @@ begin Result := Length(FCachedCandles); end; -procedure TOHLC.Build(const ATickData: TArray>; +procedure TOHLC.Build(const ATickData: TArray>; ASelectedTimeframeSeconds: Int64; AAutoAggCandleWidth: Integer; AAutoAggCandleSpacing: Integer; AAutoAggPaintBoxClientWidth: Integer; AMemoForLogging: TStrings; AGenericCandleBuilder: IGenericCandleBuilder = nil); // Parameter changed @@ -200,7 +200,7 @@ var CandleList: TList; TempCandle: TCachedCandle; LogTimePerCandleStr: string; - CurrentTick: TDataRecord; + CurrentTick: TDataPoint; begin if AMemoForLogging <> nil then AMemoForLogging.Add(FormatDateTime('yyyy-mm-dd hh:nn:ss', Now) + Format(' - TOHLC.Build: TF Secs: %d...', @@ -353,8 +353,8 @@ begin SetLength(FCachedCandles, NumCandlesToCacheAuto); if (NumDataPoints > 1) and (NumCandlesToCacheAuto > 0) then begin - var FirstTickTimeVal_A := ATickData[0].TimeStamp; - var LastTickTimeVal_A := ATickData[High(ATickData)].TimeStamp; + var FirstTickTimeVal_A := ATickData[0].Time; + var LastTickTimeVal_A := ATickData[High(ATickData)].Time; var TotalDataDurationDaysVal_A := LastTickTimeVal_A - FirstTickTimeVal_A; if NumCandlesToCacheAuto > 0 then // Avoid division by zero if NumCandlesToCacheAuto is somehow 0 here begin @@ -432,7 +432,7 @@ begin CurrentTickIndex := 0; while CurrentTickIndex <= High(ATickData) do begin - BucketStartTimeOADate := Floor(ATickData[CurrentTickIndex].TimeStamp / TimeframeIntervalOADays) * TimeframeIntervalOADays; + BucketStartTimeOADate := Floor(ATickData[CurrentTickIndex].Time / TimeframeIntervalOADays) * TimeframeIntervalOADays; BucketEndTimeOADate := BucketStartTimeOADate + TimeframeIntervalOADays; DataIndexStart := CurrentTickIndex; @@ -444,8 +444,8 @@ begin // Iterate through ticks that fall into the current bucket while (CurrentTickIndex <= High(ATickData)) and - (ATickData[CurrentTickIndex].TimeStamp >= BucketStartTimeOADate) and - (ATickData[CurrentTickIndex].TimeStamp < BucketEndTimeOADate) do + (ATickData[CurrentTickIndex].Time >= BucketStartTimeOADate) and + (ATickData[CurrentTickIndex].Time < BucketEndTimeOADate) do begin if ATickData[CurrentTickIndex].Data.Ask > HighPrice then HighPrice := ATickData[CurrentTickIndex].Data.Ask; // Changed if ATickData[CurrentTickIndex].Data.Ask < LowPrice then LowPrice := ATickData[CurrentTickIndex].Data.Ask; // Changed @@ -492,8 +492,8 @@ begin if Length(ATickData) > 0 then begin - var FirstTickTimeVal := ATickData[0].TimeStamp; - var LastTickTimeVal := ATickData[High(ATickData)].TimeStamp; + var FirstTickTimeVal := ATickData[0].Time; + var LastTickTimeVal := ATickData[High(ATickData)].Time; FTotalDataTimeSpanText := FormatTimeSpanFromSeconds((LastTickTimeVal - FirstTickTimeVal) * SecsPerDay_Double); if AMemoForLogging <> nil then AMemoForLogging.Add(Format('TOHLC.Build: Total data time span: %s.', [FTotalDataTimeSpanText]));