Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to avoid File errors using StreamWriter on multiple instrument Backtest

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

    How to avoid File errors using StreamWriter on multiple instrument Backtest

    Hi,

    I'm trying to collect statistics using StreamWriter and Strategy Analyzer. For a single instrument, all works fine. But I would like to be able to run the strategy on an instrument list, and collect all the resulting data in a single file to save work.

    This causes file access errors because NT runs a bunch of the instruments simultaneously.

    I am sure there must be a simple way around this problem, but I can't figure it out...

    Perhaps some of you crack programmers out there could provide some tips?

    Most appreciated!

    PS. Im using NT8B10

    #2
    Hi ours_solaire,

    As a tip, use a static method that queues things in a list and writes that list to the file line by line (instead of many instances that all try and write simultaneously).

    Attached is an example of creating static methods.


    You can also contact one of our professional NinjaScript Consultants who would be eager to create or modify this script at your request or assist you with your script. Please let me know if you would like our business development follow up with you with a list of professional NinjaScript Consultants who would be happy to create this script or any others at your request.
    Attached Files
    Last edited by NinjaTrader_ChelseaB; 04-19-2016, 03:14 PM.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello ours_solaire,

      If you want a less elegant, but easy-to-implement solution, you could prefix the filename used by StreamWriter with Instrument.MasterInstrument.name for stocks, or name & contract date for futures . This would separate the write operations to separate files and eliminate simultaneous access errors.

      Then later manually merge the files together.

      Comment


        #4
        Thanks for the tips guys!

        rayko: it's exactly this last step of concatenating the files together manually that I want to avoid. If I run this puppy on the NASDAQ100 list, for example, that's quite a lot of merging

        ChelseaB: thanks for your offer of support. I will try to sort this out myself, but if I run up against too many more issues, I will contact your support guys. thanks!

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by sightcareclickhere, Today, 01:55 PM
        0 responses
        1 view
        0 likes
        Last Post sightcareclickhere  
        Started by Mindset, 05-06-2023, 09:03 PM
        9 responses
        258 views
        0 likes
        Last Post ender_wiggum  
        Started by Mizzouman1, Today, 07:35 AM
        4 responses
        18 views
        0 likes
        Last Post Mizzouman1  
        Started by philmg, Today, 01:17 PM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_ChristopherJ  
        Started by cre8able, Today, 01:01 PM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X