How to test from an Indicator if a Signal is ON or OFF

Questions about MultiCharts and user contributed studies.
User avatar
ym58
Posts: 10
Joined: 17 Jan 2011
Has thanked: 2 times

How to test from an Indicator if a Signal is ON or OFF

Postby ym58 » 24 Jan 2011

How can I test in an indicator if a signal that is applied to a particular chart is turned ON or OFF ?
Each strat has indeed its own Id (aiAppId), but how may I check its status (on/off) from an indic ?
Thanks

User avatar
Dave Masalov
Posts: 1712
Joined: 16 Apr 2010
Has thanked: 51 times
Been thanked: 489 times

Re: How to test from an Indicator if a Signal is ON or OFF

Postby Dave Masalov » 24 Jan 2011

Dear ym58,

You can do it only using Global Variables. If the signal is on, it sends a value to Global Variables, if the signalis off, it doesn't.

User avatar
ym58
Posts: 10
Joined: 17 Jan 2011
Has thanked: 2 times

Re: How to test from an Indicator if a Signal is ON or OFF

Postby ym58 » 24 Jan 2011

I thought about GV's, Dave, but it does not work 'real time' ... see :

#1 - strat is on, it sets GV to on, indicator sees the GV on ... good
#2 - strat is set off, it does not set GV to off, indicator still thinks strat is on because GV is still on ... not good

Do tou see any wayround to keep this GV updated 'realtime' ?

Thanks.

User avatar
Dave Masalov
Posts: 1712
Joined: 16 Apr 2010
Has thanked: 51 times
Been thanked: 489 times

Re: How to test from an Indicator if a Signal is ON or OFF

Postby Dave Masalov » 24 Jan 2011

Dear ym58,

Apparently it can be done only by changing the source code of Global Variables. This source code should be in open access.

General concept is:

1) Dll functions can be called when a study is created and turned on or off. The following methods should be used:
OnCreate
OnDestroy

2) A corresponding function should be defined in dll.

Example:
Here are the prototypes for the DLL functions that will be called on the Create and Destroy
events.
int __stdcall MYCREATEFUNC(IEasyLanguageObject *pEL);
int __stdcall MYDESTROYFUNC(IEasyLanguageObject *pEL);
Here is a typical directive construct that may be used to run the DLL functions above for an
EasyLanguage study.
#Events
OnCreate = MyCreateFunc;
OnDestroy = MyDestroyFunc;
#End

OnDestroy is called when the study is turned off or deleted.

User avatar
ym58
Posts: 10
Joined: 17 Jan 2011
Has thanked: 2 times

Re: How to test from an Indicator if a Signal is ON or OFF

Postby ym58 » 24 Jan 2011

Dave,

I am not familiar AT ALL with DLL programming and/or GV's code improvements, nor do I know, besides, WHERE to post an improvement request.

I really wish I could find something simpler and more straightforward that would use standard features of GV's.

Any clue ?

User avatar
Dave Masalov
Posts: 1712
Joined: 16 Apr 2010
Has thanked: 51 times
Been thanked: 489 times

Re: How to test from an Indicator if a Signal is ON or OFF

Postby Dave Masalov » 24 Jan 2011

Dear ym58,

Probably, there is an easier way to do this. However, we are not aware of it. If you are interested in custom programming services, we can do it for you at additional price.


Return to “MultiCharts”