Dear Customer Support,
I need your help for the following queries. My application has couple of series defined below (alongwith TChartgrid comments) aginst each:-
type
TFChart01 = class(TForm)
Chart1: TChart;
Series1: TCandleSeries; // Candle- Text,Close,High,Low,Close Index -0
Series5: TVolumeSeries; // Volume=Y Index=1
Series2: TLineSeries; // EMA 1 - Y Index-2
TeeFunction1: TExpMovAveFunction;
Series3: TLineSeries; // EMA 2 - Y Index-3
TeeFunction2: TExpMovAveFunction;
Series4: TLineSeries; // EMA 3 - Y Index-4
TeeFunction3: TExpMovAveFunction;
Series6: TLineSeries; // Vol EMA -Y, Index-5
TeeFunction4: TExpMovAveFunction;
Series7: TLineSeries; //Bollinger Band-XY, Index-6
TeeFunction5: TBollingerFunction;
Series8: TLineSeries; //CLV-Y Index 7
TeeFunction6: TCLVFunction;
Series9: TLineSeries; //STochastics XY Index-8
TeeFunction7: TStochasticFunction;
// Index 9,11,12 seem to refer to MACD & Index 10 to Bollingerbands
Series10: TLineSeries; //MACD Y,XY,Y,Y Index 9-12
TeeFunction8: TMACDFunction;
ChartGrid1: TChartGrid;
The questions I have pertaining to the above are:
Q1. How do I turn off & on or make invisible/visible Bollinger Bands & MACD programmatically ? Am using the following right now with erratic results
Bollinger Band
TeeFunction5.LowBand.Visible:=false;
Series7.Visible:=false;
MACD
Series10.Visible:=false
(need to turn off/on histogram, MACD line & MACD trigger)
Q2. How do I capture the data values for Bollinger upperband, Bollinger lower band, Bollinger mean average line, MACD histogram, MACD line, MACD trigger line. Will appreciate giving me the layout of series for MACD as given by TChartgrid.
Q3. At times I find the Bollinger upper and lower bands crossing each other. What could be causing this behaviour ? To my mind this should never happen !!
Q4. When using TChartlistbox - all series for Chart1 get displayed. How can one disable some of them and keep others enabled ? I need to use few of them selectively with checkboxes in one TChartlistbox and few other with radio buttons in another TChartlistbox.
Q5. Am using CLV function but the series does not change whenever I change it's period. What is the correct way to change the CLV period and recalculate it ? Candle and Volume series are being fed manually. The program stub I am using is:-
TeeFunction6.Period:=Spinedit7.Value; //default 20
Series8.CheckDataSource;
Will appreciate a quick and detailed response to the above queries.
Regards,
Satish
Clarifications on TeeChart - VCL (Delphi 7)
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Satish,
If you have a look at the code below where Series1 is a TBarSeries and the chart has a TMACDFunction with Series1 as its datasource, you'll have 4 series (1 Bar Series and 3 internal series generated for the MACD function). According to this, to access those internal series you need to use their index in the chart as done in the button's code below, which shows and hides the MACD function completely. Also notice that the indexes start at 0.
Could you please send us an example we can run "as-is" to reproduce this problem here? You can post your files at [url]news://www.steema.net/steema.public.attachments[/url] newsgroup.
To achieve that you should have a look at the "Series groups" example at TeeChart's features demo which is available at TeeChart's program group.
You could also have 2 list boxes with a series group each.
Another option would be using:
The ShowInEditor property will be available with the next maintenance release.
Q1. How do I turn off & on or make invisible/visible Bollinger Bands & MACD programmatically ? Am using the following right now with erratic results
Bollinger Band
TeeFunction5.LowBand.Visible:=false;
Series7.Visible:=false;
MACD
Series10.Visible:=false
(need to turn off/on histogram, MACD line & MACD trigger)
If you have a look at the code below where Series1 is a TBarSeries and the chart has a TMACDFunction with Series1 as its datasource, you'll have 4 series (1 Bar Series and 3 internal series generated for the MACD function). According to this, to access those internal series you need to use their index in the chart as done in the button's code below, which shows and hides the MACD function completely. Also notice that the indexes start at 0.
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
begin
Series1.FillSampleValues();
Chart1.Title.Text[0]:='Number of series: '+IntToStr(Chart1.SeriesCount);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Chart1[1].Visible:=not Chart1[1].Visible;
Chart1[2].Visible:=not Chart1[2].Visible;
Chart1[3].Visible:=not Chart1[3].Visible;
end;
You will know how many lines you have by outputing Chart1.SeriesCount, series index will range from 0 to Chart1.SeriesCount-1 so that you can access any series value using something like:Q2. How do I capture the data values for Bollinger upperband, Bollinger lower band, Bollinger mean average line, MACD histogram, MACD line, MACD trigger line. Will appreciate giving me the layout of series for MACD as given by TChartgrid.
Code: Select all
Chart1[SeriesIndex].YValue[ValueIndex]
Q3. At times I find the Bollinger upper and lower bands crossing each other. What could be causing this behaviour ? To my mind this should never happen !!
Could you please send us an example we can run "as-is" to reproduce this problem here? You can post your files at [url]news://www.steema.net/steema.public.attachments[/url] newsgroup.
Q4. When using TChartlistbox - all series for Chart1 get displayed. How can one disable some of them and keep others enabled ? I need to use few of them selectively with checkboxes in one TChartlistbox and few other with radio buttons in another TChartlistbox.
To achieve that you should have a look at the "Series groups" example at TeeChart's features demo which is available at TeeChart's program group.
You could also have 2 list boxes with a series group each.
Another option would be using:
Code: Select all
type
TSeriesAccess=class(TChartSeries);
procedure TForm1.FormCreate(Sender: TObject);
begin
// Series1.ShowInEditor:=False; // <-- New ( 7.06 )
TSeriesAccess(Series3).InternalUse:=True; // <-- Old (7.0x)
end;
This is because Period property doesn't apply to that function and is internally disabled because it's computed for each point. However, I'll add this request to our wish-list to be considered for future releases.Q5. Am using CLV function but the series does not change whenever I change it's period. What is the correct way to change the CLV period and recalculate it ? Candle and Volume series are being fed manually. The program stub I am using is:-
TeeFunction6.Period:=Spinedit7.Value; //default 20
Series8.CheckDataSource;
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Clarifications Teechart -VCL
Narcis,
Thanks for your quick response. Most of my issues are resolved. The Bollinger band overlap was being caused by absence of specification for the axis of the lower band series - have been able to correct that.
I recommend that the documentation be beefed up for financial functions that use additional internal series. Also, could you point me to any examples where I could draw color-filled boxes from a particular H-L bar to a subsequent one.
Thanks a lot !!
Satish
Thanks for your quick response. Most of my issues are resolved. The Bollinger band overlap was being caused by absence of specification for the axis of the lower band series - have been able to correct that.
I recommend that the documentation be beefed up for financial functions that use additional internal series. Also, could you point me to any examples where I could draw color-filled boxes from a particular H-L bar to a subsequent one.
Thanks a lot !!
Satish
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Satish,
You're welcome.
I'll add your documentation request to our wish-list to be considered for future releases. Regarding the color-filled boxes, could you please be more specific about what are you exactly looking for? If you want you can post an image at our public newsgroups: [url]news://www.steema.net/steema.public.attachments[/url].
You're welcome.
I recommend that the documentation be beefed up for financial
functions that use additional internal series. Also, could you point me to any examples where I could draw color-filled boxes from a particular H-L bar to a subsequent one.
I'll add your documentation request to our wish-list to be considered for future releases. Regarding the color-filled boxes, could you please be more specific about what are you exactly looking for? If you want you can post an image at our public newsgroups: [url]news://www.steema.net/steema.public.attachments[/url].
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Drawing rectangles/boxes on a OHLC chart
Narcis,
I basically desire to draw Darvas boxes on an OHLC chart -not sure if you are conversant with them or not. A simple explanation is as follows:-
1. Assume 10 OHLC bars with index X index serials 1 to 10.
2. Need to draw a box which has X range index 1 to 10 (covers all 10 bars), top of box is High of say Bar 5 and bottom of box is say Low of Bar 9.
3. Need to draw this box and fill it with a partcular color -say red.
4. Basically I need reference to commands/examples to draw horizontal lines, vertical lines and rectangles where I know the X index/serial numbers of the OHLC bars (Candle series). How does one convert the bar X index value to X & Y coordinates (need Y coordinates for both High/Low values of a OHLC bar). What commands can be used in Teechart to draw horizontal/vertical lines & boxes on top of charts ?
Thanks
Satish
I basically desire to draw Darvas boxes on an OHLC chart -not sure if you are conversant with them or not. A simple explanation is as follows:-
1. Assume 10 OHLC bars with index X index serials 1 to 10.
2. Need to draw a box which has X range index 1 to 10 (covers all 10 bars), top of box is High of say Bar 5 and bottom of box is say Low of Bar 9.
3. Need to draw this box and fill it with a partcular color -say red.
4. Basically I need reference to commands/examples to draw horizontal lines, vertical lines and rectangles where I know the X index/serial numbers of the OHLC bars (Candle series). How does one convert the bar X index value to X & Y coordinates (need Y coordinates for both High/Low values of a OHLC bar). What commands can be used in Teechart to draw horizontal/vertical lines & boxes on top of charts ?
Thanks
Satish
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Satish,
I've done an example of how to draw a Darvas box in a OHLC chart according to your specifications. This is an interesting feature we may implement for future versions.
Below you have the full code for the form, just place a TChart with an OHLC series to it, 2 edit boxes and a button. If you want I can send you the full project.
I've done an example of how to draw a Darvas box in a OHLC chart according to your specifications. This is an interesting feature we may implement for future versions.
Below you have the full code for the form, just place a TChart with an OHLC series to it, 2 edit boxes and a button. If you want I can send you the full project.
Code: Select all
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, TeEngine, Series, OHLChart, CandleCh, ExtCtrls, TeeProcs, Chart,
StdCtrls, TeeComma, TeCanvas;
type
TForm1 = class(TForm)
Chart1: TChart;
Series1: TCandleSeries;
Edit1: TEdit;
Label1: TLabel;
Label2: TLabel;
Edit2: TEdit;
Button1: TButton;
TeeCommander1: TTeeCommander;
procedure FormCreate(Sender: TObject);
procedure Chart1AfterDraw(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
procedure DrawDarvasBox(StartIndex, EndIndex: Integer);
public
{ Public declarations }
end;
var
Form1: TForm1;
x0,y0,x1,y1: Integer;
Go: Boolean;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
Series1.FillSampleValues();
Chart1.View3D:=false;
Go:=false;
end;
procedure TForm1.Chart1AfterDraw(Sender: TObject);
var
transparency : TTeeTransparency;
blend : TTeeBlend;
BoxRect: TRect;
begin
if Go then
begin
transparency:=70;
BoxRect:=Rect(x0,y0,x1,y1);
blend := Chart1.Canvas.BeginBlending(BoxRect, transparency);
Chart1.Canvas.Brush.Color:=clGreen;
Chart1.Canvas.Pen.Color:=clGreen;
Chart1.Canvas.Rectangle(BoxRect) ;
Chart1.Canvas.EndBlending(blend);
end;
end;
procedure TForm1.DrawDarvasBox(StartIndex, EndIndex: Integer);
var i, MinIndex, MaxIndex: Integer;
begin
if ((StartIndex>=0) and (EndIndex<Series1.Count)
and (StartIndex<EndIndex)) then
begin
MinIndex:=StartIndex;
MaxIndex:=StartIndex;
for i:=StartIndex+1 to EndIndex do
begin
if (Series1.LowValues.Value[i]<Series1.LowValues.Value[MinIndex]) then
MinIndex:=i
else if (Series1.HighValues.Value[i]>Series1.HighValues.Value[MaxIndex]) then
MaxIndex:=i;
end;
Chart1.Title.Text[0]:=IntToStr(MinIndex)+', '+IntToStr(MaxIndex);
x0:=Series1.CalcXPos(StartIndex);
y0:=Chart1.Axes.Left.CalcYPosValue(Series1.HighValues.Value[MaxIndex]);
x1:=Series1.CalcXPos(EndIndex);
y1:=Chart1.Axes.Left.CalcYPosValue(Series1.LowValues.Value[MinIndex]);
Go:=true;
end
else
begin
Go:=false;
ShowMessage('Wrong indexes');
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
DrawDarvasBox(StrToInt(Edit1.Text), StrToInt(Edit2.Text));
end;
end.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Clarifications - TeeChart
Narcis,
Thanks a lot for the wonderful code !! Will appreciate if you could send me the complete project in zipped format.
Regards,
Satish
Thanks a lot for the wonderful code !! Will appreciate if you could send me the complete project in zipped format.
Regards,
Satish
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
You're welcome Satish.
I've just sent you the project.
BTW: Could you give me some tip (a URL will be enough) on which specs. do you think we should follow to develop Darvas boxes feature?
Thanks in advance.
I've just sent you the project.
BTW: Could you give me some tip (a URL will be enough) on which specs. do you think we should follow to develop Darvas boxes feature?
Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |