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

Export last data to file

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

    Export last data to file

    What is the best way to export the last bid/offer/last data to a simple *.txt file? Can it be done by any NT tools or script only?

    #2
    Hi curious, welcome to our support forums! Yes, you would need custom coding to write this to a txt file - http://www.ninjatrader-support2.com/...ead.php?t=3477

    For Level1 data you can work with OnMarketData() - http://www.ninjatrader-support.com/H...arketData.html
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Thanks.

      OK, I'll write&compile some code that I need in NinjaScript Editor. How should then I run it?

      Comment


        #4
        You can then run the indicator or strategy from the chart by right clicking in it and selecting either to add 'indicators' or 'strategies'.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          As I understand for level1 data I can use both OnMarketData() and OnBarUpdate() methods. What is the difference between them for bid/ask data export? Almost every bid/ask change brings OnBarUpdate also. Am I right? Or there is any difference which I have not considered?

          Comment


            #6
            You're correct, you can use either one to access the needed data. Just would need to run things in realtime on CalculateOnBarClose = false to get updates on each incoming tick.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Originally posted by curious View Post
              As I understand for level1 data I can use both OnMarketData() and OnBarUpdate() methods. What is the difference between them for bid/ask data export? Almost every bid/ask change brings OnBarUpdate also. Am I right? Or there is any difference which I have not considered?
              each bid/ask change doesn't necessarily mean OnBarUpdate is called. for example, if someone canceled an order right at the ask, the ask would drop but there would be no reported executions. see one of my older posts to get a feel for what can be done with last/bid/ask data.. http://www.ninjatrader-support2.com/...ad.php?t=10296

              Comment


                #8
                Originally posted by NinjaTrader_Bertrand View Post
                Yes, you would need custom coding to write this to a txt file - http://www.ninjatrader-support2.com/...ead.php?t=3477
                Going back to your example. You offer to use the File.WriteAllLines() method (or I can use File.WriteAllText() instead), but they work only with string data type. Is there any method to output doubles (bid, ask, etc.) directly or I have to use Convert.ToString() function before and File.WriteAllLines()/File.WriteAllText() then?

                Comment


                  #9
                  Hello,

                  If I recall correctly, they should write fine. Try it, if it does not work you will need use .ToString()
                  DenNinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by NinjaTrader_Ben View Post
                    Hello,

                    If I recall correctly, they should write fine. Try it, if it does not work you will need use .ToString()
                    Well, it doesn't work w/o .ToString(). Returns 2 errors:
                    The best overloaded method match for 'System.IO.File.WriteAllText(string,string)' has some invalid arguments
                    Argument '2': cannot convert from 'double' to 'string'

                    Comment


                      #11
                      The error states what is wrong. You can't use a double when it is looking for a string. To convert the double to a string you can just use .ToString() on the double variable.
                      Josh P.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by fwendolynlpxz, Today, 05:19 AM
                      0 responses
                      1 view
                      0 likes
                      Last Post fwendolynlpxz  
                      Started by traderqz, Yesterday, 12:06 AM
                      11 responses
                      27 views
                      0 likes
                      Last Post NinjaTrader_Gaby  
                      Started by PaulMohn, Today, 03:49 AM
                      0 responses
                      8 views
                      0 likes
                      Last Post PaulMohn  
                      Started by inanazsocial, Today, 01:15 AM
                      1 response
                      10 views
                      0 likes
                      Last Post NinjaTrader_Jason  
                      Started by rocketman7, Today, 02:12 AM
                      0 responses
                      11 views
                      0 likes
                      Last Post rocketman7  
                      Working...
                      X