How to exchange data between the indicator and the signal

Questions about MultiCharts and user contributed studies.
icberlin
Posts: 1
Joined: 07 Sep 2021

How to exchange data between the indicator and the signal

Postby icberlin » 07 Sep 2021

Hi MC friends
After creating a indicator (has a variable named 'myVar'),
is it possible to get the value of 'myVar' in the signal file?
thanks for any suggestion.

Mydesign
Posts: 177
Joined: 15 Feb 2017
Has thanked: 32 times
Been thanked: 39 times

Re: How to exchange data between the indicator and the signal

Postby Mydesign » 10 Sep 2021

Hello,

You can either:
- duplicate your indicator code into your signal
- convert your indicator as a function, then call it from the signal
- Use i_SetPlotValue / i_getPlotValue. The trick to do so is to use a function as the middleman to collect the value.

KDH
Posts: 7
Joined: 15 Jan 2021
Has thanked: 1 time
Been thanked: 1 time

Re: How to exchange data between the indicator and the signal

Postby KDH » 10 Sep 2021

As Mydesign suggests, write your indicator logic in functions. Your indicator should call the function and plot the returned value. Your signal can also call the function.

User avatar
Tammy MultiCharts
Posts: 200
Joined: 06 Aug 2020
Has thanked: 6 times
Been thanked: 65 times

Re: How to exchange data between the indicator and the signal

Postby Tammy MultiCharts » 17 Sep 2021

Hello icberlin,

It is also possible to use GlobalVariables to achieve your goal.
Please find more information about the external DLL here.

janus
Posts: 835
Joined: 25 May 2009
Has thanked: 63 times
Been thanked: 104 times

Re: How to exchange data between the indicator and the signal

Postby janus » 17 Sep 2021

It depends on what you are doing. If you are running two or more different studies that have different purposes side by side then as suggested, global variables is the ideal way to share data across them. If you are talking about converting an indicator study to a signal study then as was already suggested use a function(s) to write one or more lots of code that is/are used by two or more studies.

I've gone one step further and have given up writing my code in EL. I now write all my work in another language in a DLL. I find it so much easier and simpler to debug. It also runs a lot faster. It also allows me to run the code stand-alone without using MC all the time - just once to save the instatement data to a flat file. I do that for optimisation purposes and it runs much quicker. Also useful for debugging purposes without the need to fire up MC all the time. For example, if I encounter a programming error the IDE will inform me which line in the code the error occurs. A common problem in EL is out of bounds array indexing - it doesn't inform me which array it is. In the IDE I used, much like in VS, it traps the error and shows me. Other sorts of errors are handled in the same way. When using it as a DLL errors are trapped and a window message pops up so I can avoid crashing MC. There are so many other benefits of "escaping" from the EL. I did consider moving over to .NET but it turns out the way I'm doing it is so much better, at least for me it is. Others of course will have a different and equally legitimate view for their situation.

That way MC is only used for plotting and trading purposes. I wish I started using that approach a lot sooner. It's even better than using the ,NET version of MC as I don't need to use the clumsy VS interface. There are so many other IDEs for different languages. I don't have a need to write fancy widgets at the moment but I might down the road, and the IDE I use has that capability, just as VS does. I won't discuss or debate the merits of which programming language is best since that's more of a personal preference. Some like java, some like C++, some like C#, some like python, some like perl, some like Basic, some like Fortran, etc. etc.. I actually like and dislike all of those for different reasons and have used them and others in the past.


Return to “MultiCharts”