I
have this application that is in C# and works with the financial markets.
It
allows users to program any kind of studies, indicators or charts at wish but
only if they have the app. Compile and run the code within it’s own process. In
other words It’s explicit DLL’s are not accessible from outside world.
I
have however managed to get it to write to and read from Global Variables that
I can have access to the same GV’s from outside too.
The
app. Also has a custom event maker nad my thinking is to code all my
applications outside, for example like making keyboard Macro commands that can
be triggered through my GUI made outside to for each Macro place a simple flag
in the Global Variables and then code events for the Global Variables that when
their state changes to let the customevent within the other application know
and then the application based on the code received to carry out the necessary
steps.
I
don’t know if I explained myself clearly or not but what I need to know is :
1- If I could achieve the above utilizing the other
application’s custom event maker known as TriggerCustomEvent?
a. The snippet below show an example of how the custom event
maker TriggerCustomEvent can be used with a timer.
2- Is my suggested approach the best way for getting inside the
other app. As in the case of making a keyboard Macro or there are other ways
that you’d suggest for achieving the same?
I
sincerely thank you for your help, being a NewB in C# but desperate to get this
done…
Sample
of the code to make an event for the timer:
[code]
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected
override void
OnBarUpdate()
{
if
(CurrentBar == 0)
{
//
Initiate our Timer object with an interval of 1000ms (1 second)
myTimer.Tick += new EventHandler(TimerEventProcessor);
myTimer.Interval = 1000;
myTimer.Start();
}
}
// Timer's
tick event handler. Called at every tick of 1000ms.
private
void TimerEventProcessor(Object myObject, EventArgs
myEventArgs)
{
/*
Important to use the TriggerCustomEvent() to ensure that NinjaScript indexes
and pointers are correctly set.
Do not process your
code here. Process your code in the MyCustomHandler method. */
TriggerCustomEvent(MyCustomHandler,
myTimer.Interval);
}
private
void MyCustomHandler(object
state)
{
//
Informs us of when the event was triggered and of our Timer settings
Print("\tTime:
" + DateTime.Now);
Print("\tTimer
Interval: " + state.ToString() + "ms");
//
Prints the L2 Ask Book we created. Cycles through the whole List and prints the
contained objects.
Print("Ask
Book: ");
for
(int idx = 0; idx < askRows.Count; idx++)
Print("Ask Price=" + askRows[idx].Price + " Volume=" + askRows[idx].Volume);
//
Prints the L2 Bid Book we created. Cycles through the whole List and prints the
contained objects.
Print("Bid
Book: ");
for
(int idx = 0; idx < bidRows.Count; idx++)
Print("Bid Price=" + bidRows[idx].Price + " Volume=" + bidRows[idx].Volume);
}
//
Important to clean up our resources
public
override void
Dispose()
{
//
Make sure you include base.Dispose() whenever you override the Dispose() method
base.Dispose();
//
Cleans up our Timer object
myTimer.Dispose();
}
#region Properties
#endregion
}
[/code]