Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy start hook

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

    Strategy start hook

    Hi guys

    I need a hook which will allow me to run some code when a custom strategy is started. At the moment I've overridden the Initialize() method and placed my setup code in there. However, I've got all kinds of problems (such as TickSize not being accessible) because that method is called any time an instance strategy is created. Obviously this can happen before any instrument has been selected.

    There must be some way for me to determine when the strategy has started and pick up info such as the TickSize.

    Thanks.

    #2
    Please try this:
    - define a boolean flag variable, set to true
    - first time OnBarUpdate is called check if flag is true and then
    * run your Init() stuff
    * set flag variable to false

    Comment


      #3
      Already tried that. The problem is the L2 order book gets built before OnBarUpdate() is called for the first time. What I need is a hook which allows me to setup my strategy before any market data events get fired.

      Comment


        #4
        ScoobyStoo,

        Maybe I am missing something but I am not seeing why there is such a requirement of doing this before receiving data events. What is it that you need to build beforehand?
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Josh View Post
          ScoobyStoo,

          Maybe I am missing something but I am not seeing why there is such a requirement of doing this before receiving data events. What is it that you need to build beforehand?
          It's OK, don't worry about it. I need to construct a ton of objects required by the strategy prior to it beginning to process market data. I've fixed it by including a call at the beginning on each overridden market data method to determine if the strategy has been initialised and if not to initialise it. That way I know that whichever market data event is raised first, the strategy will get correctly initialised. It's a really ugly solution though...

          Would be really handy for NT7 to expose proper hooks to all the strategy lifecycle events (start, pause, stop etc). Obviously, I don't know how difficult that would be to do though...

          Thanks for the help

          Comment


            #6
            Great you got it working, thanks for the suggestions ScoobyStoo.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            647 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            368 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            108 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            571 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            573 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X