Recent

Author Topic: Hint tools gives wrong hints  (Read 308 times)

Nicole

  • Hero Member
  • *****
  • Posts: 1324
Hint tools gives wrong hints
« on: May 11, 2026, 03:29:03 pm »
I want a hover hint giving me information, which are the values of my series.
Wherever I try: The values are wrong.
In the area of the year 2017 is shown a date of 2015, in the area of August is shown March and so on.
Please check the screenshot for one example. This is not true sometimes, but frequently.

My method is this:

Code: Pascal  [Select][+][-]
  1. // gibt die Werte der Kurven unter dem Cursor aus
  2. procedure TFrame_cot_dis.Tool_HintHint(ATool: TDataPointHintTool;
  3.   const APoint: TPoint; var AHint: String);
  4. var lineSer: TLineSeries;
  5.     ohlcSeries: TOpenHighLowCloseSeries;
  6.     idx: Integer;
  7.     O, H, L, C: Double;
  8.     dt: TDateTime;
  9.     yidx, {%H-}YWert: Integer;  //yWert brauche ich
  10.     ttl: String;
  11.     s: string;
  12. begin
  13.   yidx:=0;
  14.   with TDatapointHintTool(ATool) do begin  // Vorteil zu "with.. as" => keine Exception
  15.     if Series is TLineSeries then begin
  16.       lineSer := TLineSeries(Series);
  17.       idx := PointIndex;
  18.       YWert := YIndex;
  19.       if lineser <> nil then begin
  20.         if yidx > 0 then
  21.             ttl := TLineSeries(lineser).Styles.Styles[yidx].Text
  22.           else begin
  23.             ttl := lineser.Title;
  24.             s := Zeit.StringDoubleWirdString(FloatToStr(lineser.GetXValue(idx)));
  25.             AHint := ttl +': '+ FloatToStrF(lineser.GetYValue(idx), ffFixed, 4, 0)+ ' (' + s + ')';
  26.               end
  27.           end else AHint := '';
  28.     end
  29.     else if series is TOpenHighLowCloseSeries then begin
  30.       ohlcSeries := TOpenHighLowCloseSeries(Series);
  31.       idx := ATool.PointIndex;
  32.       dt := OHLCSeries.XValue[idx];
  33.       O := OHLCSeries.YValues[idx, OHLCSeries.YIndexOpen];
  34.       H := OHLCSeries.YValues[idx, OHLCSeries.YIndexHigh];
  35.       L := OHLCSeries.YVAlues[idx, OHLCSeries.YIndexLow];
  36.       C := OHLCSeries.YValues[idx, OHLCSeries.YIndexClose];
  37.       //VolumeSeries.YValue[idx];  // Assuming that this is a TLineSeries displaying the volume of transactions on this date
  38.       AHint := Format(
  39.         'Date: %s' + LineEnding +
  40.         'Open: %.2n'+LineEnding+
  41.         'High: %.2n' + LineEnding +
  42.         'Low: %.2n' + LineEnding +
  43.         'Close: %.2n'    // 'Volume: %.2n $'
  44.         , [
  45.         DateToStr(dt),
  46.         O, H, L, C
  47.         // ,volume
  48.       ]);
  49.  
  50.     end
  51.     else exit; end;
  52.  
  53. end;        
  54.  

wp

  • Hero Member
  • *****
  • Posts: 13558
Re: Hint tools gives wrong hints
« Reply #1 on: May 11, 2026, 11:54:21 pm »
Do the two series, the LineSeries and the OHLCSeries, have the same x values?

Nicole

  • Hero Member
  • *****
  • Posts: 1324
Re: Hint tools gives wrong hints
« Reply #2 on: May 12, 2026, 10:43:50 am »
Yes, they all shall contain weekly data of the same time period.
However I am not sure, if the specific day is the same in all cases.
I have one table containing the COT data and a different one containing the rates.

The drawing of the data is correct to my mind.
The hint is severely wrong. Sometimes the data shows 2015 instead of 2017.
Most series are taken by the same SQL query.

Best I show my query, it is triggered by this:

Code: Pascal  [Select][+][-]
  1.   // zu zeichnende Werte werden aus der DB abgefragt
  2.   COT_DisA_:=Lies_DCOT_fuerGrafik(self); // Query: füllt das TCOT_DisA mit Daten aus TBCOT_DIS
  3.   Anzahl:=Length(COT_DisA_);  // hier war -1? warum?
  4.   if anzahl <= 0 then Begin
  5.     ShowMessage('zu dieser Waren, in diesem Zeitintervall gibt es keine Daten.');
  6.     exit;
  7.   end;  
  8.  

drawn by this:

