Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

TriggerCustomEvent Method question

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

    TriggerCustomEvent Method question

    Iīm trying to understand the TriggerCustomEvent Method and would appreciate some guidance. Yes, Iīve had a look at the provided sample code ; ) This is my testcode without the TCE method:

    protected override void OnBarUpdate()
    {
    if (ToDay(Time[0]) == 20110113)
    {
    DrawArrowDown(CurrentBar.ToString(), true, 0, Highs[0][0]+5, Color.Tomato)
    WebBrowser b = new WebBrowser();
    b.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(b_Document Completed1);
    b.Navigate("http://finance.yahoo.com/");
    string screen = "Step 1";
    DrawTextFixed("tag1", screen, TextPosition.TopRight);
    Print("Step 1");
    }
    }

    private void b_DocumentCompleted1(object sender, WebBrowserDocumentCompletedEventArgs e)
    {
    Print("Step 3");
    WebBrowser b = sender as WebBrowser;
    string screen = b.DocumentText;
    b.DocumentCompleted -= new WebBrowserDocumentCompletedEventHandler(b_Document Completed1);
    DrawTextFixed("tag1", screen, TextPosition.TopRight);
    Print("Step 4");
    }


    And this is how I implemented TriggerCustomEvent on that code:

    protected override void OnBarUpdate()
    {
    if (ToDay(Time[0]) == 20110113)
    {
    DrawArrowDown(CurrentBar.ToString(), true, 0, Highs[0][0]+5, Color.Tomato)
    WebBrowser b = new WebBrowser();
    b.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(b_Document Completed1);
    b.Navigate("http://finance.yahoo.com/");
    string screen = "Step 1";
    DrawTextFixed("tag1", screen, TextPosition.TopRight);
    Print("Step 1");
    }
    }
    private void b_DocumentCompleted1(object sender, WebBrowserDocumentCompletedEventArgs e)
    {
    TriggerCustomEvent(MyCustomHandler1, 0, sender);
    Print("Step 2");
    }
    private void MyCustomHandler1(object sender)
    {
    Print("Step 3");
    WebBrowser b = sender as WebBrowser;
    string screen = b.DocumentText;
    b.DocumentCompleted -= new WebBrowserDocumentCompletedEventHandler(b_Document Completed1);
    DrawTextFixed("tag1", screen, TextPosition.TopRight);
    Print("Step 4");
    }

    My questions are:

    1. Did I implement the TCE method correct?
    2. The output window gives med 1,3,4,2... is that really the correct execute sequence for the code, or did I do something wrong?
    3. Where, if anywhere, do I unregister the b_DocumentCompleted1 event handler?

    Iīm not a programmer, so Iīm sorry if Iīm missing something basic here.

    //TNX, Fredrik

    #2
    Hello,

    This is unfortunaley not supported NinjaScript. Therefor you will need to get a response from someone from the community on this as I will be unable to further assist on this. You may want to try searching google also for this type of information, as this is not NinjaScript and is more c# custom programming.

    Let me know if I can be of further assistance.
    BrettNinjaTrader Product Management

    Comment


      #3
      No probs, but isnīt the TriggerCustomEvent a proprietary NT method?!

      Comment


        #4
        Hello,

        Is not documented in our help guide at all. Therefore it is not supported.
        BrettNinjaTrader Product Management

        Comment


          #5
          TriggerCustomEvent() is described in the NT7 help document in "Alphabetical Reference" under letter "T".

          Regards
          Ralph

          Comment


            #6
            Thanks Ralph - to clarify - the TriggerCustomEvent() method is supported NinjaScript with usage as documented in the reference sample code for working with Timer events - your call looks correct FREEN, are you working on NT 6.5 or 7 with it?

            Comment


              #7
              Thanks Ralf and Bertrand. Yes, Iīm aware of the help file and the sample script, and yes; Iīm in NT7. Two things surprised me:

              1. In the provided sample script, the eventhandler isnīt unregistered.
              2. The execution sequence of the code when using the TCE method.

              But I guess thatīs the way itīs supposed to be with the TCE method?!

              As a test I made a multi-step event chain without the TCE method, and it doesnīt get executed. I guess one event at a time gets executed for each "OnBarUpdate"?! This was just a test to se how dependant the code is on the TCE method to run correctly in NT. Still playing around.

              Again Bertrand, thanks! Your help in the forum is outstanding!
              Last edited by FREEN; 01-18-2011, 05:55 AM.

              Comment


                #8
                To sum things up for anyone interested; I never really got a hang of the CustomEventHandler() method in the context I was using it. As Bertrand says; this method is intended for Timer events. I ended up putting that part of the code in a dll instead, calling it from a script. Runs just fine!

                To correct myself from the previous post, the code does get executed without CustomEventHandler(), but as said in many post from support it getīs out of sync with other events in NT.
                Last edited by FREEN; 02-01-2011, 03:04 PM.

                Comment


                  #9
                  Originally posted by FREEN View Post
                  ...As Bertrand says; this method is intended for Timer events...
                  This method is intended to synconise all user events with the NT-system. With user events I mean non-syncronised events like timers, context menu events, click events on the chart, etc. If you do not generate such events, then you do not need to apply the custom event handler.

                  Regards
                  Ralph

                  Comment


                    #10
                    Originally posted by Ralph View Post
                    This method is intended to synconise all user events with the NT-system. With user events I mean non-syncronised events like timers, context menu events, click events on the chart, etc. If you do not generate such events, then you do not need to apply the custom event handler.

                    Regards
                    Ralph
                    I stand corrected. NT only gives support on it in the Timer events context.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    578 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    334 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    101 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    553 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    551 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X