i tried to create a custom event in my indicator, that should handle buy or sell trigger. I want to use that event in my custom strategy to enter a trade. so that's what i want to do.
but the problem is, that the custom event handler is always null (not initialized), and i don't know why. i've read several c# tutorials with event handler examples and i did it 1:1 but it does not work.
is it not possible to create own events in indicators?
here my short example code:
Event Handler:
protected virtual void OnEventMessage(EventArgs e)
{
Print("OnEventMessage ...");
EventHandler handler = EventMessage;
if (handler != null)
{
handler(this, e);
Print("Handler sent EventMessage ...");
}
else
{
Print("Handler is null @ EventMessage ...");
}
}
public event EventHandler EventMessage;
OnEventMessage(EventArgs.Empty);
Best Regards,
Tom

Comment