Posting to Twitter - NinjaTrader Programming | futures io social day trading
futures io futures trading


Posting to Twitter
Updated: Views / Replies:5,615 / 29
Created: by shodson Attachments:1

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 1  
 
Thread Tools Search this Thread
 

Posting to Twitter

  #1 (permalink)
 Vendor: www.probabletrades.com 
OC, California, USA
 
Futures Experience: Advanced
Platform: IB/TWS, NinjaTrader, thinkorswim
Favorite Futures: stocks, options, futures, VIX
 
shodson's Avatar
 
Posts: 1,860 since Jun 2009
Thanks: 480 given, 3,255 received

Posting to Twitter

I just coded my automated strategy to post trades, entries, exits, and daily P/L summaries to a Twitter account. I tried using some of the 3rd-part .NET Twitter APIs but I couldn't get one to work (Twitteroo) so I just used the command-line API. You need to have a working copy of curl.exe on your machine and set it's path in the "cmd" string. I've attached a ZIP with the curl.exe I'm using on Vista Ultimate. The "user" and "password" parameters are your Twitter username and password you want to post to.

 
Code
        private void PostToTwitter(string msg, string user, string password)
        {
            try
            {
                string cmd = "C:\\Windows\\System32\\curl.exe";
                string args = "-u " + user + ":" + password -d status=\"" 
                    + msg + "\" http://twitter.com/statuses/update.xml";    
                
                System.Diagnostics.Process.Start(cmd, args);
            }
            catch (Exception ex)
            {
                Print(ex.Message);
            }
        }
You can follow my strategy's Twitter account at @uberBOT1.

Attached Files
Register to download File Type: zip curl.zip (190.5 KB, 30 views)
Reply With Quote
The following 7 users say Thank You to shodson for this post:
 
  #2 (permalink)
 Vendor: www.probabletrades.com 
OC, California, USA
 
Futures Experience: Advanced
Platform: IB/TWS, NinjaTrader, thinkorswim
Favorite Futures: stocks, options, futures, VIX
 
shodson's Avatar
 
Posts: 1,860 since Jun 2009
Thanks: 480 given, 3,255 received

Actually, this one is probably better, it doesn't require the curl library, just uses the built-in .NET libraries. Props to this page for helping me fine-tune it.
 
Code
private void PostToTwitter(string msg, string username, string password)
{
    System.IO.Stream os = null;
    try
    {
         string user = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(username + ":" + password));
         string url = "http://twitter.com/statuses/update.xml";
         System.Net.HttpWebRequest req = (System.Net.HttpWebRequest) System.Net.WebRequest.Create(url);
         req.Headers.Add("Authorization", "Basic " + user);
         req.ContentType = "application/x-www-form-urlencoded";
         req.Method = "POST";
         req.ServicePoint.Expect100Continue = false;

         byte[] bytes = System.Text.Encoding.ASCII.GetBytes("status=" + msg);

         req.ContentLength = bytes.Length;
         os = req.GetRequestStream();
         os.Write(bytes, 0, bytes.Length);

         System.Net.WebResponse resp = req.GetResponse();
         if (resp == null) return;

         System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream());
         string response = sr.ReadToEnd().Trim();
    }
    catch (Exception ex)
    {
        Print("Error in PostToTwitter: " + ex.Message);
    }
    if (os != null) os.Close();
}

Reply With Quote
The following 5 users say Thank You to shodson for this post:
 
  #3 (permalink)
Elite Member
Wrocław, Poland
 
Futures Experience: Intermediate
Platform: NinjaTrader, Racket
Favorite Futures: Ockham's razor
 
gregid's Avatar
 
Posts: 651 since Aug 2009
Thanks: 321 given, 605 received


Thanks shodson for posting this.

Also, may I ask you a question of what is the advantage of using API over using service like TwitterMail?

Doesn't TwitterMail allow you to post updates by sending email to your Twitter account?

Reply With Quote
 
  #4 (permalink)
 Vendor: www.probabletrades.com 
OC, California, USA
 
Futures Experience: Advanced
Platform: IB/TWS, NinjaTrader, thinkorswim
Favorite Futures: stocks, options, futures, VIX
 
shodson's Avatar
 
Posts: 1,860 since Jun 2009
Thanks: 480 given, 3,255 received

Not sure, I've never used TwitterMail

Reply With Quote
 
  #5 (permalink)
Administrator: Retired Backtester
 Vendor: speedytradingservers.com 
Rennes France
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: IB/Kinetick
Favorite Futures: Futures
 
sam028's Avatar
 
Posts: 3,366 since Jun 2009
Thanks: 3,574 given, 3,983 received


