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

trading with files

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

    trading with files

    I'm trying to develop an indicator that listens to one of my accounts and copies the orders to another account.
    I'm trying to do it with files.
    https://ninjatrader.com/support/help..._files_oif.htm
    says that you should increment the OIF.txt file you use for each order.

    Why is it adding slashes before and after my incrementing integer that I turned into a string?


    Click image for larger version  Name:	Untitled.png Views:	0 Size:	5.9 KB ID:	1189708


    Code:
     private void [B]OnOrderUpdate[/B](object sender, OrderEventArgs e)
    {
    string folderName = @"C:\Users\ezrol\OneDrive\Documents\NinjaTrader 8\incoming\";
    string fileName = @"oif";
    [B]string stringIncrement = increment.ToString();[/B]
    string extension = @".txt";
    string pathAndFile = System.IO.Path.Combine(folderName, fileName, [B]stringIncrement[/B], extension);
    
    string writeText = "";
    //string writeText = "PLACE";"SimJons";"INSTRUMENT;ACTION;1;OR DER TYPE;LIMIT PRICE;STOP PRICE;GTC;OCO ID;ORDER ID;STRATEGY;STRATEGY ID";        // [B]not sure how to correctly write the variables on all these fields?[/B]
    
    File.WriteAllText(pathAndFile, writeText); // Create a file and write the content of writeText to it
    increment++;
    }
    Last edited by ezrollin; 02-13-2022, 01:22 AM.

    #2
    I don't think Path.Combine is meant to create your filename. Try something like this instead:
    Code:
    string pathAndFileNew = System.IO.Path.Combine(folderName, fileName + stringIncrement + extension);

    Comment


      #3
      Hi,

      I have a side question.

      I noticed your path include "OneDrive". Are you actively running Microsoft OneDrive on your computer pointing to this location? If so, I would suggest closing the OneDrive while running NT8. The constant syncing caused many issues with my NT8, and I ended up uninstalling it. So, I'm very curious if you are still using it.

      Steven

      Comment


        #4
        Originally posted by ezrollin View Post
        I'm trying to develop an indicator that listens to one of my accounts and copies the orders to another account.
        I'm trying to do it with files.
        Why?
        I mean, that's not really necessary, is it?

        Using the Account Api, you have CreateOrder, Change,
        Cancel, and Submit methods, plus others.

        You monitor the leader account using the leader account's
        event handler OrderUpdate, then you reflect all leader
        account order submissions, changes, and cancellations
        to all follower account(s) -- using the same Account Api.

        Why do you need files?
        What problem are you trying to solve?

        Comment


          #5
          Originally posted by StevenL View Post
          Hi,

          I have a side question.

          I noticed your path include "OneDrive". Are you actively running Microsoft OneDrive on your computer pointing to this location? If so, I would suggest closing the OneDrive while running NT8. The constant syncing caused many issues with my NT8, and I ended up uninstalling it. So, I'm very curious if you are still using it.

          Steven
          Hell no! I had the same problem! I eventually got so tired of it I killed it!! good advice though!

          Comment


            #6
            Originally posted by bltdavid View Post

            Why?
            I mean, that's not really necessary, is it?

            Using the Account Api, you have CreateOrder, Change,
            Cancel, and Submit methods, plus others.

            You monitor the leader account using the leader account's
            event handler OrderUpdate, then you reflect all leader
            account order submissions, changes, and cancellations
            to all follower account(s) -- using the same Account Api.

            Why do you need files?
            What problem are you trying to solve?
            Couldnt figure it out. I'm not a programmer.
            It seemed like OIF was easier
            Could you help? thanks

            Comment


              #7
              Have you searched the forums for this trade copy functionality? I know there are many who do the same already, but maybe your requirements are a little different?

              Look at this thread.
              How to submit an order for a specific account - NinjaTrader Support Forum

              Comment


                #8
                Originally posted by StevenL View Post
                Have you searched the forums for this trade copy functionality? I know there are many who do the same already, but maybe your requirements are a little different?

                Look at this thread.
                How to submit an order for a specific account - NinjaTrader Support Forum
                Thanks but that didnt help me.
                Yes I went through about 8 pages of OIF search results yesterday.
                Theres not a lot of code examples anywhere.

                I got it writing correctly now.

                Now my only problem is this:
                Code:
                PLACE;<ACCOUNT>;<INSTRUMENT>;<ACTION>;<QTY>;<ORDER TYPE>;[LIMIT PRICE];[STOP PRICE];<TIF>;[OCO ID];[ORDER ID];[STRATEGY];[STRATEGY ID]
                I understand <> is required fields.
                How do i send my data to these fields?
                OnOrderUpdate (which my file writing is in) works like: e.Order.Name, e.Order.Instrument, OrderAction.Sell, OrderType.Limit, OrderEntry.Manual, TimeInForce.Day, 1, e.AverageFillPrice etc......
                What would be the correct syntax to send? thanks

                Comment


                  #9
                  I'm trying this:
                  Code:
                  string writeText = "PLACE";e.Order.Instrument; OrderAction; OrderType; LimitPrice; StopPrice; TimeInForce.GTC;
                  but its not allowing it.

                  Comment


                    #10
                    Code:
                    string writeText = "PLACE";Order.Instrument; Order.OrderAction; Order.OrderType; Order.LimitPrice; Order.StopPrice; Order.TimeInForce.GTC;
                    doesnt work..

                    Comment


                      #11
                      Hello ezrollin,

                      I would agree putting OIF files in the mix would be more work and slower than sending the orders to the account.

                      I have an example of placing orders to an account that demonstrates.
                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #12
                        Originally posted by ezrollin View Post
                        Code:
                        string writeText = "PLACE";Order.Instrument; Order.OrderAction; Order.OrderType; Order.LimitPrice; Order.StopPrice; Order.TimeInForce.GTC;
                        doesnt work..
                        string writeText = "PLACE;" + Order.Instrument + ";" + Order.OrderAction + ";" + Order.OrderType + ";" ....

                        Comment


                          #13
                          Originally posted by NinjaTrader_ChelseaB View Post
                          Hello ezrollin,

                          I would agree putting OIF files in the mix would be more work and slower than sending the orders to the account.

                          I have an example of placing orders to an account that demonstrates.
                          https://ninjatrader.com/support/foru...720#post820720

                          Looks like its operating like a strategy, making its own trades. But is not identified as a strategy. Theres no graphics on it. I think it could help me I'll look into it! thanks!


                          Originally posted by bltdavid View Post
                          string writeText = "PLACE;" + Order.Instrument + ";" + Order.OrderAction + ";" + Order.OrderType + ";" ....
                          I get the same errors I have been getting:

                          Click image for larger version  Name:	Untitled.png Views:	0 Size:	9.4 KB ID:	1189783
                          Thanks

                          Comment


                            #14
                            NT 8 Replicator | Speedy Trading Servers

                            Just ran across that. Haven't looked at it in detail yet, since I'm not needing it.

                            Comment


                              #15
                              Originally posted by StevenL View Post
                              NT 8 Replicator | Speedy Trading Servers

                              Just ran across that. Haven't looked at it in detail yet, since I'm not needing it.
                              Here's a more complete list.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by NRITV, Today, 01:15 PM
                              2 responses
                              8 views
                              0 likes
                              Last Post NRITV
                              by NRITV
                               
                              Started by frankthearm, Today, 09:08 AM
                              7 responses
                              31 views
                              0 likes
                              Last Post NinjaTrader_Clayton  
                              Started by maybeimnotrader, Yesterday, 05:46 PM
                              5 responses
                              26 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by quantismo, Yesterday, 05:13 PM
                              2 responses
                              19 views
                              0 likes
                              Last Post quantismo  
                              Started by adeelshahzad, Today, 03:54 AM
                              5 responses
                              33 views
                              0 likes
                              Last Post NinjaTrader_BrandonH  
                              Working...
                              X