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

stream reader onbarupdate

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

    stream reader onbarupdate

    Hello,

    I want to ask how I can force stream reader (I use it for reading from web) in onbarupdate eg only with close of bar when running a script with cobcfalse. Because NT7 was frozen all the time I put it to onstartup, but I need to read it during a trade in onbarupdate for moving stops. I have now:

    string uri = @"https://www.dropbox.com/s/" + filePath;
    HttpWebRequest req = (HttpWebRequest)WebRequest.Create(uri);
    HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
    using (StreamReader sr = new StreamReader(resp.GetResponseStream()))
    {
    string line;
    while ((line=sr.ReadLine())!=null)
    {
    string[] parts = line.Split(',');
    and so on.............

    Whats wrong with this please or what do I have to add so that I can use it in onbarupdate without freezing?

    Thank you!
    Tony

    #2
    Is this close enough?

    Comment


      #3
      You might also consider using a timer in NT.,

      It might be even more feasible to write a separate program that runs every 30 seconds/1 minute, etc, writes the data to a file, and then NT reads that file. That way NT won't "freeze". You'll have to work out locking issues, etc.

      Comment


        #4
        sledge,

        thank you for your reply. In the meantime I added FirstTickOfBar but also then its freezing and I have to shut down NT7 from taskmanager. When running the script with COBCtrue then its also freezing when enabling the script.

        So it seems that it works only in OnStartUp but not in OnBarUpdate. (its a good idea with reading in a separate program but this will not work then as well, no?)

        Than you!
        Tony

        Comment


          #5
          Without debugging I don't have much further to speculate on your code.

          dropbox.com could be refusing connection?, or your code is some how entering an infinite loop while parsing.

          I remember writing some code - to parse my cable modem's webpage to find the status of the signal. I have since lost this code.

          You might want to fully debug the code in OnBarUpdate after you slow it down.

          Comment


            #6
            Hello Tonynt,

            Thank you for your note.

            Without the script I'm unable to test on my end however I'm curious if you first download the file, then parse it, if that would prevent the freeze?

            Here is a link to a sample where I first download the file then parse it,


            Please let us know if this does not resolve the issue.
            Alan P.NinjaTrader Customer Service

            Comment


              #7
              Alan,

              get the error message when importing to NT7.

              Thanks
              Tony
              Attached Files

              Comment


                #8
                Hello tonynt,

                The indicator I linked to is for NinjaTrader 8 and was provided to demonstrate how to download data then parse it.

                Please let us know if you need further assistance.
                Alan P.NinjaTrader Customer Service

                Comment


                  #9
                  Alan P: any chance of getting that file you linked to here since I can not download anything from the User Fileshare area...

                  Comment


                    #10
                    Hello EminiTrader,

                    The file that was previously linked to has been removed for the time being, I checked with Alan and he noted that it needed to be updated and needed to be removed until that was able to happen. If you are looking for a specific concept from that indicator I could suggest to do a general web search for "C# download file" or "C# parse file" as some examples. Currently we only have a sample of reading/writing files and that really is just standard C# so any external tutorials can help here.


                    Please let me know if I may be of further assistance.
                    JesseNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by BarzTrading, Today, 07:25 AM
                    2 responses
                    15 views
                    1 like
                    Last Post BarzTrading  
                    Started by devatechnologies, 04-14-2024, 02:58 PM
                    3 responses
                    20 views
                    0 likes
                    Last Post NinjaTrader_BrandonH  
                    Started by tkaboris, Today, 08:01 AM
                    0 responses
                    4 views
                    0 likes
                    Last Post tkaboris  
                    Started by EB Worx, 04-04-2023, 02:34 AM
                    7 responses
                    162 views
                    0 likes
                    Last Post VFI26
                    by VFI26
                     
                    Started by Mizzouman1, Today, 07:35 AM
                    1 response
                    10 views
                    0 likes
                    Last Post NinjaTrader_Gaby  
                    Working...
                    X