Code: Pascal  [Select][+][-]
  1.   // die Variable COT_DisA_ wird den Serien zugewiesen und gezeichnet
  2.   for i := 0 to Length(COT_DisA_) - 1 do  begin
  3.      series_OPEN_INTEREST.AddXY(COT_DisA_[i].datum, COT_DisA_[i].OPEN_INTEREST);
  4.      series_PROD_LONG.AddXY(COT_DisA_[i].datum, COT_DisA_[i].PROD_LONG);
  5.      series_PROD_NET.AddXY(COT_DisA_[i].datum, COT_DisA_[i].PRODNet);
  6.      series_PROD_SHORT.AddXY(COT_DisA_[i].datum, COT_DisA_[i].PROD_SHORT);
  7.        .....
  8. much more
  9.  


and this is the query-method:

Code: Pascal  [Select][+][-]
  1.  
  2. // füllt COT_DisA zu Anfangs- und Enddaten des Formulars für eine Ware
  3. function TFrame_cot_dis.Lies_DCOT_fuerEineWare(ware_: string): TCOT_DisA;
  4. var s: string;
  5.     i, Anzahl: integer;
  6. begin
  7.   IBSQL_Cot_Agr.close;
  8.   s := 'select count(datum) as anzahl from TBCOT_DIS where comm = :ware_ '
  9.       + 'and DATUM >= :MY_AnfJDATUM and DATUM <= :MY_EndJDATUM';
  10.   IBSQL_Cot_Agr.SQL.Text := s;
  11.   IBSQL_Cot_Agr.ParamByName('ware_').AsString := ware_;
  12.   IBSQL_Cot_Agr.ParamByName('MY_AnfJDATUM').AsDateTime := DateTimePicker_Anf_Dis.Date;
  13.   IBSQL_Cot_Agr.ParamByName('MY_EndJDATUM').AsDateTime := DateTimePicker_Ende_Dis.Date;
  14.   IBSQL_Cot_Agr.ExecQuery;
  15.   Anzahl := IBSQL_Cot_Agr.FieldByName('anzahl').AsInteger;
  16.   IBSQL_Cot_Agr.close;
  17.  
  18.   if Anzahl < 1 then begin
  19.     SetLength(Result{%H-}, 0);  // Statt Result := nil  sagt Devin
  20.     exit;
  21.   end;
  22.  
  23.   SetLength(Result{%H-}, Anzahl);
  24.   s := 'select ID_COT_DIS, DATUM, COMM, OPEN_INTEREST, '
  25.       + 'PROD_LONG, PROD_SHORT, SWAP_LONG, SWAP_SHORT, SWAP_SPREAD, '
  26.       + 'MMONEY_LONG, MMONEY_SHORT, MMONEY_SPREAD, '
  27.       + 'OTHER_LONG, OTHER_SHORT, OTHER_SPREAD, '
  28.       + 'NONREP_LONG, NONREP_SHORT, '
  29.       + 'CONC_4_LONG, CONC_4_SHORT, CONC_8_LONG, CONC_8_SHORT, '
  30.       + 'CONC_NET_4_LONG, CONC_NET_4_SHORT, CONC_NET_8_LONG, CONC_NET_8_SHORT '
  31.       + 'from TBCOT_DIS where comm = :ware_ '
  32.       + 'and DATUM >= :MY_AnfJDATUM and DATUM <= :MY_EndJDATUM '
  33.       + 'order by datum';
  34.   IBSQL_Cot_Agr.close;
  35.   IBSQL_Cot_Agr.SQL.Text := s;
  36.   IBSQL_Cot_Agr.ParamByName('ware_').AsString := ware_;
  37.   IBSQL_Cot_Agr.ParamByName('MY_AnfJDATUM').AsDateTime := DateTimePicker_Anf_Dis.Date;
  38.   IBSQL_Cot_Agr.ParamByName('MY_EndJDATUM').AsDateTime := DateTimePicker_Ende_Dis.Date;
  39.   IBSQL_Cot_Agr.ExecQuery;
  40.  
  41.   i := 0;
  42.   while not IBSQL_Cot_Agr.Eof do
  43.   begin
  44.     Result[i].ID_COT_Dis := IBSQL_Cot_Agr.FieldByName('ID_COT_DIS').AsInteger;
  45.     Result[i].DATUM := trunc(IBSQL_Cot_Agr.FieldByName('DATUM').AsDateTime);
  46.     Result[i].COMM := IBSQL_Cot_Agr.FieldByName('COMM').AsString;
  47.     Result[i].OPEN_INTEREST := IBSQL_Cot_Agr.FieldByName('OPEN_INTEREST').AsInteger;
  48.     Result[i].PROD_LONG := IBSQL_Cot_Agr.FieldByName('PROD_LONG').AsInteger;
  49.     Result[i].PROD_SHORT := IBSQL_Cot_Agr.FieldByName('PROD_SHORT').AsInteger;
  50.     Result[i].ProdNet:=Result[i].PROD_LONG - Result[i].PROD_SHORT;
  51.     Result[i].SWAP_LONG := IBSQL_Cot_Agr.FieldByName('SWAP_LONG').AsInteger;
  52.     Result[i].SWAP_SHORT := IBSQL_Cot_Agr.FieldByName('SWAP_SHORT').AsInteger;
  53.     Result[i].SWAP_SPREAD := IBSQL_Cot_Agr.FieldByName('SWAP_SPREAD').AsInteger;
  54.     Result[i].MMONEY_LONG := IBSQL_Cot_Agr.FieldByName('MMONEY_LONG').AsInteger;
  55.     Result[i].MMONEY_SHORT := IBSQL_Cot_Agr.FieldByName('MMONEY_SHORT').AsInteger;
  56.     Result[i].MMONEY_SPREAD := IBSQL_Cot_Agr.FieldByName('MMONEY_SPREAD').AsInteger;
  57.     Result[i].OTHER_LONG := IBSQL_Cot_Agr.FieldByName('OTHER_LONG').AsInteger;
  58.     Result[i].OTHER_SHORT := IBSQL_Cot_Agr.FieldByName('OTHER_SHORT').AsInteger;
  59.     Result[i].OTHER_SPREAD := IBSQL_Cot_Agr.FieldByName('OTHER_SPREAD').AsInteger;
  60.     Result[i].NONREP_LONG := IBSQL_Cot_Agr.FieldByName('NONREP_LONG').AsInteger;
  61.     Result[i].NONREP_SHORT := IBSQL_Cot_Agr.FieldByName('NONREP_SHORT').AsInteger;
  62.     Result[i].conc_4_long := IBSQL_Cot_Agr.FieldByName('CONC_4_LONG').AsFloat;
  63.     Result[i].conc_4_short := IBSQL_Cot_Agr.FieldByName('CONC_4_SHORT').AsFloat;
  64.     Result[i].conc_8_long := IBSQL_Cot_Agr.FieldByName('CONC_8_LONG').AsFloat;
  65.     Result[i].conc_8_short := IBSQL_Cot_Agr.FieldByName('CONC_8_SHORT').AsFloat;
  66.     Result[i].conc_net_4_long := IBSQL_Cot_Agr.FieldByName('CONC_NET_4_LONG').AsFloat;
  67.     Result[i].conc_net_4_short := IBSQL_Cot_Agr.FieldByName('CONC_NET_4_SHORT').AsFloat;
  68.     Result[i].conc_net_8_long := IBSQL_Cot_Agr.FieldByName('CONC_NET_8_LONG').AsFloat;
  69.     Result[i].conc_net_8_short := IBSQL_Cot_Agr.FieldByName('CONC_NET_8_SHORT').AsFloat;
  70.     Inc(i);
  71.     IBSQL_Cot_Agr.Next;
  72.   end;
  73.   IBSQL_Cot_Agr.close;
  74.  
  75. end;        
  76.  
  77.  

