first and last index of for instance HIGH function

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
senbengtma
Newbie
Newbie
Posts: 15
Joined: Tue Nov 09, 2021 12:00 am

first and last index of for instance HIGH function

Post by senbengtma » Thu May 04, 2023 1:14 pm

I cant access the series that is a function, only series1.

Code: Select all

type
  TForm1 = class(TForm)
    Chart1: TChart;
    Series1: TCandleSeries;
    Series2: TFastLineSeries;
    TeeFunction1: THighTeeFunction;
    Series3: TFastLineSeries;
    TeeFunction2: TLowTeeFunction;
    ChartListBox1: TChartListBox;



    procedure GoToTeechart(sender: TObject; DataId: Integer; RealTimeDataElement: TIABRealTimeData);
    procedure GoToTeechartHistory(Sender: TObject; DataId, Item, Count: Integer; HistoricalChartDataElement: TIABHistoricalChartData);


  private
    { Private declarations }
  public


    { Public declarations }
  end;

var
  Form1: TForm1;
   num:integer;
implementation

{$R *.dfm}


procedure tform1.GoToTeechart(Sender: TObject; DataId: Integer; RealTimeDataElement: TIABRealTimeData);
var
  Open,High,Low,Close: Double;

  first1,last1,first2,last2:integer;

  tid:tdatetime;
begin
  tid:=realtimedataelement.DateTime;
  Open:=RealTimeDataElement.Open;
  High:=RealTimeDataElement.High;
  Low:=RealTimeDataElement.Low;
  Close:=RealTimeDataElement.Close;

  Chart1.LeftAxis.Maximum :=high+1 ;
  Chart1.LeftAxis.minimum :=low-1 ;


  series1.AddCandle(now,open,high,low,close);

  chart1.Axes.Bottom.AdjustMaxMin;
  self.series1.CalcFirstLastVisibleIndex;

  self.Series2.CalcFirstLastVisibleIndex;

  first1:=series1.FirstDisplayedIndex;
  last1:=series1.LastDisplayedIndex;

  first2:=series2.FirstDisplayedIndex;
 last2:=series2.LastDisplayedIndex;

  //first2:=chart1.Series[1].FirstDisplayedIndex;
  //last2:=chart1.Series[1].LastDisplayedIndex;

  codesite.Send(format('first1:%d  first2:%d  last1:%d  last2:%d',[first1,first2,last1,last2]));

senbengtma
Newbie
Newbie
Posts: 15
Joined: Tue Nov 09, 2021 12:00 am

Re: first and last index of for instance HIGH function

Post by senbengtma » Thu May 04, 2023 1:18 pm

first1:0 first2:-1 last1:1 last2:-1
first1:0 first2:-1 last1:2 last2:-1
first1:0 first2:-1 last1:3 last2:-1
first1:0 first2:-1 last1:4 last2:-1

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: first and last index of for instance HIGH function

Post by Yeray » Tue May 09, 2023 12:47 pm

Hello,

You may have missed to add a DataSource to Series2. Ie:

Code: Select all

  Series1:=TCandleSeries(Chart1.AddSeries(TCandleSeries));
  Series1.FillSampleValues;

  TeeFunction1:=THighTeeFunction.Create(Self);
  Series2:=TFastLineSeries(Chart1.AddSeries(TLineSeries));
  Series2.DataSource:=Series1;
  Series2.SetFunction(TeeFunction1);
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

senbengtma
Newbie
Newbie
Posts: 15
Joined: Tue Nov 09, 2021 12:00 am

Re: first and last index of for instance HIGH function

Post by senbengtma » Wed May 10, 2023 11:58 am

thanks but No..

Code: Select all

    object Series1: TCandleSeries
      Legend.Visible = False
      CloseValues.Name = 'Close'
      CloseValues.Order = loNone
      DateValues.Name = 'Date'
      DateValues.Order = loAscending
      HighValues.Name = 'High'
      HighValues.Order = loNone
      LowValues.Name = 'Low'
      LowValues.Order = loNone
      OpenValues.Name = 'Open'
      OpenValues.Order = loNone
      ShowInLegend = False
      DownCloseColor = 1330417
      DownCloseGradient.StartColor = 1330417
      HighLowPen.Color = clDefault
      HighLowPen.EndStyle = esSquare
      UpCloseColor = 6519581
      UpCloseGradient.StartColor = 6519581
    end
    object Series2: TFastLineSeries
      LinePen.Color = 3513587
      XValues.DateTime = True
      XValues.Name = 'X'
      XValues.Order = loAscending
      YValues.Name = 'Y'
      YValues.Order = loNone
      DataSources = (
        'Series1')
      object TeeFunction1: THighTeeFunction
      end
    end

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: first and last index of for instance HIGH function

Post by Yeray » Fri May 12, 2023 10:55 am

Hello,

Maybe you need to add the CheckDataSource after adding a new value to the candle.
Find an example attached.
HighFunctionTest.zip
(3.19 KiB) Downloaded 2404 times
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply