Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Show and hide a form according to external condition(s).

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Show and hide a form according to external condition(s).

    I'm a discretional Forex trader, looking for 1 to 5 minutes charts, but when an entry condition occurs, I'm looking for 15min to 1hr charts for confirmation. Working with several instruments, it was very tedious for me to keep all the charts on the screen and remain concentrated on my work. Therefore I implemented automatic Show/Hide mechanism.

    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 :
    HTML Code:
     http://www.ninjatrader.com/support/forum/showthread.php?t=58362
    but I'm aware I was not clear enough.

    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.
    Attached Files

Latest Posts

Collapse

Topics Statistics Last Post
Started by sidlercom80, 10-28-2023, 08:49 AM
170 responses
2,271 views
0 likes
Last Post sidlercom80  
Started by Irukandji, Yesterday, 02:53 AM
2 responses
17 views
0 likes
Last Post Irukandji  
Started by adeelshahzad, Today, 03:54 AM
0 responses
3 views
0 likes
Last Post adeelshahzad  
Started by CortexZenUSA, Today, 12:53 AM
0 responses
3 views
0 likes
Last Post CortexZenUSA  
Started by CortexZenUSA, Today, 12:46 AM
0 responses
1 view
0 likes
Last Post CortexZenUSA  
Working...
X