Page 1 of 1
Multiple lines from custom function?
Posted: Wed Jan 05, 2011 10:38 pm
by 15658023
It looks like we will be creating a number of custom financial functions. I have found one example that uses the inherited Calculate event and I have that working. I see that it returns a single value and that one value is easy to plot. What I want to create are functions that return more than one line. An example from your function list is MACD. One MACD function returns 2 lines and a histogram. Can I create a single custom function that populates three lines like that? Is that the function of the CalculateMany event? Do you have a simple sample (VB.Net would be nice, but C# would suffice) of using CalculateMany? I did not see one in my samples.
Thanks for your help!
Re: Multiple lines from custom function?
Posted: Thu Jan 06, 2011 2:42 pm
by 15658023
Here is a quick second question for the topic of Custom functions using the "Calculate" event. Let's say the particular bar that is being processed by some trip through this event is an "invalid" day, like a holiday or something. If I want to return a value that is not plotted, or is ignored, what kind of value do I pass back? That function returns a type double. "0" is not a good option because 0 could be a valid response. I am trying to figure out the appropriate value that would be "DoNotPainted" in the following series.
line1.TreatNulls = Steema.TeeChart.Styles.TreatNullsStyle.DoNotPaint
Should I just pass back something like:
Dim O as Object = Nothing
Return O
Thanks!
Re: Multiple lines from custom function?
Posted: Mon Jan 10, 2011 3:10 pm
by 10050769
Hello dave,
I am afraid that is not possible. The solution I propose to you, is that create a custom function that inherits of MACD function or ADX function. Once this is done you only has to overwrite methods Calculate and CalculateMany because works as you want. You can find examples of ADX and MACD function in Demo project All Features\Welcome !\Functions\Financial\ADX and All Features\Welcome !\Functions\Financial\MACD. And also you can find more information of methods Calculate and CalculateMany in Tutorial 7.
Here is a quick second question for the topic of Custom functions using the "Calculate" event. Let's say the particular bar that is being processed by some trip through this event is an "invalid" day, like a holiday or something. If I want to return a value that is not plotted, or is ignored, what kind of value do I pass back? That function returns a type double. "0" is not a good option because 0 could be a valid response. I am trying to figure out the appropriate value that would be "DoNotPainted" in the following series.
You have different options for achieve it:
1.- You can change color of the point you want Transparent changing property Color.Transparent.
2.- You can do SetNull(ValueIndex) of point are you want null or transparent.
3.- You can use property of Series.DefaultNullValue that sets or returns the value to be used as a null value within the series.
I hope will helps.
Thanks,