Re: [Lazarus] TAChart CandleStick Chart
"What did you do? Replace the tamultiseries.pas in a TAChart of Lazarus 1.2.4?" Yes. Ok, I'll try svn. Thank you! Regards, Kamen -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
[Lazarus] TAChart CandleStick Chart
>> (please see attached image) Sorry I can't find an attachment here... What did you do? Replace the tamultiseries.pas in a TAChart of Lazarus 1.2.4? I'm not sure if this is gonna work because there have been several changes since 1.2.4. Switch to trunk, and you won't see an error. -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] TAChart CandleStick Chart
When I am loading new financialdemo there is an error (please see attached image). I was updated only tamultiseries.pas from http://svn.freepascal.org/svn/lazarus/trunk/components/tachart/. Which other files I must update? Regards, Kamen Оригинално писмо От: Werner Pamler Относно: [Lazarus] TAChart CandleStick Chart До: lazarus@lists.lazarus.freepascal.org Изпратено на: Понеделник, 2014, Октомври 6 21:45:30 EEST >> How can I make color of the tails like body? I uploaded a small modification today which takes care of your request: the color of the body border and the tails of the CandleStick series is determined by the property CandleStickLinePen. If you set this color to clDefault these lines will be painted in the color of the body. Please see the updated "financial" demo. >> How can I add HorzScrollBar or something like this and keep the scale of CandleStick? In TAChart you can zoom by left-dragging a rectangle across the chart. And you can pan the zoomed window by dragging with the right-mouse button down. Or you can implement more sophisticated features by using the chart tools. In addition, there is a TChartNavScrollbar which you can use to scroll the zoomed window across the chart range. You just have to link its "Chart" property to the chart which you want to control. The "Min" and "Max" of the scrollbar map to the data range used in the chart. To get day-by-day scrolling set the scrollbar's Min and Max to the corresponding values of the horizontal axis (Chart1.GetFullExtent.a.x and b.x) at run-time. Moreover, there is also a TChartNavPanel which displays the full range of the data and encloses the zoomed range by a rectangle. You can drag this rectangle over the chart, and the zoom window will follow automatically. Having "MiniMap" true displays a miniature chart for rough orientation. Again, you have to couple it to the chart of interest by means of the "Chart" property. In my feeling, however, there are still some weaknesses of this component, maybe I can look after them in the next days. BTW: Do you know the TAChart documentation http://wiki.lazarus.freepascal.org/TAChart_documentation? -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus <> -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] TAChart CandleStick Chart
Thank you very much! Regards, Kamen Оригинално писмо От: Werner Pamler Относно: [Lazarus] TAChart CandleStick Chart До: lazarus@lists.lazarus.freepascal.org Изпратено на: Понеделник, 2014, Октомври 6 21:45:30 EEST >> How can I make color of the tails like body? I uploaded a small modification today which takes care of your request: the color of the body border and the tails of the CandleStick series is determined by the property CandleStickLinePen. If you set this color to clDefault these lines will be painted in the color of the body. Please see the updated "financial" demo. >> How can I add HorzScrollBar or something like this and keep the scale of CandleStick? In TAChart you can zoom by left-dragging a rectangle across the chart. And you can pan the zoomed window by dragging with the right-mouse button down. Or you can implement more sophisticated features by using the chart tools. In addition, there is a TChartNavScrollbar which you can use to scroll the zoomed window across the chart range. You just have to link its "Chart" property to the chart which you want to control. The "Min" and "Max" of the scrollbar map to the data range used in the chart. To get day-by-day scrolling set the scrollbar's Min and Max to the corresponding values of the horizontal axis (Chart1.GetFullExtent.a.x and b.x) at run-time. Moreover, there is also a TChartNavPanel which displays the full range of the data and encloses the zoomed range by a rectangle. You can drag this rectangle over the chart, and the zoom window will follow automatically. Having "MiniMap" true displays a miniature chart for rough orientation. Again, you have to couple it to the chart of interest by means of the "Chart" property. In my feeling, however, there are still some weaknesses of this component, maybe I can look after them in the next days. BTW: Do you know the TAChart documentation http://wiki.lazarus.freepascal.org/TAChart_documentation? -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
[Lazarus] TAChart CandleStick Chart
>> How can I make color of the tails like body? I uploaded a small modification today which takes care of your request: the color of the body border and the tails of the CandleStick series is determined by the property CandleStickLinePen. If you set this color to clDefault these lines will be painted in the color of the body. Please see the updated "financial" demo. >> How can I add HorzScrollBar or something like this and keep the scale of CandleStick? In TAChart you can zoom by left-dragging a rectangle across the chart. And you can pan the zoomed window by dragging with the right-mouse button down. Or you can implement more sophisticated features by using the chart tools. In addition, there is a TChartNavScrollbar which you can use to scroll the zoomed window across the chart range. You just have to link its "Chart" property to the chart which you want to control. The "Min" and "Max" of the scrollbar map to the data range used in the chart. To get day-by-day scrolling set the scrollbar's Min and Max to the corresponding values of the horizontal axis (Chart1.GetFullExtent.a.x and b.x) at run-time. Moreover, there is also a TChartNavPanel which displays the full range of the data and encloses the zoomed range by a rectangle. You can drag this rectangle over the chart, and the zoom window will follow automatically. Having "MiniMap" true displays a miniature chart for rough orientation. Again, you have to couple it to the chart of interest by means of the "Chart" property. In my feeling, however, there are still some weaknesses of this component, maybe I can look after them in the next days. BTW: Do you know the TAChart documentation http://wiki.lazarus.freepascal.org/TAChart_documentation? -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] TAChart CandleStick Chart
Thank you for adding CandleStick Chart! I have 2 questions: In OHLC tails are in the same color like body but in CandleStick is not. When I change background to black tails hides. How can I make color of the tails like body? Maybe in CandlestickLinePen add option to copy color from body? When I add big portion of data for example 2 years all period are in screen and CandleStick are too small. How can I add HorzScrollBar or something like this and keep the scale of CandleStick? I can zoom it but I want to scroll back to earlier time period. Kamen Оригинално писмо От: Werner Pamler Относно: [Lazarus] TAChart CandleStick Chart До: lazarus@lists.lazarus.freepascal.org Изпратено на: Вторник, 2014, Септември 16 22:09:11 EEST In r46244 the TOpenHighLowCloseSeries has a new property "Mode": selection "mOHLC" does the standard painting as before while "mChandleStick" paints the candlesticks that you requested. Since your code was mostly a copy of existing code I decided to stick to the old series type, but just add the painting modes. There are also properties "CandleStickUpBrush", "CandleStickDownBrush" and "CandleStickLinePen" to control painting of the up and down bars and the border and shadow line. I also added a little demo "financial" to the "demo" folder of the TAChart installation which demonstrates both modes. It would be nice if you could have a look if everything is fine - I'm not an expert in financial charts. I also fixed the bug which ignored the true minimum of the data - therefore, it is no longer necessary to calculate the minimum by yourself, just have a look at the code in the demo project. And, finally, I modified the AddXOHLC method such that it automatically initializes the size of the YCount of the chart source if the current size would not be enough. -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] TAChart CandleStick Chart
El 16/09/14 a las 16:09, Werner Pamler escibió: In r46244 the TOpenHighLowCloseSeries has a new property "Mode": selection "mOHLC" does the standard painting as before while "mChandleStick" paints the candlesticks that you requested. Since your code was mostly a copy of existing code I decided to stick to the old series type, but just add the painting modes. There are also properties "CandleStickUpBrush", "CandleStickDownBrush" and "CandleStickLinePen" to control painting of the up and down bars and the border and shadow line. I also added a little demo "financial" to the "demo" folder of the TAChart installation which demonstrates both modes. It would be nice if you could have a look if everything is fine - I'm not an expert in financial charts. I also fixed the bug which ignored the true minimum of the data - therefore, it is no longer necessary to calculate the minimum by yourself, just have a look at the code in the demo project. And, finally, I modified the AddXOHLC method such that it automatically initializes the size of the YCount of the chart source if the current size would not be enough. Great!, I'll take a look later today. -- Leonardo M. Ramé Medical IT - Griensu S.A. Av. Colón 636 - Piso 8 Of. A X5000EPT -- Córdoba Tel.: +54(351)4246924 +54(351)4247788 +54(351)4247979 int. 19 Cel.: +54 9 (011) 40871877 -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
[Lazarus] TAChart CandleStick Chart
In r46244 the TOpenHighLowCloseSeries has a new property "Mode": selection "mOHLC" does the standard painting as before while "mChandleStick" paints the candlesticks that you requested. Since your code was mostly a copy of existing code I decided to stick to the old series type, but just add the painting modes. There are also properties "CandleStickUpBrush", "CandleStickDownBrush" and "CandleStickLinePen" to control painting of the up and down bars and the border and shadow line. I also added a little demo "financial" to the "demo" folder of the TAChart installation which demonstrates both modes. It would be nice if you could have a look if everything is fine - I'm not an expert in financial charts. I also fixed the bug which ignored the true minimum of the data - therefore, it is no longer necessary to calculate the minimum by yourself, just have a look at the code in the demo project. And, finally, I modified the AddXOHLC method such that it automatically initializes the size of the YCount of the chart source if the current size would not be enough. -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] TAChart CandleStick Chart
El 15/09/14 a las 15:49, Werner Pamler escibió: The "TopMark" and "BottomMark", as you call it, can be removed by setting WhiskerWidth to 0, and the "MiddleMark" disappears with MedianPen.Style set to psClear. The "Up" and "Down" colors can be set by some logics when adding data points (there's the color parameter in the Add method...). The intrinsic problem that Box/Whisker expects ordered y values, while the Candle obviously does not ("open" can be greater or smaller then "close"), could be overcome by pre-sorting the data which should also take account of the Up/Down colors. Well, in total, these are a few lines of code, but relatively straightforward. Nevertheless, maybe too much for less code-centered guys? Anyway, I'll try to add your contribution to a new CandleStick series. A few question before I begin: Your posting says that Candlestick plots do not have top and bottom marks, but the wikipedia reference that you gave does show them. What is true? What should be the default up and down colors? Thanks. I'm used to see CandleStick charts in many Stock Trading software, and I never saw thos top and bottom marks. Default UP can be clLime and Down clRed. P.S.: the next chart type is Heikin Ashi, a variation of CandleStick. -- Leonardo M. Ramé Medical IT - Griensu S.A. Av. Colón 636 - Piso 8 Of. A X5000EPT -- Córdoba Tel.: +54(351)4246924 +54(351)4247788 +54(351)4247979 int. 19 Cel.: +54 9 (011) 40871877 -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
[Lazarus] TAChart CandleStick Chart
The "TopMark" and "BottomMark", as you call it, can be removed by setting WhiskerWidth to 0, and the "MiddleMark" disappears with MedianPen.Style set to psClear. The "Up" and "Down" colors can be set by some logics when adding data points (there's the color parameter in the Add method...). The intrinsic problem that Box/Whisker expects ordered y values, while the Candle obviously does not ("open" can be greater or smaller then "close"), could be overcome by pre-sorting the data which should also take account of the Up/Down colors. Well, in total, these are a few lines of code, but relatively straightforward. Nevertheless, maybe too much for less code-centered guys? Anyway, I'll try to add your contribution to a new CandleStick series. A few question before I begin: Your posting says that Candlestick plots do not have top and bottom marks, but the wikipedia reference that you gave does show them. What is true? What should be the default up and down colors? -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] TAChart CandleStick Chart
El 14/09/14 a las 11:46, Werner Pamler escibió: I'm not familiar with the multivalued series. But you chandlestick series looks much like the Box/Whisker series which is included in TAChart. Can you point out the difference? -- Mm, they look similar, but Box/Whisker, has a top and bottom horizontal lines and an horizontal line in the middle of the candle, maybe adding a couple of boolean properties like TopMark, BottomMark and MiddleMark to the Box/Whisker chart will let use it as a CandleStick chart. -- Leonardo M. Ramé http://leonardorame.blogspot.com -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
[Lazarus] TAChart CandleStick Chart
I'm not familiar with the multivalued series. But you chandlestick series looks much like the Box/Whisker series which is included in TAChart. Can you point out the difference? -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
[Lazarus] TAChart CandleStick Chart
Hi, I inherited TOpenHighLowCloseSeries to implement CandleStick Charts: http://en.wikipedia.org/wiki/Candlestick_chart I only implemented the Draw method, but it would be nice to have this properties in the final version also: CandleColor: fill color of default or UP candle. DownCandleColor: fill color of down candle By now I use LinePen.Color and DownLinePen.Color as color of brush (fill of candle color) and the border is allways clBlack. Can someone include it in TAMultiseries? // interface { TCandleStickChart } TCandleStickChart = class(TOpenHighLowCloseSeries) public procedure Draw(ADrawer: IChartDrawer); override; end; // implementation procedure TCandleStickChart.Draw(ADrawer: IChartDrawer); function MaybeRotate(AX, AY: Double): TPoint; begin if IsRotated then Exchange(AX, AY); Result := ParentChart.GraphToImage(DoublePoint(AX, AY)); end; procedure DoLine(AX1, AY1, AX2, AY2: Double); begin ADrawer.Line(MaybeRotate(AX1, AY1), MaybeRotate(AX2, AY2)); end; function GetGraphPointYIndex(AIndex, AYIndex: Integer): Double; begin if AYIndex = 0 then Result := GetGraphPointY(AIndex) else Result := AxisToGraphY(Source[AIndex]^.YList[AYIndex - 1]); end; procedure DoRect(AX1, AY1, AX2, AY2: Double); var r: TRect; begin with ParentChart do begin r.TopLeft := MaybeRotate(AX1, AY1); r.BottomRight := MaybeRotate(AX2, AY2); end; ADrawer.FillRect(r.Left, r.Top, r.Right, r.Bottom); ADrawer.Rectangle(r); end; var my: Cardinal; ext2: TDoubleRect; i: Integer; x, tw, yopen, yhigh, ylow, yclose: Double; p: TPen; begin my := MaxIntValue([YIndexOpen, YIndexHigh, YIndexLow, YIndexClose]); if IsEmpty or (my >= Source.YCount) then exit; ext2 := ParentChart.CurrentExtent; ExpandRange(ext2.a.X, ext2.b.X, 1.0); ExpandRange(ext2.a.Y, ext2.b.Y, 1.0); PrepareGraphPoints(ext2, true); for i := FLoBound to FUpBound do begin x := GetGraphPointX(i); yopen := GetGraphPointYIndex(i, YIndexOpen); yhigh := GetGraphPointYIndex(i, YIndexHigh); ylow := GetGraphPointYIndex(i, YIndexLow); yclose := GetGraphPointYIndex(i, YIndexClose); tw := GetXRange(x, i) * PERCENT * TickWidth; if (DownLinePen.Color = clTAColor) or (yopen <= yclose) then p := LinePen else p := DownLinePen; ADrawer.BrushColor:= P.Color; // set border black ADrawer.SetPenParams(p.Style, clBlack); DoLine(x, yhigh, x, ylow); DoRect(x - tw, yopen, x + tw, yclose); end; end; I attached a screenshot of the result. -- Leonardo M. Ramé http://leonardorame.blogspot.com -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus