I've checked through this forum for the problem I am having and found one or two posts that might be helpful but I was not able to find a solution. At a high level, how would one access results from a custom indicator within a custom signal (strategy)?
I noticed that all of the signal scripts that come with MultiCharts.NET which rely on a certain indicator (e.g., 'Keltner_Channel_LE') do not have a reference to that indicator type but rather use duplicated code to re-create the indicator for the signal's purposes. If I had a simple indicator that returns a single value, I'm aware that I could write a function and make use of this function in both the indicator and a strategy. However, assume that we write some advanced (long) indicator script (e.g., the 'BetterVolume' script that was posted in the User Contributed section, which includes numerous formatting conditions to fill volume bars a variety of different colors). It does not seem logical that I would have to duplicate the entirety of that code inside a signal script if I wanted to enter a trade based on the color of a volume bar. I would have assumed I could create a 'BetterVolume' object within the signal and use this object to return any result that I wanted (e.g., color of last volume bar).
I was not able to do what I described above. What would the MultiCharts.NET solution be here? I hope that it's not to duplicate indicator code within each strategy.
Thanks,
Mark
Accessing Indicator from Signal [SOLVED]
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: Accessing Indicator from Signal [SOLVED]
Hello Mark,
Currently the possible solutions for your inquiry are using Global Variables or duplicating indicator code within each strategy.
We understand your arguments and we find them reasonable. We are looking into improving this functionality in the next major update of MultiCharts (ver 9).
Currently the possible solutions for your inquiry are using Global Variables or duplicating indicator code within each strategy.
We understand your arguments and we find them reasonable. We are looking into improving this functionality in the next major update of MultiCharts (ver 9).
-
- Posts: 14
- Joined: 23 Jan 2013
- Has thanked: 4 times
Re: Accessing Indicator from Signal
I'm definitely looking for this as well. I make many custom indicators and would like to be able to call their plot values from signals without using the "Global Variables" method.Currently the possible solutions for your inquiry are using Global Variables or duplicating indicator code within each strategy.
We understand your arguments and we find them reasonable. We are looking into improving this functionality in the next major update of MultiCharts (ver 9).
Is there an ETA on Version 9 or when we can expect to see this functionality?
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: Accessing Indicator from Signal
MultiCharts 9 is targeted to the second half of this year (roughly). There is no exact date for it yet.Is there an ETA on Version 9 or when we can expect to see this functionality?
-
- Posts: 3
- Joined: 09 Feb 2013
Re: Accessing Indicator from Signal
I agree,that is an important feature which lack to MC.NET.
Duplicate code is a non sens in programmation and a cpu time consumer.
Duplicate code is a non sens in programmation and a cpu time consumer.
Re: Accessing Indicator from Signal
Hi.
The notes for MC .NET 8.8 RC state:
● Now objects of one study are accessible from another one. Learn more about this feature here.
Very interesting!
What are the capabilities and limitations of this feature?
Are there any available code examples of how to take advantage of this?
The notes for MC .NET 8.8 RC state:
● Now objects of one study are accessible from another one. Learn more about this feature here.
Very interesting!
What are the capabilities and limitations of this feature?
Are there any available code examples of how to take advantage of this?
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: Accessing Indicator from Signal
New methods have been added to the base indicator and signal class:
object CStudyAbstract.AddIndicator.AddIndicator(string indicator_name);
object CStudyAbstract.AddIndicator.AddIndicator(Type indicator_t);
You can call them only in the Create method.
Here is an example:
object CStudyAbstract.AddIndicator.AddIndicator(string indicator_name);
object CStudyAbstract.AddIndicator.AddIndicator(Type indicator_t);
You can call them only in the Create method.
Here is an example:
Code: Select all
namespace PowerLanguage.Indicator{
public class a1 : IndicatorObject {
public a1(object _ctx):base(_ctx){}
private IPlotObject plot1;
private ADX m_adx_indic;
protected override void Create() {
plot1 = AddPlot();
m_adx_indic = (ADX)AddIndicator("ADX");
m_adx_indic.length = 20;
}
protected override void CalcBar(){
plot1.Set(m_adx_indic.Plots[0].Values[0]);
}
}
}
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: Accessing Indicator from Signal
Please find a sample code attached.Hi
An example for indicator works well but could you give us an exemple how to use the custom indicators in the signals?
Regards
MaRCHeW
- Attachments
-
- Test_SignalByIndicator.pln
- (1.88 KiB) Downloaded 2465 times
Re: Accessing Indicator from Signal
I know it's possible to import values of an indicator from a signal file. Is it possible to start an indicator from a signal file so that I don't have to add the indicator by hand ? I don't want just the values but I would like to start the indicator from the signal with the indicator being plot according to the indicator setup.
Thanks.
Thanks.
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: Accessing Indicator from Signal
Hello there,
This AddIndicator method is very limited in its use; it just adds the custom indicator to the signal but it still doesn't allow one to get access to the variables for one to use in the indicator which is what most traders would want to do. You can only assign values to its parameters and plot out its values and that's it. But if you want to actually get the variable value out, print them out, compare them; it won't let you. You will get a nasty nullreference error because the object is not an instance of the indicator object. So if you want to get access to a custom indicator's variable values, you actually have to create an object and set it to an instance of the custom indicator and also create a variable series and set the variable series as an instance of the variable series of that variable of that custom indicator AND you have to make sure that that variable from that indicator that you want to see its value in the strategy was made public. And then and only then you get use the "variable_name[int barsago]" to get its value.
So complicated and so frustrating. This is what I realized after three hours of trial & error.
Hope everyone else is having an easier time than me!
This AddIndicator method is very limited in its use; it just adds the custom indicator to the signal but it still doesn't allow one to get access to the variables for one to use in the indicator which is what most traders would want to do. You can only assign values to its parameters and plot out its values and that's it. But if you want to actually get the variable value out, print them out, compare them; it won't let you. You will get a nasty nullreference error because the object is not an instance of the indicator object. So if you want to get access to a custom indicator's variable values, you actually have to create an object and set it to an instance of the custom indicator and also create a variable series and set the variable series as an instance of the variable series of that variable of that custom indicator AND you have to make sure that that variable from that indicator that you want to see its value in the strategy was made public. And then and only then you get use the "variable_name[int barsago]" to get its value.
So complicated and so frustrating. This is what I realized after three hours of trial & error.
Hope everyone else is having an easier time than me!
Last edited by MultiC on 20 Mar 2015, edited 1 time in total.
-
- Posts: 26
- Joined: 30 Jan 2014
- Been thanked: 4 times
Re: Accessing Indicator from Signal
Well, there is good news: Just use database inside the indicator. I use MS SQL, it meshes nicely with .NET. You have to buy a copy from Microsoft. The good news is, you could get a copy of SQL developer edition for a very small fee, although it is restricted to a single developer machine use.
I use it for indicator data and other things which control study behavior too. It's a very robust solution to data needs from what ever source you want. I even use it to implement my signal providers API. it's turning into a very complex network of data from different providers and such.
Never rely upon one source for data.
I use it for indicator data and other things which control study behavior too. It's a very robust solution to data needs from what ever source you want. I even use it to implement my signal providers API. it's turning into a very complex network of data from different providers and such.
Never rely upon one source for data.
Re: Accessing Indicator from Signal
@MultiC: to get access to an indicator's variables, you need to make them public. That's all.
Hello there,
This AddIndicator method is very limited in its use; it just adds the custom indicator to the signal but it still doesn't allow one to get access to the variables for one to use in the indicator which is what most traders would want to do. You can only assign values to its parameters and plot out its values and that's it. But if you want to actually get the variable value out, print them out, compare them; it won't let you. You will get a nasty nullreference error because the object is not an instance of the indicator object. So if you want to get access to a custom indicator's variable values, you actually have to create an object and set it to an instance of the custom indicator and also create a variable series and set the variable series as an instance of the variable series of that variable of that custom indicator AND you have to make sure that that variable from that indicator that you want to see its value in the strategy was made public. And then and only then you get use the "variable_name[int barsago]" to get its value.
So complicated and so frustrating. This is what I realized after three hours of trial & error.
Hope everyone else is having an easier time than me!
-
- Posts: 26
- Joined: 30 Jan 2014
- Been thanked: 4 times
Re: Accessing Indicator from Signal
Never rely entirely upon one data source, especially when money is involved. Hustlers abound at every table. Usually there will be a hustler hustling another hustler.
That's all I'm going to say about it.
That's all I'm going to say about it.