MY Function

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Chartist
Newbie
Newbie
Posts: 60
Joined: Wed Sep 18, 2013 12:00 am

MY Function

Post by Chartist » Tue Jul 15, 2014 2:06 pm

I have a version without source-code.

in the help I can read:
"
Average True Range Technical Indicator (ATR) is an indicator that shows volatility of the market.
The ATR Function uses a OHLC ( Candle ) series as datasource.
"

If I follow the instructions, I will be ablte to add the function / or any of the others BUILT IN.
Fine.

My questions:
a) How can I add MY OWN function?

Sure, I can use AddXY(....) and add it point by point manually.
But if there is a more sophisticated way, I really would be glad to learn it.


b) How can I edit the formular or at least display e.g. the RSI?


Thank you!
Cheryll
Cheryll

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: MY Function

Post by Narcís » Wed Jul 16, 2014 8:37 am

Hi Cheryll,

a) You can use the custom function feature (y=f(x)). You'll find an example at All Features\Welcome!\Functions\Extended\Custom y=f(x) example in the new features demo, available at TeeChart's program group.

b) I'm not 100% sure about what you mean here. There are some examples about getting the function formula at "What's New?\Welcome!\New Features\Functions" in the new features demo. However, this doesn't apply to the RSI function. Could you please provide more information about what do you need?
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Chartist
Newbie
Newbie
Posts: 60
Joined: Wed Sep 18, 2013 12:00 am

Re: MY Function

Post by Chartist » Thu Jul 17, 2014 3:29 pm

Hi Narcis,

thank you for your reply.
I will search for the things you mentioned in lit a.

lit b:
RSI can be figured e.g. like this:

"
RSI = 100 - 100/(1 + RS*)
*Where RS = Average of x days' up closes / Average of x days' down closes.
"
.... but as well, there can be taken an average value of the last RSI value instead, - to mention one of the ideas used in the world.
The values are very similar, but not ident.
RSI need not be calculated from the close value. I can use a medum value or the open etc.
It is not about what is "right".
It is about: Where can I look "into" the built-in thing to find out how the RSI and all the others are figured exactly?
And: can I change them, if I want to?

Thanks,
Cheryll
Cheryll

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: MY Function

Post by Narcís » Fri Jul 18, 2014 7:12 am

Hi Cheryll,
Chartist wrote: It is about: Where can I look "into" the built-in thing to find out how the RSI and all the others are figured exactly?
TeeChart help wrote:According to TeeChart.chm, the help file included with the binary installer, TRSIFunction is described this way:

TRSIFunction is a TLineSeries derived component that calculates a percent value based on Financial data.
TRSIFunction must be connected to a TOHLCSeries or any derived Series component (like TCandleSeries. Like a TMovingAverageFunction, RSI will calculate a new point Y value by using previous Period points.

The used formula is:

Add all Close prices greater than Open prices and divide by ocurrences (Ups).

Add all Close prices lower than Open prices and divide by ocurrences (Downs).

RSI := 100.0 - ( 100.0 / ( 1.0 + Abs( Ups / Downs ) ) )

To see a visual representation of TeeChart Extended Functions, go to the TeeChart User Guide.
TeeChart source code customers can look at exactly how each function is being calculated in the source code. For example, TRSIFunction is implemented in CandleCh.pas. Basic function type is TTeeFunction (implemented in TeeEngine.pas). You'll find that functions have the Calculate method and other similar methods.
Chartist wrote: And: can I change them, if I want to?
Sure, if you are a source code customer you can modify the sources or extend them to fit your exact needs. You can create your own functions deriving from existing ones.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Chartist
Newbie
Newbie
Posts: 60
Joined: Wed Sep 18, 2013 12:00 am

Re: MY Function

Post by Chartist » Fri Jul 18, 2014 4:18 pm

Hi,

thank you for your reply.
As said before, I am no source code customer.

What can I do?

Regards,
Cheryll
Cheryll

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: MY Function

Post by Sandra » Mon Jul 21, 2014 12:32 pm

Hello Cheryll,
thank you for your reply.
As said before, I am no source code customer.
What can I do?
I think you should use Custom function to represent the desired formula. You can see it in the Functions Demo example that Narcis suggested previously, All features\Welcome !\Functions\Extended\Custom y=f(x). Please, take a look in it. Also, I would like suggest you take a look in the below links where you find some examples that give you an idea as you need do to implement your own function.

http://teechart.net/support/viewtopic.p ... ion#p57576
http://teechart.net/support/viewtopic.p ... ons#p27038

Hoping it will help, otherwise please don't hesitate to let me know.
Thanks in advance,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Chartist
Newbie
Newbie
Posts: 60
Joined: Wed Sep 18, 2013 12:00 am

Re: MY Function

Post by Chartist » Wed Jul 23, 2014 10:06 am

Thank you so much for the links.
I found the example in the help, but could not implement it.

2 things, which probably go wrong:
1)
I use a TDBChart, not a TChart as in the example. I do not know, if this matters.
However I cannot find an OnCalculate event there.

2)
How do I fill my TDBChart?
Triggered by a button-event: The code calls a procedure and this procedure generates the rather complex SQL-query-text, which differs from case to case and is used from many parts of my software.
The SQL-Text I filled into my design-time-TDBChart mask, - is just a fake to be able to compile.
To put an onCalculate event into the generated Query in function (instead of the not-there TDBChart OnCalculate event) would reduce the speed of my code that much, that it will be unusable for all my other needs.

In other words:
I would need an event in a TDBChart to trigger the function call, but it must not be the onCalculate Event of my query.

Thanks!
Cheryll
Cheryll

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: MY Function

Post by Sandra » Thu Jul 24, 2014 11:17 am

Hello Cheryll,
1) I use a TDBChart, not a TChart as in the example. I do not know, if this matters.

However I cannot find an OnCalculate event there.
TDBChart derives from TChart and inherits all its functionality. When a Chart Series is connected to a TDBChart component, TDBChart looks in the Series DataSource property. Therefore, using TDChart you can do the same as you do with a Chart.

The Calculate method is a method of your custom function, not to TDBChart, as you see in the examples. In these, the method (event) is assigned to the functions not to Chart. Also, in the Tutorial 7 - Working with Functions of TeeChart Pro, you find an exactly guide that indicate you what need do to create your own function. The tutorial is in a similar path as next:

%Program Files (x86)%\Steema Software\TeeChart 2014 for RAD XE6\Docs
2)
How do I fill my TDBChart?

Triggered by a button-event: The code calls a procedure and this procedure generates the rather complex SQL-query-text, which differs from case to case and is used from many parts of my software.

The SQL-Text I filled into my design-time-TDBChart mask, - is just a fake to be able to compile.

To put an onCalculate event into the generated Query in function (instead of the not-there TDBChart OnCalculate event) would reduce the speed of my code that much, that it will be unusable for all my other needs.

In other words:

I would need an event in a TDBChart to trigger the function call, but it must not be the onCalculate Event of my query.
You’ll need to choose the moment when to update the Chart, perhaps after processing data changes. A Call to the Series.CheckDatasource will then cause the Series to update.

Thanks in advance,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Chartist
Newbie
Newbie
Posts: 60
Joined: Wed Sep 18, 2013 12:00 am

Re: MY Function

Post by Chartist » Tue Aug 19, 2014 4:08 pm

Thank you very much.
I found many ressources whith your hints and they gave me many new ideas and ways.

Cheryll
Cheryll

Post Reply