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

Write to a file

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

    Write to a file

    I would like to create a file and write to it from a strategy, is that possible? I've found examples for indicators but not strategies.

    Is there a unique number to identify each position? If so, how do I get that # in Ninjascript?

    Thanks!!

    #2
    Hello mrmistermike2016, and thank you for your question. For File I/O, you will need to use MSDN's built-in C# functionality. Here is some publicly available documentation on File I/O and, if you intend to read this data in a spreadsheet, some publicly available documentation for CSV methods as well.

    Learn the basics of file and stream I/O, which is the transfer of data either to or from a storage medium, in .NET.

    http://stackoverflow.com/questions/3...-using-c-sharp (David Pokluda's answer regarding using the Visual Basic CSV implementation from C#)

    Is there a unique number to identify each position?
    You as a user can

    • create a Dictionary<long, Position>
    • implement an OnPositionUpdate method
    • use the (linked documentation publicly available) MSDN C# UUID method to create a unique ID for each position
    • use this unique ID as your Dictionary key, and your Position object as its value

    Please let us know if there are any other ways we can help
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      This doesn't make sense to me. So if I have an issue with a position and I need to discuss it with my broker, what information do I give them?

      How do I request/suggest this enhancement in a newer version? I can't believe I'm the only trader that would find this information useful.

      Thanks!!

      Comment


        #4
        Since I am more of a technical support specialist I have contacted a colleague of mine who can discuss your options as far as consulting with a NinjaScript specialist who can configure your strategy with the functionality I outlined.
        Jessica P.NinjaTrader Customer Service

        Comment


          #5
          Hello mrmistermike2016,

          This is Ryan L. from the NinjaTrader Ecosystem responding on behalf of my colleague Jessica.

          You can search our extensive library of NinjaScript consultants for any custom strategy work for use within NinjaTrader through the link below. Simply enter a consultant name or search by using our filter categories. Once you have identified your consultants of choice, please visit each consultant's site for more information or contact them directly to learn more!

          This NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The companies and services listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.

          Please let me know if you have any questions, concerns or if I can provide any further assistance by responding to this thread at your convenience.
          Ryan L.NinjaTrader Customer Service

          Comment


            #6
            Hey Ryan, I don't need a Ninjascript consultant. I have been programming for years and I have a slew of colleagues with C# experience. My question is regarding the Position ID and can I access it or not in Ninjascript?

            I spoke to the team at Forex.Com and all positions and orders have unique IDs. Why can't I see it like I can the open price, position type, etc? Somehow behind the scene Ninjatrader has to connect to the right position and order at the broker. How is that done?

            Thanks!!

            Comment


              #7
              I believe there was a miscommunication. If you are not asking how to implement File I/O, and based on your most recent post, I believe you may be referring to an Order ID. That information can be retrieved from OnOrderUpdate. The passed-in order object has a unique OrderID. This information as well as information regarding the order type, entry price, and others is made available here as well. This documentation has more information.

              Order objects : http://ninjatrader.com/support/helpG...n-us/order.htm
              OnOrderUpdate (contains a code example) : http://ninjatrader.com/support/helpG...rderupdate.htm

              Position in NinjaScript usually refers to e.g. "3 deep on the long side of the market". Tracking when that sort of Position had occurred uniquely is something a user will need to do. However, the method used to enter a Position is usually referred to as an Order, and these are indeed automatically assigned tracking IDs.

              I hope this clears up the situation, and the way I had interpreted your request. Please let us know if there are any other ways we can help.
              Jessica P.NinjaTrader Customer Service

              Comment


                #8
                Thanks Jessica. I'll work in it and let you know.

                Thanks!!

                Comment


                  #9
                  Wrong thread!

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by DJ888, 04-16-2024, 06:09 PM
                  6 responses
                  18 views
                  0 likes
                  Last Post DJ888
                  by DJ888
                   
                  Started by Jon17, Today, 04:33 PM
                  0 responses
                  1 view
                  0 likes
                  Last Post Jon17
                  by Jon17
                   
                  Started by Javierw.ok, Today, 04:12 PM
                  0 responses
                  6 views
                  0 likes
                  Last Post Javierw.ok  
                  Started by timmbbo, Today, 08:59 AM
                  2 responses
                  10 views
                  0 likes
                  Last Post bltdavid  
                  Started by alifarahani, Today, 09:40 AM
                  6 responses
                  41 views
                  0 likes
                  Last Post alifarahani  
                  Working...
                  X