Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Twitter API added to Ninja... please?

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

    Twitter API added to Ninja... please?

    Hi Guys,

    I place my trades in Ninja, and then type them in twitter.

    It would be great if Ninja automatically tweeted entry, profit and stop.


    As an educator I'm sure a few of us would find this useful.
    (I noticed its been done for MT4 https://www.myfxbook.com/ , )

    Twitter APIs are simple and you could add it in, in no time.

    #2
    Hello loadednrg,

    Thank you for your post.

    I will forward this idea to development for possible inclusion on the list of possible future enhancement.
    Ryan O.NinjaTrader Customer Service

    Comment


      #3
      This is really very simple

      If you use this really pretty simple to accomplish.
      http://code.google.com/p/twitterizer/ will help.
      1) Download zip to your NT computer.
      2) Add the downloaded framework to your custom indicator/strategy (hint from edit scrip uset right mouse button and 'preferences' 'add' this new dll
      3) Start coding...

      e.g.
      #region Using declarations
      ...
      using NinjaTrader.Data;
      using NinjaTrader.Gui.Chart;
      using Twitterizer.Framework;
      #endregion
      ....
      #region Variables
      ....
      Twitter t = new Twitter("YourUserName", "YourPassword");
      #endregion

      //logic that tells you went to enter/exit goes here
      TwitterStatus newStatus = t.Status.Update("NinjaTrader to Twitter Trade 1 test - wow that was easy! *smiles");
      //Of course you'll want to put your trade details into the msg but that's simple enough

      That's it!

      Trade well.

      Kevin

      Comment


        #4
        Thanks Kevin, looks helpful, will give it a try. Cheers.

        Comment


          #5
          Twitter integration

          Hello can you help...I did what you said in your post. It compiles. But the script simply does not run. It does not even show up as an option in the backtest window.

          It does compile ok though. I added the dll as said. Though its not properties its called references on the right click in the editor.

          Any idea what I am doing wrong? Compatibility issues? Code snipets:

          #region Using declarations
          using System;
          using System.IO;
          using System.Text;
          using System.ComponentModel;
          using System.Diagnostics;
          using System.Drawing;
          using System.Drawing.Drawing2D;
          using System.Xml.Serialization;
          using NinjaTrader.Cbi;
          using NinjaTrader.Data;
          using NinjaTrader.Indicator;
          using NinjaTrader.Strategy;
          using NinjaTrader.Gui.Chart;
          using Twitterizer.Framework;
          #endregion

          #region Variables
          private int fast = 14;
          private int slow = 28;
          private int trailstop = 16;
          private int baroffset = 6;
          private int profittarget = 16;

          private bool trailstopflag = false;
          private bool doubletradeflag = false;
          private bool starttradeflag = false;
          private bool closetradeflag = false;
          private string positionflag;
          private double trailstopprice;
          private double entryprice;
          private int loopcounter = 999;
          Twitter t = new Twitter("blue_point", "xxxxx");

          private bool oopsdebug = true;
          private int tradelogflag = 0;

          #endregion

          No other twitter code exists ....

          Comment


            #6
            More 411

            It looks like you have initialized everything correctly but have not called the API to update the status.

            This line of code should be inserted in order to send a Twitter status update.
            //Insert your own text that includes the trade details
            TwitterStatus newStatus = t.Status.Update("NinjaTrader to Twitter Trade 1 test - wow that was easy!");

            A couple words of caution -
            You only get 150 requests to the Twitter API per hour. It is very easy to blow this limit out if you are calling the line of code above on bar updates. Also, you may wish to catch exceptions and toss them to the output window. This may help you figure out if you are actually authorizing at Twitter's site or not.

            This framework does not use oAuth at this point in time. oAuth is Twitter's preferred method of authorizing application users with the Twitter API. This framework is grandfather'd in to access the API without oAuth. - FROM WHAT I CAN TELL

            Maybe somebody that knows NT better than me could comment here-- I have only used this code successfully in Indicators. I have not tried it in strategies. SO when I fire off a Twitter status it's sending a status update to Twitter for a buy or sell 'signal' rather than an actual trade execution. It would be nice to see some sample code for the actual executions.

            Comment


              #7
              Sorry not that easy ... no i mean the script does not run at all !!!!

              Sorry not that easy ... no i mean the script does not run at all !!!!

              Yes I know what you said in ur response. The issue is that it does not run at ALL with this framework. The script does not even show up as an option in the backtest window....it simple when compiles screws something up...Yes it does compile...correctly...strange. There something in the dll or something specific to that package that Ninja does not like at run time....


              Originally posted by i001962 View Post
              It looks like you have initialized everything correctly but have not called the API to update the status.

              This line of code should be inserted in order to send a Twitter status update.
              //Insert your own text that includes the trade details
              TwitterStatus newStatus = t.Status.Update("NinjaTrader to Twitter Trade 1 test - wow that was easy!");

              A couple words of caution -
              You only get 150 requests to the Twitter API per hour. It is very easy to blow this limit out if you are calling the line of code above on bar updates. Also, you may wish to catch exceptions and toss them to the output window. This may help you figure out if you are actually authorizing at Twitter's site or not.

              This framework does not use oAuth at this point in time. oAuth is Twitter's preferred method of authorizing application users with the Twitter API. This framework is grandfather'd in to access the API without oAuth. - FROM WHAT I CAN TELL

              Maybe somebody that knows NT better than me could comment here-- I have only used this code successfully in Indicators. I have not tried it in strategies. SO when I fire off a Twitter status it's sending a status update to Twitter for a buy or sell 'signal' rather than an actual trade execution. It would be nice to see some sample code for the actual executions.

              Comment


                #8
                Don't know what to tell you other than it works as an indicator (for me) Can you get it to show up and select it as an indicator when viewing a chart?

                I'm using the latest NT version 6.5 something (sorry not at my trading computer to check the full details).

                Comment


                  #9
                  Twitter integration

                  Nope, it compiles but it must compiles into to guk. It definetly sees the framework...when not load it does not compile. When I comment out the define variable statement "Twitter t = new Twitter("blue_point", "xxxxx");" it then works, but then i dont have the structure code to work with obviously.......

                  Tried as well to make in public and private variable.....no go .... using the latest version of ninja 6.5 as well.

                  Originally posted by i001962 View Post
                  Don't know what to tell you other than it works as an indicator (for me) Can you get it to show up and select it as an indicator when viewing a chart?

                  I'm using the latest NT version 6.5 something (sorry not at my trading computer to check the full details).

                  Comment


                    #10
                    Brut force solution for twitter integration

                    Using a command line programme found by a google search (see attached). Don't forget to set the execution permisions on the executable, the location that u put it in and change the id and password of ur twitter account accordingly .... u can then change the string manipulations as u like.

                    Have fun...tested and works...


                    private void updatetwitter(string txt)
                    {
                    string twitterid = "twitterid";
                    string twitterpw = "password";
                    txt = "Blue trading robot: " + txt;
                    txt = txt + @" http://blue-point-trading.com/";
                    string prog = @"c:\temp\twimmando.exe ";
                    string cmd = @"-uri /statuses/update.json -f status ";
                    cmd = cmd + '"' + txt + '"';
                    cmd = cmd + " -post -u " + twitterid + " -p " + twitterpw;
                    Process p = new Process();
                    p.StartInfo.FileName = prog;
                    p.StartInfo.Arguments = cmd;
                    p.StartInfo.UseShellExecute = false;
                    p.StartInfo.CreateNoWindow = true;
                    p.StartInfo.RedirectStandardOutput = true;
                    p.StartInfo.UseShellExecute = false;
                    p.Start();
                    }
                    Attached Files
                    Last edited by Bluepoint; 12-23-2009, 07:48 PM.

                    Comment


                      #11
                      Hi, This is Ricky, creator of the Twitterizer framework. I'm not familiar with Ninja, but if there are any issues integrating the framework, I'd be more than happy.

                      @i001962: You're correct that OAuth is the preferred authentication method and our framework does not (yet) support it, but we weren't 'grandfathered' in, per-se. Basic authentication is still fully supported.

                      Regardless, the code posted looks correct. We have a few methods of determining what (if any) issues may have occurred. Feel free to reply here, PM me, or contact our mailing list if you have any questions or suggestions.

                      Mailing list: http://groups.google.com/group/twitterizer

                      Comment


                        #12
                        BluePoint - Glad to hear you found a way around the issue.
                        DiggitallyBorn - Glad to hear I was doing it correctly - BTW thanks for the awesome framework. Looking forward to the oAuth!

                        It occurred to me while adding a dll ref. for another project that I needed to restart NT after adding the reference in order for the namespace to be recognized and compile correctly. Not certain if that will help you BluePoint but thought I'd share it.

                        Comment


                          #13
                          Example of Twitter into NT

                          http://www.youtube.com/watch?v=3n9DFx634Es

                          The above vid is a demo of a NT indicator I've created (er...mashed together) that uses the Twitterizer framework to pull in Tweets.

                          I use the indicator with Market Replay to insert some 'noise' into my practise session. Since I persist the Twitter stream after it's read I haven't posted the indicator to the forum as of yet. One of these days I'll polish the code and release it. In the meantime feel free to contact me if you have any questions about it.

                          Comment


                            #14
                            Originally posted by loadednrg View Post
                            Hi Guys,

                            I place my trades in Ninja, and then type them in twitter.

                            It would be great if Ninja automatically tweeted entry, profit and stop.


                            As an educator I'm sure a few of us would find this useful.
                            (I noticed its been done for MT4 https://www.myfxbook.com/ , )

                            Twitter APIs are simple and you could add it in, in no time.
                            It tried to do the same but they release a new version 2 BETA and it does not work anymore.

                            The owner of this domain has not yet uploaded their website.

                            Comment


                              #15
                              Originally posted by i001962 View Post
                              If you use this really pretty simple to accomplish.
                              http://code.google.com/p/twitterizer/ will help.
                              1) Download zip to your NT computer.
                              2) Add the downloaded framework to your custom indicator/strategy (hint from edit scrip uset right mouse button and 'preferences' 'add' this new dll
                              3) Start coding...

                              e.g.
                              #region Using declarations
                              ...
                              using NinjaTrader.Data;
                              using NinjaTrader.Gui.Chart;
                              using Twitterizer.Framework;
                              #endregion
                              ....
                              #region Variables
                              ....
                              Twitter t = new Twitter("YourUserName", "YourPassword");
                              #endregion

                              //logic that tells you went to enter/exit goes here
                              TwitterStatus newStatus = t.Status.Update("NinjaTrader to Twitter Trade 1 test - wow that was easy! *smiles");
                              //Of course you'll want to put your trade details into the msg but that's simple enough

                              That's it!

                              Trade well.

                              Kevin
                              It tried to reproduce the steps but the version is changes and I do not get it working? Please can anybody help

                              The owner of this domain has not yet uploaded their website.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Spiderbird, Today, 12:15 PM
                              2 responses
                              10 views
                              0 likes
                              Last Post Spiderbird  
                              Started by WHICKED, Today, 12:45 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post WHICKED
                              by WHICKED
                               
                              Started by FrazMann, Today, 11:21 AM
                              2 responses
                              6 views
                              0 likes
                              Last Post NinjaTrader_ChristopherJ  
                              Started by rjbtrade1, 11-30-2023, 04:38 PM
                              2 responses
                              80 views
                              0 likes
                              Last Post DavidHP
                              by DavidHP
                               
                              Started by lorem, Yesterday, 09:18 AM
                              5 responses
                              18 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Working...
                              X