Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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
    Chris L.NinjaTrader Customer Service

    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 Lumbeezl, 01-11-2022, 06:50 PM
      30 responses
      802 views
      1 like
      Last Post grayfrog  
      Started by xiinteractive, 04-09-2024, 08:08 AM
      3 responses
      11 views
      0 likes
      Last Post NinjaTrader_Erick  
      Started by Johnny Santiago, 10-11-2019, 09:21 AM
      95 responses
      6,193 views
      0 likes
      Last Post xiinteractive  
      Started by Irukandji, Today, 09:34 AM
      1 response
      3 views
      0 likes
      Last Post NinjaTrader_Clayton  
      Started by RubenCazorla, Today, 09:07 AM
      1 response
      6 views
      0 likes
      Last Post RubenCazorla  
      Working...
      X