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

Publish manual trades to Twitter

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

    Publish manual trades to Twitter

    I'd like to use some library (perhaps this one: http://twittervb.codeplex.com/documentation or some other one) to publish trades I make to twitter as I place them. The thing is, these are manually placed trades in the DOM, not strategy-initiated trades. Is it possible to do something like this with a user-initiated trade?

    Said another way, can I receive events in a strategy and retrieve order information, if that order was not placed within the strategy?
    Last edited by JoshDance; 05-08-2011, 01:16 PM.

    #2
    JoshDance, tapping into manual events is not currently supported.

    Strategies don't know about positions/orders/fills started outside that strategy.
    AustinNinjaTrader Customer Service

    Comment


      #3
      Thanks Austin. It sounds like my best option may be to read from the log file.

      Comment


        #4
        I'm trying now to open the log file. Here is my code:

        Code:
                protected override void Initialize()
                {
                    Overlay				= false;
                    CalculateOnBarClose	= false;
        			Print("trying to open: " + path);
        			if (File.Exists(path))
        			{
        				try {
        					sr = new System.IO.StreamReader(path);
        					sr.ReadToEnd();
        				}
        				catch (Exception e)
        				{Print("Error reading file.");}
        			}
        			else
        				Print("File does not exist.");
        
                }
        Above that I define "path" this way:

        Code:
        		private string path = Cbi.Core.UserDataDir.ToString() + "log\\log.20110508";
        My output window then says:

        trying to open: C:\Users\Josh\Documents\NinjaTrader 7\log\log.20110508
        File does not exist.

        But if I copy the exact string from the error message, I can go to notepad and paste it and open the file. Any ideas? This should be simple, not sure what's going on. And yes, the file actually exists and I can open it, and the date is correct.

        Comment


          #5
          Interesting thread. Perhaps this is reflecting my lack of knowledge regarding your problem, but wouldn't it be easier to use the SendMail() command and update twitter by email?

          Regards,

          Comment


            #6
            JoshDance, looks like it's missing .txt ending file extension?
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Originally posted by J_o_s View Post
              Interesting thread. Perhaps this is reflecting my lack of knowledge regarding your problem, but wouldn't it be easier to use the SendMail() command and update twitter by email?

              Regards,
              I may in fact use that but right now the issue is that I have to get the data from somewhere, and the only solution I can think of for this particular problem is to do so via reading the log.

              Comment


                #8
                Originally posted by NinjaTrader_Bertrand View Post
                JoshDance, looks like it's missing .txt ending file extension?
                Thanks Bertrand, big duh on my part! Windows explorer is hiding the .txt extension.

                Comment


                  #9
                  I'm getting the following error:

                  Error reading file. System.IO.IOException: The process cannot access the file 'C:\Users\Josh\Documents\NinjaTrader 7\log\log.20110509.txt' because it is being used by another process.
                  That other process would obviously be NT, which has it open for read/write. Is there a way using the StreamReader(path) to open this as read-only, or is this even possible? I'm currently just doing:

                  Code:
                  sr = new System.IO.StreamReader(path);
                  Edit: I just changed the code to try to open readwrite and it works:

                  Code:
                  fs = new FileStream(path,FileMode.Open,FileAccess.Read,FileShare.ReadWrite);
                  sr = new System.IO.StreamReader(fs);
                  Last edited by JoshDance; 05-09-2011, 08:36 PM.

                  Comment


                    #10
                    Can we see your Twitter feed when you are done? I guess your trades have to be seen by us somehow

                    Comment


                      #11
                      Originally posted by dennho View Post
                      Can we see your Twitter feed when you are done? I guess your trades have to be seen by us somehow
                      Sure, but if I were you, I wouldn't base any trade decisions off of anything I do, unless you want your account to decline like mine has the last couple of weeks. This is more of an interesting exercise for me than anything else. I just switched my name last night so it may not show up yet, but it's "joshtrader" , let me know if you can find me. Also, I'm only posting executions as they happen, not when the order is placed, stop location, etc. From what I can tell so far, it posts to twitter to within about 2-3 seconds, not bad at all really.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by helpwanted, Today, 03:06 AM
                      1 response
                      16 views
                      0 likes
                      Last Post sarafuenonly123  
                      Started by Brevo, Today, 01:45 AM
                      0 responses
                      11 views
                      0 likes
                      Last Post Brevo
                      by Brevo
                       
                      Started by aussugardefender, Today, 01:07 AM
                      0 responses
                      6 views
                      0 likes
                      Last Post aussugardefender  
                      Started by pvincent, 06-23-2022, 12:53 PM
                      14 responses
                      244 views
                      0 likes
                      Last Post Nyman
                      by Nyman
                       
                      Started by TraderG23, 12-08-2023, 07:56 AM
                      9 responses
                      387 views
                      1 like
                      Last Post Gavini
                      by Gavini
                       
                      Working...
                      X