Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Need advice. blocked file. async await

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

    Need advice. blocked file. async await

    hi all.
    my goal to get a last OHLC bar and upload it to a file.
    then in my program(java) i want take data from this file and write some code.
    my problem: this file is blocked by writer from ninjatrader. and i can't read data from file.
    i have tryed to create a new thread and to wrote OHLC data from this thread with some Thread.sleep(50). but ninjatrade make crashdown all time.
    i have tryed to use async method but indicator don't compile. cause don't to see async and await.
    has anybody who can to give my good advice how resolve it?
    ps. NT_7 .NET 4.5.2

    #2
    Hello ansgrecho, thanks for writing in.

    Any external application outside of NinjaTrader goes out of the scope of support we could provide. Use the StreamWriter class to open the file, then make sure to call StreamWriter.Close() when the file writing is done. If the application outside of NinjaTrader can not access the file, it needs special exception handling that will wait until the file is available to be opened. We do not reccomend using Thread.Sleep within the NinjaScript as this can cause stability issues in the NinjaTrader system as a whole. An async Task is not supported in NinjaTrader 7 as it requires .Net 4 and NinjaTrader 7 uses .Net 3.5

    There is an example of using the Streamwriter here:

    https://ninjatrader.com/support/help...o_write_to.htm

    Kind regards,
    ChrisL

    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Hi Chris.
      This example don't resolve my problem.
      can I create new threads in the editor window? if so, what control words(sleep,wait,notify,yield) does the ninjatrader support? cause i can to get a full control on writer only from my thread, but not base thread.
      i need to get data in my application from a blocked file. but i don't achive it. does NT_8 support .Net 4.5?
      in this article from your site to wrote "Due to the asynchronous nature of this indicator" TIPS. and why is here async to use and i can't to use async in nt_7 https://ninjatrader.com/support/help...o_write_to.htm , https://gyazo.com/35a26ed37ac852af7c2d05f897e23346?
      Last edited by ansgrecho; 09-24-2020, 02:13 AM.

      Comment


        #4
        Hello ansgrecho, thanks for your reply.

        The file is being blocked because it is open, not because it's running on the UI thread of NinjaTrader. In the NinjaTrader 8 example, the stream writer is closed at the end of the writing procedure. This should be sufficient to allow another program to access the file. This should be tested thoroughly.

        Please let me know if I can assist any further.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          ok. Thanks for you help

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by zacharydw00, Today, 05:14 PM
          0 responses
          11 views
          0 likes
          Last Post zacharydw00  
          Started by shahabjet1, Today, 04:47 PM
          0 responses
          19 views
          0 likes
          Last Post shahabjet1  
          Started by aligator, Today, 04:32 PM
          0 responses
          17 views
          0 likes
          Last Post aligator  
          Started by timko, Today, 04:02 PM
          0 responses
          19 views
          0 likes
          Last Post timko
          by timko
           
          Started by asmmbillah, Today, 03:37 PM
          2 responses
          24 views
          0 likes
          Last Post asmmbillah  
          Working...
          X