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

Does File.Readline() in a chart indicator freeze or delay chart updating visually

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

    Does File.Readline() in a chart indicator freeze or delay chart updating visually

    Hello,

    I am looking to transfer data between NT7 and NT8 and after researching and testing have decided that the best way for me to do this is to write from NT7 to a small text file and then read it in NT8 from a custom indicator.

    My question is

    if I use File.Readlines() (and/or the associated methods) in an NT8 indicator, will my NT8 chart (where the indicator lives) freeze or stop updating until after the File.Readlines call has been completed?

    I am asking because I am considering using this approach on a fast NQ tick chart (25 or 50 ticks) and could potentially be making the call multiple times per second in a fast market even when using OnBarClose() for the indicator.

    Please note that the text file that is being read is relatively small, say around less than 20kb; so not a lot of data is being read, but regardless, if this will slow my chart from updating as quickly as possible then I'm thinking I should scratch this idea.

    Please advise?


    Thank you,

    Josh
    Last edited by NTLevel2; 07-11-2022, 01:45 PM.

    #2
    Hello NTLevel2,

    Yes that could cause delays, you could also run into file IO errors if that file is being accessed by other scripts. In general doing operations fast with the file system is not advisable, you would generally want to do read/write operations as infrequent as possible to avoid any kind of delay in processing.

    File actions need to complete before the next line of code executes so if the file takes some time to read that could cause delays if you do that very frequently.

    The hard drive is also much less fast in terms of access/writing than using memory so if possible it would be suggested to make this into a variable in the script to read/modify.

    If the file is absolutely required you would need to run this for some time on your machine to get an idea if there are any problems surrounding doing that with the file in question.

    If you are trying to transfer some data which the platform cannot natively import it would be best to have nt7 write all data needed at once and then have NT8 read that data once at the start of the script and store that data to a variable. If the data in the file is not changing then reading it more than once would just be extra work.



    Last edited by NinjaTrader_Jesse; 07-11-2022, 02:06 PM.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hello Jesse,

      Thank you for your prompt and thorough response. Thank you for confirming- I was thinking that the File.Readlines() might cause a delay.

      Unfortunately, I do need to continuously read in the data from an equally fast chart coming from NT7. Thinking creatively, I have a follow up question:

      Assuming I have sufficient processing power, If I make the File.Readlines() call from a Market Analyzer cell (as opposed to an indicator on the chart itself), do you know if that would still cause a delay in the updating of my NQ price chart?

      I understand and agree that transferring the data through memory would be better than using I/O from the HD, but because of NT7's older .NET build, I seem to be limited in the types of Interprocess Communication that can be used between the NT7 and NT8 applications.


      Thank you again,

      Josh

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by arvidvanstaey, Today, 02:19 PM
      4 responses
      10 views
      0 likes
      Last Post arvidvanstaey  
      Started by samish18, 04-17-2024, 08:57 AM
      16 responses
      56 views
      0 likes
      Last Post samish18  
      Started by jordanq2, Today, 03:10 PM
      2 responses
      8 views
      0 likes
      Last Post jordanq2  
      Started by traderqz, Today, 12:06 AM
      10 responses
      18 views
      0 likes
      Last Post traderqz  
      Started by algospoke, 04-17-2024, 06:40 PM
      5 responses
      47 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Working...
      X