Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

TriggerCustomEvent

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

    TriggerCustomEvent

    hi
    I use custom Events in a strategy that trades Multiple Instruments.

    IF the Custom event is for BarsInProgress 1 or 2 must i do

    TriggerCustomEvent(customEvent, 1 , object state) or
    TriggerCustomEvent(customEvent, 2 , object state) respectively.

    Or must i always trigger with BarsInProgress 0 i.e
    TriggerCustomEvent(customEvent, 0 , object state)

    In addition, it would be useful to know exactly what does TriggerCustomEvent do.. it says from help, it resets pointers, what pointers ?

    thanks
    Last edited by aljafp; 03-19-2010, 07:16 PM.

    #2
    Hello,

    >>TriggerCustomEvent works like any multithread event handler, when something happens NT executes code (points to code) in the designated area. Basically like OnBarUpdate, OnExecution, or any other method that is in the help guide that starts with "On...."().

    IF the Custom event is for BarsInProgress 1 or 2 must i do

    TriggerCustomEvent(customEvent, 1 , object state) or
    TriggerCustomEvent(customEvent, 2 , object state) respectively.

    >>What are you trying to do? Do something when a bar is updated? I'd use BarsInProgress instead:


    Or must i always trigger with BarsInProgress 0 i.e
    TriggerCustomEvent(customEvent, 0 , object state)

    >>If I understand correctly, no, just use BarsInProgess like it shows in the link above.

    In addition, it would be useful to know exactly what does TriggerCustomEvent do.. it says from help, it resets pointers, what pointers ?

    >>see my first statement above. Think of pointers as something that points to a location in your code or to a specific memory location.
    DenNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Ben View Post
      Hello,

      >>TriggerCustomEvent works like any multithread event handler, when something happens NT executes code (points to code) in the designated area. Basically like OnBarUpdate, OnExecution, or any other method that is in the help guide that starts with "On...."().

      IF the Custom event is for BarsInProgress 1 or 2 must i do

      TriggerCustomEvent(customEvent, 1 , object state) or
      TriggerCustomEvent(customEvent, 2 , object state) respectively.

      >>What are you trying to do? Do something when a bar is updated? I'd use BarsInProgress instead:


      Or must i always trigger with BarsInProgress 0 i.e
      TriggerCustomEvent(customEvent, 0 , object state)

      >>If I understand correctly, no, just use BarsInProgess like it shows in the link above.

      In addition, it would be useful to know exactly what does TriggerCustomEvent do.. it says from help, it resets pointers, what pointers ?

      >>see my first statement above. Think of pointers as something that points to a location in your code or to a specific memory location.
      I have a multiple instrument strategy but it has an external trigger which i use custom events to trigger. ( so it cannot be in onBarUpdate )
      So depending on the Event, i may send trades for Data Stream 0, 1 or 2.
      Thus if its an Event where i want to send trades for Data Stream 1.
      Do i do TriggerCustomEvent(customEvent, 1 , object state) ?

      I know what a pointer is. My question was what pointers does TriggerCustomEvent reset ?

      Comment


        #4
        Hello,

        Some code would help me understand. Please explain "external trigger" and by "data stream" do you mean bars or literally another data provider?
        DenNinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Ben View Post
          Hello,

          Some code would help me understand. Please explain "external trigger" and by "data stream" do you mean bars or literally another data provider?
          Say i watch a number of text files. Depending on which text file occurs, i will send orders for Instrument[0] or Instrument[1] or Instrument[2]. Hence my question, when the specific event occurs, do i need to perform TriggerCustomEvent(customEvent, 0 , object state) or TriggerCustomEvent(customEvent, 1 , object state) or TriggerCustomEvent(customEvent, 2 , object state) respectively. Or do i always default to using TriggerCustomEvent(customEvent, 0 , object state) Again, you still have not answer my query on what exactly does TriggerCustomEvent do ? What pointers is the method resetting ? thanks

          Comment


            #6
            Hello,

            I will have someone reply to you on Monday. Thank you for your patience.
            DenNinjaTrader Customer Service

            Comment


              #7
              You need to call it with the BIP context you want it to run off of. Pointers reset are internal pointers. These pointers control things like CurrentBar pointers to let you know which bar you are on and things like this that are under the hood things for NinjaTrader to help your script be in the correct location with correct values. Generally, you don't need to worry about it.
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                Originally posted by NinjaTrader_Josh View Post
                You need to call it with the BIP context you want it to run off of. Pointers reset are internal pointers. These pointers control things like CurrentBar pointers to let you know which bar you are on and things like this that are under the hood things for NinjaTrader to help your script be in the correct location with correct values. Generally, you don't need to worry about it.
                Actually could you give an example of what can go wrong if we do not trigger custom events via TriggerCustomEvent method ? thanks

                Comment


                  #9
                  aljafp,

                  I am not sure what you mean. Nothing "goes wrong" per se. If you don't trigger an event then simply no event is thrown and that part of your code does not process.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by NinjaTrader_Josh View Post
                    aljafp,

                    I am not sure what you mean. Nothing "goes wrong" per se. If you don't trigger an event then simply no event is thrown and that part of your code does not process.
                    Let me clarify
                    What if instead of

                    // Your timer object tick event handler
                    private void OnTimerTick()
                    {
                    // Do not process your code here but instead call the TriggerCustomEvent()
                    // method and process your code in the MyCustomHandler method
                    TriggerCustomEvent(new CustomEvent(MyCustomHandler, 0, "myText");
                    }

                    private void MyCustomHandler(object state)
                    {
                    Print((string) state + " " + CurrentBar.ToString());
                    }

                    Without going through TriggerCustomEvent I do
                    // Your timer object tick event handler
                    private void OnTimerTick()
                    {
                    MyProcessingFunction()
                    }

                    Without Calling TriggerCustomEvent, MyProcessingFunction will still be triggered.

                    So What can go wrong ? If nothing can go wrong, why the need to call TriggerCustomEvent in the first place ?

                    thanks

                    Comment


                      #11
                      aljafp,

                      That is not an event then. That is simply processing the method. You would only be able to process that method when you receive an event. For instance, OnBarUpdate()s are events. If you just want the code to process based off of bar updates then you do not need to use TriggerCustomEvent at all.
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #12
                        Originally posted by NinjaTrader_Josh View Post
                        aljafp,

                        That is not an event then. That is simply processing the method. You would only be able to process that method when you receive an event. For instance, OnBarUpdate()s are events. If you just want the code to process based off of bar updates then you do not need to use TriggerCustomEvent at all.
                        Sigh, Let me clarify further
                        protected override void Initialize()
                        {
                        myTimer.Tick += new EventHandler(OnTimerTick);
                        myTimer.Interval = 10000;
                        myTimer.Start();
                        }

                        // Your timer object tick event handler
                        private void OnTimerTick()
                        {
                        MyProcessingFunction()
                        }
                        Without Calling TriggerCustomEvent,
                        MyProcessingFunction will still be triggered. So What can go wrong ? If nothing can go wrong, why the need to call TriggerCustomEvent in the first place ? thanks

                        Comment


                          #13
                          You needed to through the TriggerCustomEvent logic to make sure the NT internal stuff is setup correctly.

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by kujista, Today, 06:23 AM
                          0 responses
                          1 view
                          0 likes
                          Last Post kujista
                          by kujista
                           
                          Started by traderqz, Yesterday, 04:32 PM
                          1 response
                          10 views
                          0 likes
                          Last Post NinjaTrader_Gaby  
                          Started by f.saeidi, Today, 05:56 AM
                          1 response
                          4 views
                          0 likes
                          Last Post Jltarrau  
                          Started by Jltarrau, Today, 05:57 AM
                          0 responses
                          4 views
                          0 likes
                          Last Post Jltarrau  
                          Started by Stanfillirenfro, Yesterday, 09:19 AM
                          7 responses
                          52 views
                          0 likes
                          Last Post NinjaTrader_Gaby  
                          Working...
                          X