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 cmtjoancolmenero, Yesterday, 03:58 PM
      11 responses
      39 views
      0 likes
      Last Post cmtjoancolmenero  
      Started by FrazMann, Today, 11:21 AM
      0 responses
      3 views
      0 likes
      Last Post FrazMann  
      Started by geddyisodin, Yesterday, 05:20 AM
      8 responses
      52 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by DayTradingDEMON, Today, 09:28 AM
      4 responses
      26 views
      0 likes
      Last Post DayTradingDEMON  
      Started by George21, Today, 10:07 AM
      1 response
      22 views
      0 likes
      Last Post NinjaTrader_ChristopherJ  
      Working...
      X