Hi!
What is the best way to parse fields (for example) 2,3,4,5 for showing a candle chart.
The lines are originally in a Tmemo
Thanks for helping!
what is the best way to parse a textfile or from Tmemo
-
- Newbie
- Posts: 14
- Joined: Mon Feb 27, 2023 12:00 am
-
- Newbie
- Posts: 14
- Joined: Mon Feb 27, 2023 12:00 am
Re: what is the best way to parse a textfile or from Tmemo
1685311200, 4239,75, 4243,25, 4231,5, 4235,5, 4236,75, 6617, 2197
1685311500, 4235,75, 4237,5, 4232, 4233,25, 4234,6, 2521, 890
1685311800, 4233,25, 4234,5, 4231,5, 4232, 4233,3, 1517, 526
1685312100, 4232, 4233, 4230,25, 4232, 4231,5, 1568, 566
1685312400, 4232, 4235, 4231,5, 4233,5, 4233,525, 1154, 448
1685312700, 4233,75, 4234, 4232,25, 4233,5, 4233,1, 708, 294
1685313000, 4233,5, 4234,5, 4231,75, 4232, 4233,25, 808, 319
1685311500, 4235,75, 4237,5, 4232, 4233,25, 4234,6, 2521, 890
1685311800, 4233,25, 4234,5, 4231,5, 4232, 4233,3, 1517, 526
1685312100, 4232, 4233, 4230,25, 4232, 4231,5, 1568, 566
1685312400, 4232, 4235, 4231,5, 4233,5, 4233,525, 1154, 448
1685312700, 4233,75, 4234, 4232,25, 4233,5, 4233,1, 708, 294
1685313000, 4233,5, 4234,5, 4231,75, 4232, 4233,25, 808, 319
-
- Newbie
- Posts: 14
- Joined: Mon Feb 27, 2023 12:00 am
Re: what is the best way to parse a textfile or from Tmemo
SeriesTextSource?
-
- Newbie
- Posts: 14
- Joined: Mon Feb 27, 2023 12:00 am
Re: what is the best way to parse a textfile or from Tmemo
Import from memo.strings?
when using seriestext Tosource .. limitied to 2 fields"
When using TdbChart.. data is correct in text in Teechart but not in tdbchart.. see attached jpg
thanks ahead..
when using seriestext Tosource .. limitied to 2 fields"
When using TdbChart.. data is correct in text in Teechart but not in tdbchart.. see attached jpg
thanks ahead..
- Attachments
-
- chart uncomplete data.jpg (54.88 KiB) Viewed 29339 times
-
- Newbie
- Posts: 14
- Joined: Mon Feb 27, 2023 12:00 am
Re: what is the best way to parse a textfile or from Tmemo
I dont give input for name and data... only for pricefields
-
- Newbie
- Posts: 14
- Joined: Mon Feb 27, 2023 12:00 am
Re: what is the best way to parse a textfile or from Tmemo
Index Close High Low Open
0 0 0 0 0
1 0 4232 0 0
2 4232 0 0 0
3 4232 0 4233 4232
4 0 0 4235 4232
5 0 0 4234 0
6 4232 0 0 0
7 0 0 0 4232
8 4231 0 0 0
9 0 0 4231 4231
10 0 4
0 0 0 0 0
1 0 4232 0 0
2 4232 0 0 0
3 4232 0 4233 4232
4 0 0 4235 4232
5 0 0 4234 0
6 4232 0 0 0
7 0 0 0 4232
8 4231 0 0 0
9 0 0 4231 4231
10 0 4
Re: what is the best way to parse a textfile or from Tmemo
Hello,
A couple of considerations:
- Those strings use the same character (comma
I chose to modify the values from comma
- Those date values look strange. If I take one of them and I convert it to date I get 28605 as year:
After correcting those issues, you should be able to do something like this:
A couple of considerations:
- Those strings use the same character (comma
,
) both as DecimalSeparator
and as FieldSeparator
. You need to change one of them to be able to correctly identify values and fields.I chose to modify the values from comma
,
to dot .
:
Code: Select all
1685311200, 4239.75, 4243.25, 4231.5, 4235.5, 4236.75, 6617, 2197
1685311500, 4235.75, 4237.5, 4232, 4233.25, 4234.6, 2521, 890
1685311800, 4233.25, 4234.5, 4231.5, 4232, 4233.3, 1517, 526
1685312100, 4232, 4233, 4230.25, 4232, 4231.5, 1568, 566
1685312400, 4232, 4235, 4231.5, 4233.5, 4233.525, 1154, 448
1685312700, 4233.75, 4234, 4232.25, 4233.5, 4233.1, 708, 294
1685313000, 4233.5, 4234.5, 4231.75, 4232, 4233.25, 808, 319
Code: Select all
ShowMessage(DateTimeToStr(StrToFloat('1685311200'))); // -> 04/05/28605
Code: Select all
var Series1: TCandleSeries;
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.View3D:=False;
Chart1.Color:=clWhite;
Chart1.Gradient.Visible:=False;
Chart1.Walls.Back.Color:=clWhite;
Chart1.Walls.Back.Gradient.Visible:=False;
Memo1.WordWrap:=False;
FormatSettings.DecimalSeparator:='.';
Series1:=TCandleSeries(Chart1.AddSeries(TCandleSeries));
with Series1 do
begin
DownCloseColor:=1330417;
UpCloseColor:=6519581;
end;
With SeriesTextSource1 do
begin
Series:=Series1;
HeaderLines:=0;
FieldSeparator:=',';
Fields.Clear;
AddField('Date',1).OnGetValue:=DateGetValue;
AddField('High',2);
AddField('Low',3);
AddField('Open',4);
AddField('Close',5);
LoadFromStrings(Memo1.Lines);
end;
end;
procedure TForm1.DateGetValue(Field:TSeriesTextField; const Text:string; var Value:Double);
begin
//Value:=StrToFloat(Text); // -> Correct Date from text
Value:=IncDay(Today, Series1.Count); // I'm using this as alternative to the above
Series1.NotMandatoryValueList.TempValue:=Value;
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |