NexusFi: Find Your Edge


Home Menu

 





Posting to Twitter


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one josh with 6 posts (1 thanks)
    2. looks_two bukkan with 5 posts (3 thanks)
    3. looks_3 shodson with 4 posts (13 thanks)
    4. looks_4 Flexer with 3 posts (0 thanks)
      Best Posters
    1. looks_one shodson with 3.3 thanks per post
    2. looks_two Beljevina with 2 thanks per post
    3. looks_3 gregid with 1.5 thanks per post
    4. looks_4 bukkan with 0.6 thanks per post
    1. trending_up 11,427 views
    2. thumb_up 24 thanks given
    3. group 13 followers
    1. forum 29 posts
    2. attach_file 1 attachments




 
Search this Thread

Posting to Twitter

  #21 (permalink)
Flexer
Philippines
 
Posts: 7 since Sep 2014
Thanks Given: 1
Thanks Received: 0

why is it that the my code cannot go down to the PostToTwitter? I put it under the OnBarUpdate, did I put it correcty? or I made a mistake.. I copy all the staf that posted on the postTwitter code. I used the code that not use curl.exe..

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
MC PL editor upgrade
MultiCharts
Exit Strategy
NinjaTrader
Trade idea based off three indicators.
Traders Hideout
Increase in trading performance by 75%
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
27 thanks
Tao te Trade: way of the WLD
23 thanks
Diary of a simple price action trader
22 thanks
My NQ Trading Journal
14 thanks
HumbleTraders next chapter
9 thanks
  #22 (permalink)
 
gregid's Avatar
 gregid 
Wrocław, Poland
 
Experience: Intermediate
Platform: NinjaTrader, Racket
Trading: Ockham's razor
Posts: 650 since Aug 2009
Thanks Given: 320
Thanks Received: 623


Flexer View Post
why is it that the my code cannot go down to the PostToTwitter? I put it under the OnBarUpdate, did I put it correcty? or I made a mistake.. I copy all the staf that posted on the postTwitter code. I used the code that not use curl.exe..

The method used by shodson was made redundant by Twitter some time ago - if you know how to program you may need want to look at some generic c# examples/discussion, like the one here:

c# - Twitter POST problems using api 1.1 - Stack Overflow

Twitter API added to Ninja... please? - Page 2 - [AUTOLINK]NinjaTrader[/AUTOLINK] Support Forum

Otherwise you need to hope someone will post new working example here.

Reply With Quote
Thanked by:
  #23 (permalink)
 
Beljevina's Avatar
 Beljevina 
Toronto, Canada
 
Experience: Advanced
Platform: NinjaTrader, SierraCharts
Broker: Amp/CQG, IB
Trading: CL, GC, 6E, ES, RTY, EURUSD, GBPJPY, AUDUSD
Posts: 352 since Sep 2010


I have been using simple SendMail commands from within my Ninjascript, to email to a TwitterMail address, with NinjaTrader configured via gmail's SMTP server (smtp.gmail.com, port 587, SSL), for well over a year now. The "tweet" is uniformly "received" within a second, and, other than what was a twittermail problem some months ago (was down for a few days), the solution works flawlessly and around the clock.

Follow me on Twitter Reply With Quote
  #24 (permalink)
Flexer
Philippines
 
Posts: 7 since Sep 2014
Thanks Given: 1
Thanks Received: 0

thank you....

I also have another problem.

I use this as my code:
Twitter t = new Twitter(Username, Password);
t.Status.Update("status = " + msg +"Instrument = " +Instrument.FullName
+"Direction = " +SignalType +"Close Price = " +Close[0] +"Date/Time = " +SignalTime);

but wen I compile this code it says that Object refferences not set of an object what does it mean?

im glad if some can answer me...

Reply With Quote
  #25 (permalink)
Flexer
Philippines
 
Posts: 7 since Sep 2014
Thanks Given: 1
Thanks Received: 0

hello everyone.. need help, I'd tried to post a tweet in the twitter in the using ninjatrader Indicator, this code was working in the ASP.NET but not in the ninja,,, I got this error when I compile it.

The name 'Response' does not exist in the current context
The name 'Request' does not exist in the current context

any can help pls??
try
{

var oauth_consumer_key = "consumerKey";
var oauth_consumer_secret = "ConsumerSecret";


if (Request["oauth_token"] == null)
{
OAuthTokenResponse reqToken = OAuthUtility.GetRequestToken(
oauth_consumer_key,
oauth_consumer_secret,
Request.Url.AbsoluteUri);

Response.Redirect(string.Format("this is a link to find if the result is success or not",
reqToken.Token));

}
else
{
string requestToken = Request["oauth_token"].ToString();
string pin = Request["oauth_verifier"].ToString();

var tokens = OAuthUtility.GetAccessToken(
oauth_consumer_key,
oauth_consumer_secret,
requestToken,
pin);

OAuthTokens accesstoken = new OAuthTokens()
{
AccessToken = tokens.Token,
AccessTokenSecret = tokens.TokenSecret,
ConsumerKey = oauth_consumer_key,
ConsumerSecret = oauth_consumer_secret
};

TwitterResponse<TwitterStatus> response = TwitterStatus.Update(
accesstoken,
"status = " + msg +"Instrument = " +Instrument.FullName
+"Direction = " +SignalType +"Close Price = " +Close[0] +"Date/Time = " +SignalTime);

if (response.Result == RequestResult.Success)
{
Response.Write("we did it!");
}
else
{
Response.Write("its all bad.");
}
}
}
catch( Exception ex )
{
Console.WriteLine(ex);
Print("----------end-------------");
}

Reply With Quote
  #26 (permalink)
 
