PDA

View Full Version : event handling between indicators and strategies


cicondo
10-16-2008, 09:06 AM
Hi Guys,

Is it possible to implement the event delegation pattern between an indicator and a strategy?
If an indicator shows a trend change e.g. I will be informed in a running strategy.

I have tried this:

(indicator class, called "MyCallback")

...
public delegate void CallMe(string message);
...
...
public event CallMe CallHandler;


in the "OnBarUpdate"-method I send via event a message like this:
if(CallHandler != null)
{
CallHandler("something is going on");
}

in the strategy class I do this:

....
(Variables)
private MyCallback callBackMe;

protected override void Initialize()
{
callBackMe = new MyCallback();
callBackMe += new CallMe(this.GetCalled);
}

private void GetCalled(string message)
{
Print(...)
}

I think that is correct, but ther is no messag eat all!
Any idea?

Thanks a lot
Markus

NinjaTrader_Josh
10-16-2008, 09:48 AM
Hi Markus,

I do not think you need to use delegation. In your indicator you can just expose some properties that contain information on the state of the trend. From your strategy you can access those properties and get the information you need. Please check out this reference sample: http://www.ninjatrader-support.com/vb/showthread.php?t=4991