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 nandhumca, Today, 03:41 PM
      0 responses
      4 views
      0 likes
      Last Post nandhumca  
      Started by The_Sec, Today, 03:37 PM
      0 responses
      3 views
      0 likes
      Last Post The_Sec
      by The_Sec
       
      Started by GwFutures1988, Today, 02:48 PM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_Clayton  
      Started by ScottWalsh, 04-16-2024, 04:29 PM
      6 responses
      33 views
      0 likes
      Last Post ScottWalsh  
      Started by frankthearm, Today, 09:08 AM
      10 responses
      36 views
      0 likes
      Last Post frankthearm  
      Working...
      X