OHLC - Draw weekly and Monthly lazarus / 55-TAChart ---------------------------------------------------------------------- Nicole · 2025-12-18 17:38 Lazarus 4.4 There is an array with daily date - OHLC data. I want to draw them weekly: The first quote of Monday shall be "open", the last quote of Friday shall be "close". and so on. Must I calculate this by myself or is there a way in TAChart that I just can set my series to "weekly". There are a lot of series in that chart. All other are weekly. to add: They shall use the same bottom axis and a different left axis. The axes thing shall have a solution and not part of the question. What is my question here: How to display this daily data in a weekly chart most efficiently? Thanks. ---------------------------------------------------------------------- wp · 2025-12-18 19:19 TAChart only does the drawing of numbers passed on to it. If your primary data sources are daily rather than weekly you must do the calculation to get weekly data yourself. ---------------------------------------------------------------------- Nicole · 2025-12-19 16:34 Thank you for your answer. As it was tricky to solve it, I share a method, which converts weekly to daily. Tricky, because we need a solution that will work as well, if Monday is a holiday or a data error says zero one day. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i // verwandelt Tageskurse in Wochenkursefunction TFrame_cot_dis.DailyInWeekly(Kurse: TKurseF): TKurseF;var i: Integer;    LastWeek, WeekIndex: Integer;begin  if Length(Kurse) = 0 then begin     ShowMessage('TFrame_cot_dis.DailyInWeekly: leeres Array wurde übergeben');     result:=Kurse;     Exit;   end;   SetLength(Result, Length(Kurse));   LastWeek := 0;  WeekIndex := 0;   for i := 0 to High(Kurse) do begin   // sucht nach der Wochennummer    if WeekOf(Kurse[i].Datum) <> LastWeek then begin        Result[WeekIndex].Datum := Kurse[i].Datum;        Result[WeekIndex].open := Kurse[i].open;   // das stimmt auch, wenn Feiertage vorhanden sind        Result[WeekIndex].high := Kurse[i].high;        Result[WeekIndex].low := Kurse[i].low;        if (Result[WeekIndex].low = 0) and (i > 0)           then Result[WeekIndex].low:=Result[WeekIndex-1].low;        Result[WeekIndex].close := Kurse[i].close;        LastWeek := WeekOf(Kurse[i].Datum);        Inc(WeekIndex);      end else begin      if Kurse[i].high > Result[WeekIndex-1].high then          Result[WeekIndex-1].high := Kurse[i].high;         if (Kurse[i].low < Result[WeekIndex-1].low) and (Kurse[i].low > 0) then          Result[WeekIndex-1].low := Kurse[i].low;         Result[WeekIndex-1].close := Kurse[i].close;        Result[WeekIndex-1].Datum := Kurse[i].Datum;      end;    end;        SetLength(Result, WeekIndex);  // das array wird auf die Zahlen beschnittenend; where Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Type TEineKontraktZeile = packed Record   //eine Kursdatenzeile für Futures     id_kurszeile: integer;  // id der DB     Datum: TDateTime;     open, high, low, close, Volume, OpenInterest: double;   wert: double;        end;Type TKurseF  = array of TEineKontraktzeile;       //alle Kurse eines Kontrakte ---------------------------------------------------------------------- wp · 2025-12-19 18:30 Quote from: Nicole on December 19, 2025, 05:34:09 pmCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i // verwandelt Tageskurse in Wochenkurse        if (Result[WeekIndex].low = 0) and (i > 0)           then Result[WeekIndex].low:=Result[WeekIndex-1].low; Does this mean that the weekly low-value carries over from the previous week to the current week? I cannot believe that this is correct. Because then a week could never have a higher low value than all weeks before. ---------------------------------------------------------------------- Nicole · 2025-12-19 19:02 I hope, I do not misunderstand you, because I am really tired for today. What was my problem: sometimes the low values jumps to zero, because the data are not complete. Then it is better to have a false low value than a zero value, because it destroys the scaling. I must figure out, if this is true for other values as well, e.g. the close. ---------------------------------------------------------------------- wp · 2025-12-19 21:32 Quote from: Nicole on December 19, 2025, 08:02:23 pmI hope, I do not misunderstand you, because I am really tired for today.  Then it is better to have a false low value than a zero value But, suppose the new week has very high prices, and the real "low" is much higher than the false low copied from last week. In this case the low value for this week will be wrong... In case of a missing low value for the first day of a new week why don't you calculate an estimated low from the other values that you have for this day: estimated_low := Min(open, close). Whenthe  next days of this same week have higher prices the estimated_low will be closer to reality than the low of last week. ---------------------------------------------------------------------- Nicole · 2025-12-20 20:53 Thank you so much for your thoughts! They are on my desktop for next week.