Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

event handling between indicators and strategies

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

    event handling between indicators and strategies

    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

    #2
    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/v...ead.php?t=4991
    Josh P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by algospoke, 04-17-2024, 06:40 PM
    6 responses
    49 views
    0 likes
    Last Post algospoke  
    Started by arvidvanstaey, Today, 02:19 PM
    4 responses
    11 views
    0 likes
    Last Post arvidvanstaey  
    Started by samish18, 04-17-2024, 08:57 AM
    16 responses
    61 views
    0 likes
    Last Post samish18  
    Started by jordanq2, Today, 03:10 PM
    2 responses
    11 views
    0 likes
    Last Post jordanq2  
    Started by traderqz, Today, 12:06 AM
    10 responses
    21 views
    0 likes
    Last Post traderqz  
    Working...
    X