When certain condition occurs on an indicator A running in form F1 , another form - F2 may be shown when a condition occurs and remain hidden otherwise.
Let's call indicator A a master indicator. Several instances of the master indicator may exist , also different indicators may be designed as master indicators.
The following indicators implement Show/Hide form mechanism according to external conditions and provide usage example. I described very vaguely general mechanism of passing data/signalling actions here :
http://www.ninjatrader.com/support/forum/showthread.php?t=58362
A description of attached code follows:
All indicators are designed NOT to work on historical data.
There is a special indicator ShowHide with a single purpose of showing/hiding its parent form when it is said to do so. The instance of this indicator should be present on any form to be shown/hidden.
A communication between master indicator(s) and ShowHide indicator(s) is done via a Dictionary item with a key “ShowHide|{Instrument Name}”. For example, the key for $EURUSD is “Show Hide|$EURUSD”
The file SpecialAction.cs implements a singleton object SpecialAction. It is accessible everywhere by SpecialAction.Instance property. Member functions: Increment is called by a master indicator signalling that a show condition occurred. Decrement is called by a master indicator when the show condition is not present anymore.
Reference count is kept for multiple show/hide events from multiple master indicators running concurrently.
ShowHide calls RefCount method and shows/hides a parent form accordingly. It is important to set CalculateOnBarClose = false; , because master indicators may run on different types and values of data series.
The indicators MyTest and MyTest2 show how to use the mechanism above. Please pay attention for a code :
In Initialize() SpecialAction singleton is accessed and kept for further use. Increment with a proper key is called when show condition occurrs ,
Decrement is called when it ceases. OnTermination calls Decrement if show condition exists during the termination.
Running MyTest and MyTest2 together, you can see that another form is shown as long as one of show conditions occurs. You can run either several instances of one and both of them. It may be done for different instruments at the same time.
In order to use the mechanism, copy the files SpecialAction.cs and ShowHide.cs to indicators folder. Develop you master indicators according to my examples.
Encl. the files.