Pristine's Avatar
 Pristine 
barcelona
 
Experience: Advanced
Platform: ninjatrader
Trading: futures
Posts: 6 since Nov 2013
Thanks Given: 1
Thanks Received: 1


Beljevina View Post
I have been using simple SendMail commands from within my Ninjascript, to email to a TwitterMail address, with NinjaTrader configured via gmail's SMTP server (smtp.gmail.com, port 587, SSL), for well over a year now. The "tweet" is uniformly "received" within a second, and, other than what was a twittermail problem some months ago (was down for a few days), the solution works flawlessly and around the clock.

What scrip are using to resend by mail?

Thanks!

Follow me on Twitter Reply With Quote
  #27 (permalink)
 
Beljevina's Avatar
 Beljevina 
Toronto, Canada
 
Experience: Advanced
Platform: NinjaTrader, SierraCharts
Broker: Amp/CQG, IB
Trading: CL, GC, 6E, ES, RTY, EURUSD, GBPJPY, AUDUSD
Posts: 352 since Sep 2010


Pristine View Post
What scrip are using to resend by mail?

Thanks!

When a possible trigger/alert point has been hit, my code would issue something like the following code, to "tweet" out to me:

 
Code
SendMail ("<FullFormSourceFromEmailAddress>","<YourEmailonTwittermail>@twittermail.com", Instrument.MasterInstrument.Name + " Trigger signal printed on " + BarsPeriod.Value.ToString()   +  BarsPeriod.Id.ToString().Substring(0,3) + " chart @ " + Time[0].ToString() ,"Possible Buy. Close Price was " + Close[0].ToString() + ". Bar low was " + Low[0].ToString() + "."  );

Follow me on Twitter Reply With Quote
  #28 (permalink)
 TradingTechnics 
Brampton, ON
 
Experience: Intermediate
Platform: NinjaTrader
Broker: Amp Futures/Zen-Fire
Trading: futures, forex
Posts: 4 since Jan 2010
Thanks Given: 0
Thanks Received: 0

Hello Trader,

I have used your code to perform the same function but running into an error, can you share your full code or help in fixing the error, here is my code:


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Design;
using System.Drawing.Drawing2D;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using System.Xml.Serialization;
using Microsoft.Win32;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Gui.Design;
using NinjaTrader.Indicator;
using RestSharp;

namespace NinjaTrader.PostToTwitter
{
[Description("")]
public class PostToTwitter : Strategy
{
[Browsable(false)]
private void PostToTwitter(string msg, string user, string password)
{
try
{
string cmd = "D:\\Curl\\Surge\\9\\bin\\curl.exe";
string args = "-u " + "twitter-username" + ":" + "twitter-pwd" -d status=\"" + msg + "\" http://twitter.com/statuses/update.xml";
System.Diagnostics.Process.Start(cmd, args);
}
catch (Exception ex)
{
Print(ex.Message);
}
}
}
}






shodson View Post
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.


Reply With Quote
  #29 (permalink)
 
shodson's Avatar
 shodson 
OC, California, USA
Quantoholic
 
Experience: Advanced
Platform: IB/TWS, NinjaTrader, ToS
Broker: IB, ToS, Kinetick
Trading: stocks, options, futures, VIX
Posts: 1,976 since Jun 2009
Thanks Given: 533
Thanks Received: 3,709

I don't know, you don't even explain what the error message is that you are getting. I wrote this code 8 years ago. I don't post trade updates to Twitter anymore. Maybe Twitter changed their API so that might explain why this doesn't work anymore.


TradingTechnics View Post
Hello Trader,

I have used your code to perform the same function but running into an error, can you share your full code or help in fixing the error, here is my code:


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Design;
using System.Drawing.Drawing2D;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using System.Xml.Serialization;
using Microsoft.Win32;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Gui.Design;
using NinjaTrader.Indicator;
using RestSharp;

namespace NinjaTrader.PostToTwitter
{
[Description("")]
public class PostToTwitter : Strategy
{
[Browsable(false)]
private void PostToTwitter(string msg, string user, string password)
{
try
{
string cmd = "D:\\Curl\\Surge\\9\\bin\\curl.exe";
string args = "-u " + "twitter-username" + ":" + "twitter-pwd" -d status=\"" + msg + "\" http://twitter.com/statuses/update.xml";
System.Diagnostics.Process.Start(cmd, args);
}
catch (Exception ex)
{
Print(ex.Message);
}
}
}
}


Follow me on Twitter Visit my NexusFi Trade Journal Started this thread Reply With Quote
  #30 (permalink)
 TradingTechnics 
Brampton, ON
 
Experience: Intermediate
Platform: NinjaTrader
Broker: Amp Futures/Zen-Fire
Trading: futures, forex
Posts: 4 since Jan 2010
Thanks Given: 0
Thanks Received: 0


Its erroring at the following code Line:

string args = "-u " + "twitter-username" + ":" + "twitter-pwd" -d status=\"" + msg + "\" http://twitter.com/statuses/update.xml";

Error : ; expected at line 32 column 83
Error : Unexpected Character "\" at line 32 column 90

I tried it several way but the error is not getting resolved, maybe you can help

Also getting error @ Line 24, column 31
Error: NinjaTrader.Strategy is a 'namespace' but is used like 'type'

The is the code line : public class PostToTwitter : Strategy

If you copy the complete code and compile, you will see the errors, just replace twitter username/pwd with yours.



shodson View Post
I don't know, you don't even explain what the error message is that you are getting. I wrote this code 8 years ago. I don't post trade updates to Twitter anymore. Maybe Twitter changed their API so that might explain why this doesn't work anymore.


Reply With Quote




Last Updated on March 28, 2017


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts