Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Mr C

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

    Mr C

    Hello- Currently I have a strategy that dumps a bunch of data from my strategy directly into an Excel file. I'm referencing the Microsoft.Office.Interop.Excel file in my code. The problem I'm having is that the program reliably crashes during data transfer. I'm getting an HRESULT Busy exception which has to do with the fact that Excel only works from a single threaded condition whereas the strategy, through the interop program, sends multiple threads. I implemented an Imessagefilter in an attempt to fix this. That C# code is loaded in the strategy directory and appears to be working. The only thing left for me to do is to set the thread to single (Single Thread Apartment ) via the [STAthread] reference. But for some reason this doesn't appear to be working since I'm getting a message that the thread is still MTA (Multiple Thread Apartment) when I run the code. This error message is coming from my Imessagefilter code I mentioned earlier. Is there a way to properly set the thread to STA?



    #2
    Hello,

    Thank you for the post.

    Update:
    I modified the indicator so that it does not freeze the UI thread. I just put the Excel writing in OnTermination() so the UI thread will halt for the time it takes to write the entire bar array to the file.

    I am going to do some testing and will be back with a reply shortly. If you can post a simple example of how you are doing this it will allow me to better assist.

    I look forward to assisting further.
    Attached Files
    Last edited by NinjaTrader_ChrisL; 01-10-2018, 08:12 AM. Reason: Update

    Comment


      #3
      Hi Chris,

      You can refer to this post on the Ninja Forum on how I'm doing this. There's a zip file on this post.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      559 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      324 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
      546 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      547 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X