gregid View Post
Thanks shodson for posting this.

Also, may I ask you a question of what is the advantage of using API over using service like TwitterMail?

Doesn't TwitterMail allow you to post updates by sending email to your Twitter account?

I'm not a Twitter user, but I think it's the easy way to do it, just a mailto() to your TwitterMail.

Reply With Quote
 
  #6 (permalink)
Elite Member
Working on my LCD tan
 
Futures Experience: Advanced
Platform: NinjaTrader
 
Posts: 127 since Jun 2009
Thanks: 25 given, 51 received


shodson View Post
Actually, this one is probably better, it doesn't require the curl library, just uses the built-in .NET libraries. Props to this page for helping me fine-tune it.
 
Code
private void PostToTwitter(string msg, string username, string password)
{
    System.IO.Stream os = null;
    try
    {
         string user = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(username + ":" + password));
         string url = "http://twitter.com/statuses/update.xml";
         System.Net.HttpWebRequest req = (System.Net.HttpWebRequest) System.Net.WebRequest.Create(url);
         req.Headers.Add("Authorization", "Basic " + user);
         req.ContentType = "application/x-www-form-urlencoded";
         req.Method = "POST";
         req.ServicePoint.Expect100Continue = false;

         byte[] bytes = System.Text.Encoding.ASCII.GetBytes("status=" + msg);

         req.ContentLength = bytes.Length;
         os = req.GetRequestStream();
         os.Write(bytes, 0, bytes.Length);

         System.Net.WebResponse resp = req.GetResponse();
         if (resp == null) return;

         System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream());
         string response = sr.ReadToEnd().Trim();
    }
    catch (Exception ex)
    {
        Print("Error in PostToTwitter: " + ex.Message);
    }
    if (os != null) os.Close();
}

Apologies for the grave dig but I'm curious how you implemented this code. I tried pasting the code into a strategy and calling it in "OnBarUpdate" and it locked up NT7. Never managed to break NT so easily and consistently lol.

Reply With Quote
 
  #7 (permalink)
Elite Member
Calcutta, India
 
Futures Experience: Intermediate
Platform: ArthaChitra
 
Posts: 278 since Jun 2009
Thanks: 161 given, 259 received

have a look at TwitterVB - A .NET Twitter Library

Reply With Quote
The following user says Thank You to bukkan for this post:
 
  #8 (permalink)
Elite Member
Georgia, US
 
Futures Experience: None
Platform: Various
Favorite Futures: Various
 
josh's Avatar
 
Posts: 4,897 since Jan 2011
Thanks: 5,143 given, 11,242 received

I've asked over at the NT forum but thought it wouldn't hurt to double post here.

Is it possible to use something like TwitterVB or another library to post twitter updates if I place a manual trade, as opposed to calling the code from an automated strategy? Like, if I place a stop order in the DOM, is there some mechanism to detect that and immediately post that an order is placed, and then when the order is filled, and then when the stop loss is moved, etc.?

Reply With Quote
The following user says Thank You to josh for this post:
 
  #9 (permalink)
Elite Member
Georgia, US
 
Futures Experience: None
Platform: Various
Favorite Futures: Various
 
josh's Avatar
 
Posts: 4,897 since Jan 2011
Thanks: 5,143 given, 11,242 received

I tried using a strategy and it seems that a strategy will not detect orders placed outside of the strategy.

After researching, one way I can see to implement this is to read from the log file, and read each line and then just determine the order information from that text file.

Reply With Quote
 
  #10 (permalink)
Elite Member
Georgia, US
 
Futures Experience: None
Platform: Various
Favorite Futures: Various
 
josh's Avatar
 
Posts: 4,897 since Jan 2011
Thanks: 5,143 given, 11,242 received


As an update to this, I am reading from the log file and doing what I needed to do, this is the only way to get info for manually placed trades according to NT. Parsing the info and using SendMail() via twittermail.

Reply With Quote

Reply



futures io > > > > > Posting to Twitter

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Twitter-based fund beats the market Big Mike News and Current Events 8 August 19th, 2011 08:13 AM
Shoot the short Big Mike Off-Topic 303 April 13th, 2011 11:11 AM
Posting video on BMT lolu Tech Support 8 June 10th, 2010 10:17 AM
posting charts jdella Traders Hideout 3 July 4th, 2009 09:42 AM
Twitter? shodson Off-Topic 2 July 1st, 2009 07:19 PM


All times are GMT -4. The time now is 03:47 PM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts
Page generated 2017-12-17 in 0.13 seconds with 20 queries on phoenix via your IP 107.20.115.174