Accessing Indicator from Signal  [SOLVED]

Questions about MultiCharts .NET and user contributed studies.
markwit229
Posts: 14
Joined: 23 Jan 2013
Has thanked: 4 times

Accessing Indicator from Signal

Postby markwit229 » 27 Feb 2013

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

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Accessing Indicator from Signal  [SOLVED]

Postby Henry MultiСharts » 27 Feb 2013

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).

markwit229
Posts: 14
Joined: 23 Jan 2013
Has thanked: 4 times

Re: Accessing Indicator from Signal

Postby markwit229 » 27 Feb 2013

Thanks, Henry.

drmrboyc
Posts: 7
Joined: 22 Mar 2013
Has thanked: 1 time

Re: Accessing Indicator from Signal

Postby drmrboyc » 10 Apr 2013

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).
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.

Is there an ETA on Version 9 or when we can expect to see this functionality?

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Accessing Indicator from Signal

Postby Henry MultiСharts » 11 Apr 2013

Is there an ETA on Version 9 or when we can expect to see this functionality?
MultiCharts 9 is targeted to the second half of this year (roughly). There is no exact date for it yet.

montechristo
Posts: 3
Joined: 09 Feb 2013

Re: Accessing Indicator from Signal

Postby montechristo » 11 May 2013

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.

User avatar
MC_Prog
Posts: 330
Joined: 28 Feb 2007
Has thanked: 64 times
Been thanked: 35 times

Re: Accessing Indicator from Signal

Postby MC_Prog » 30 Nov 2013

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?

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Accessing Indicator from Signal

Postby Henry MultiСharts » 02 Dec 2013

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:

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]);
}
}
}

MaRCHeW
Posts: 37
Joined: 16 Nov 2013
Has thanked: 21 times
Been thanked: 8 times

Re: Accessing Indicator from Signal

Postby MaRCHeW » 06 Dec 2013

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

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Accessing Indicator from Signal

Postby Henry MultiСharts » 11 Dec 2013

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
Please find a sample code attached.
Attachments
Test_SignalByIndicator.pln
(1.88 KiB) Downloaded 2445 times

franky
Posts: 24
Joined: 25 Nov 2012
Has thanked: 4 times
Been thanked: 4 times

Re: Accessing Indicator from Signal

Postby franky » 16 May 2014

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.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Accessing Indicator from Signal

Postby Henry MultiСharts » 16 May 2014

Hello franky,

That is the same question that has been already discussed here.

MultiC
Posts: 1
Joined: 12 Mar 2015

Re: Accessing Indicator from Signal

Postby MultiC » 13 Mar 2015

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!
Last edited by MultiC on 20 Mar 2015, edited 1 time in total.

CarseWhite
Posts: 26
Joined: 30 Jan 2014
Been thanked: 4 times

Re: Accessing Indicator from Signal

Postby CarseWhite » 20 Mar 2015

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.

novaleaf
Posts: 49
Joined: 17 Apr 2014
Has thanked: 9 times
Been thanked: 4 times

Re: Accessing Indicator from Signal

Postby novaleaf » 03 May 2015

@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!

CarseWhite
Posts: 26
Joined: 30 Jan 2014
Been thanked: 4 times

Re: Accessing Indicator from Signal

Postby CarseWhite » 03 May 2015

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.


Return to “MultiCharts .NET”