wp

  • Hero Member
  • *****
  • Posts: 13558
Re: Hint tools gives wrong hints
« Reply #3 on: May 12, 2026, 10:29:45 pm »
Hard to tell from these snippets...

In the code of the first post there is a line "s := Zeit.StringDoubleWirdString(FloatToStr(lineser.GetXValue(idx)));". What is this "Zeit"? It not mentioned anywhere in the this procedure. Seems to be some "time", and it is not clear whether it is in sync with the series x values.

You screenshot, on the other hand, shows the discrepancy for the OHLC series to which this "Zeit" variable does not apply...

Nicole

  • Hero Member
  • *****
  • Posts: 1324
Re: Hint tools gives wrong hints
« Reply #4 on: May 13, 2026, 01:11:47 pm »
I do not suspect Zeit.

Code: Pascal  [Select][+][-]
  1. // versucht, einen String in ein Julian-Datum umzuwandeln und formatiert es
  2. function TZeit.StringDoubleWirdString(dat: string): string;
  3. var  d: double;
  4. begin
  5.   Result := 'ungültiges Datum';
  6.   if not TryStrToFloat(dat, d) then exit;
  7.   Result := FormatDateTime('dd.mm.yyyy', d);
  8. end;
  9.  

Is it possible, that is has to do something with the graphic interface? The cursor does not "know" above which curve it is? Sometimes I hover above a line series and the candle hint is shown. This is rather small it is about the y-axes. The huge problem is the x-axes. It feels if the position of the cursor would not work fine.
I have really many series. Between 30 and 40. I cannot do it below. The user wants to compare them.

 

TinyPortal © 2005-2018