Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Dev Question

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

    Dev Question

    Greetings, have two questions.

    Am developing a strategy which relies on getting 4 parameters specific to each instrument from an external DB (MS Access). So within the external DB I have ~200 stocks with their associated 4 parameters. As a traverse through the ~200 stocks during backtesting, I need to determine which instrument I’m on to make the correct call to fetch the corresponding record in Access. Is the Initialize() method called once per instrument tested? So if I were backtesting 200 instruments, it would be called once for each new instrument being tested? And second, what property can be accessed within Initialize() to tell me what instrument I’m on? Need this as a parameter to pull the right values from my Access DB.

    Many thanks for the help!

    #2
    Originally posted by dosjots View Post
    Greetings, have two questions.

    Am developing a strategy which relies on getting 4 parameters specific to each instrument from an external DB (MS Access). So within the external DB I have ~200 stocks with their associated 4 parameters. As a traverse through the ~200 stocks during backtesting, I need to determine which instrument I’m on to make the correct call to fetch the corresponding record in Access. Is the Initialize() method called once per instrument tested? So if I were backtesting 200 instruments, it would be called once for each new instrument being tested? And second, what property can be accessed within Initialize() to tell me what instrument I’m on? Need this as a parameter to pull the right values from my Access DB.

    Many thanks for the help!
    dosjots,

    I do not recommend doing that in Initialize() since it will be called multiple times.
    I would recommend moving to OnBarUpdate() and using somekind of toggle to make sure you call it once.
    Something like if(CurrentBar == 0) or using custom variable.

    Comment


      #3
      Hey Roonius, thanks for the response. I had thought that Initialize() was only called once per instrument. If multiple times, then yes I'll stick with OnBarUpdate(). Is there a property that you're aware of that I can look up the instrument name?

      Thanks again-

      Comment


        #4
        Originally posted by dosjots View Post
        Hey Roonius, thanks for the response. I had thought that Initialize() was only called once per instrument. If multiple times, then yes I'll stick with OnBarUpdate(). Is there a property that you're aware of that I can look up the instrument name?

        Thanks again-
        Initialize() is called only once per "primary bar"...

        But Initialize() can be called at some what arbitrary times in addition to when you actually run the strategy... it's called as soon as you open up the "New Strategy" window, for example. I think it does this just to pull out the default property values needed to populate the various fields for your "new strategy".

        I've always found that to be a little annoying... but that's life.

        Comment


          #5
          Originally posted by dosjots View Post
          Hey Roonius, thanks for the response. I had thought that Initialize() was only called once per instrument. If multiple times, then yes I'll stick with OnBarUpdate(). Is there a property that you're aware of that I can look up the instrument name?

          Thanks again-
          Bars.Instrument.FullName

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          633 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          364 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          105 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          567 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          568 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X