NexusFi: Find Your Edge


Home Menu

 





Ninjatrader Telegram Addon


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one sam028 with 5 posts (6 thanks)
    2. looks_two Belltalks with 4 posts (3 thanks)
    3. looks_3 bobwest with 3 posts (1 thanks)
    4. looks_4 cutzpr with 2 posts (0 thanks)
      Best Posters
    1. looks_one vspatrick with 3 thanks per post
    2. looks_two sam028 with 1.2 thanks per post
    3. looks_3 Belltalks with 0.8 thanks per post
    4. looks_4 nothingbutprofits with 0.5 thanks per post
    1. trending_up 11,319 views
    2. thumb_up 14 thanks given
    3. group 21 followers
    1. forum 23 posts
    2. attach_file 2 attachments




 
Search this Thread

Ninjatrader Telegram Addon

  #1 (permalink)
 
cutzpr's Avatar
 cutzpr 
United States
 
Experience: None
Platform: TWS,Ninja Trader
Trading: Forex, Futures, Stocks
Posts: 35 since Apr 2012
Thanks Given: 10
Thanks Received: 10

Any experienced programmers willing to build a Telegram messaging Addon Share Service for Ninja trader? Telegram is one of the only full blown messaging apps that have an API. There's a ton of different API solutions people have already built to use with C#, unfortunately I am not talented enough to do it myself.

https://telegram.org/
https://core.telegram.org/api
https://github.com/sochix/TLSharp
https://github.com/TelegramBots/Telegram.Bot
https://github.com/everbytes/SharpTelegram/blob/master/README.md

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
REcommedations for programming help
Sierra Chart
Exit Strategy
NinjaTrader
MC PL editor upgrade
MultiCharts
Better Renko Gaps
The Elite Circle
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
45 thanks
Just another trading journal: PA, Wyckoff & Trends
31 thanks
Bigger Wins or Fewer Losses?
24 thanks
Tao te Trade: way of the WLD
24 thanks
GFIs1 1 DAX trade per day journal
22 thanks
  #2 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,765 since Jun 2009
Thanks Given: 3,825
Thanks Received: 4,629


cutzpr View Post
Any experienced programmers willing to build a Telegram messaging Addon Share Service for Ninja trader? Telegram is one of the only full blown messaging apps that have an API. There's a ton of different API solutions people have already built to use with C#, unfortunately I am not talented enough to do it myself.

https://telegram.org/
https://core.telegram.org/api
https://github.com/sochix/TLSharp
https://github.com/TelegramBots/Telegram.Bot
https://github.com/everbytes/SharpTelegram/blob/master/README.md

I'll try something during the next weeks.
If I forgot send me a reminder .

Success requires no deodorant! (Sun Tzu)
Follow me on Twitter Reply With Quote
Thanked by:
  #3 (permalink)
supreme23
Vancouver
 
Posts: 29 since Apr 2018
Thanks Given: 19
Thanks Received: 9



sam028 View Post
I'll try something during the next weeks.

If I forgot send me a reminder .



Reminder ! Let’s work together guys and figure it out


Sent using the NexusFi mobile app

Reply With Quote
  #4 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,765 since Jun 2009
Thanks Given: 3,825
Thanks Received: 4,629


supreme23 View Post
Reminder ! Let’s work together guys and figure it out


Sent using the NexusFi mobile app

It's more painful than expected, and when you have things like this:
'Flood prevention. Telegram now requires your program to do requests again only after 62734 seconds have passed (TimeToWait property). If you think the culprit of this problem may lie in TLSharp's implementation, open a Github issue please.'
it's not helping.
Wait & see...

Success requires no deodorant! (Sun Tzu)
Follow me on Twitter Reply With Quote
Thanked by:
  #5 (permalink)
 
cutzpr's Avatar
 cutzpr 
United States
 
Experience: None
Platform: TWS,Ninja Trader
Trading: Forex, Futures, Stocks
Posts: 35 since Apr 2012
Thanks Given: 10
Thanks Received: 10


sam028 View Post
It's more painful than expected, and when you have things like this:
'Flood prevention. Telegram now requires your program to do requests again only after 62734 seconds have passed (TimeToWait property). If you think the culprit of this problem may lie in TLSharp's implementation, open a Github issue please.'
it's not helping.
Wait & see...

Any luck? I appreciate you taking on this endeavor.

Started this thread Reply With Quote
  #6 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,765 since Jun 2009
Thanks Given: 3,825
Thanks Received: 4,629


cutzpr View Post
Any luck? I appreciate you taking on this endeavor.

I gave up, too many bugs in the C# libraries.
I tried with some Python libraries and it was much better but it will require to integrate this in C# code which I haven't done. One day maybe...

Success requires no deodorant! (Sun Tzu)
Follow me on Twitter Reply With Quote
  #7 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,765 since Jun 2009
Thanks Given: 3,825
Thanks Received: 4,629

At the end the solution I used was:
- one .exe program, which can be use in command line, which send a Telegram message
- a strategY/indicator which calls this .exe when needed

The .exe code:
 
Code
                            
namespace TelegramSam

{
    class 
Program {        
        static 
int Main(string[] args) {

            if (
args.Length != 3) {
                
Console.WriteLine("Please enter your API token, your chatID and the message.");
                
Console.WriteLine("Usage: TeleLennard <bottoken <chatID> <test to send>");
                return 
1;
            }
            
ServicePointManager.Expect100Continue true;
            
ServicePointManager.SecurityProtocol SecurityProtocolType.Tls12;
            
string apiToken args[0];
            
string chatId args[1];
            
string message args[2];

            var 
toto "https://api.telegram.org/"+apiToken+"/sendMessage?chat_id="+chatId+"&text=" message;
            
WebRequest request WebRequest.Create(toto);
            
            
Stream rs request.GetResponse().GetResponseStream();
            
StreamReader reader = new StreamReader(rs);
            
string line "";
            
StringBuilder sb = new StringBuilder();
            while (
line != null) {
                
line reader.ReadLine();
                if (
line != null)
                    
sb.Append(line);
            }
            
string response sb.ToString();

            
Console.WriteLine(message);
            return 
0;
        }
    }

The NinjaScript:
 
Code
                            
public class TeleTest Strategy

    
{        
        
string apiToken "botXXX";
                
string chatId "0123456798";
        
string a "Is Sam";
        
string b "a genius";
        
string c "or what?";
        
string msg;
        
string exeToRun = @"C:\Users\sam\Source\repos\Tele\bin\Release\Tele.exe"
        
        private 
void sendToTelegram(object msg){        
            
ProcessStartInfo startInfo = new ProcessStartInfo();        
            
startInfo.FileName exeToRun;
            
startInfo.Arguments apiToken+" "+chatId+" "+msg;
            
startInfo.WindowStyle ProcessWindowStyle.Hidden;
            
Process.Start(startInfo);
        }
        
        protected 
override void Initialize()
        {
            
CalculateOnBarClose true;            
            
Thread thread = new Thread(sendToTelegram);
            
msg "\""+a+" "+b+" "+c+"\"";
            
thread.Start(msg);            
        }
    } 

Success requires no deodorant! (Sun Tzu)
Follow me on Twitter Reply With Quote
Thanked by:
  #8 (permalink)
 
bobwest's Avatar
 bobwest 
Western Florida
Site Moderator
 
Experience: Advanced
Platform: Sierra Chart
Trading: ES, YM
Frequency: Several times daily
Duration: Minutes
Posts: 8,168 since Jan 2013
Thanks Given: 57,464
Thanks Received: 26,278


cls71 View Post
This article (in spanish) explains step by step how to send messages (text & images ) to Telegram from NinjaTrader 8.

Hi @cls71

I have had to delete your message, because it contains a link to your company web site, where you offer paid services and courses in addition to the information about Telegram.

Forum rules to not allow a vendor to post links to their web site or otherwise do anything that could promote their products or services.

You may not have intended to violate the rules, but this requirement must be enforced to ensure a commercial-free environment in the forum.

Bob.

When one door closes, another opens.
-- Cervantes, Don Quixote
Reply With Quote
  #9 (permalink)
 darkmarine 
NEW BRUNSWICK
 
Experience: Intermediate
Platform: ninjatrader
Trading: nq
Posts: 11 since Jun 2020
Thanks Given: 2
Thanks Received: 0


sam028 View Post
At the end the solution I used was:
- one .exe program, which can be use in command line, which send a Telegram message
- a strategY/indicator which calls this .exe when needed

The .exe code:
 
Code
                            
namespace TelegramSam

{
    class 
Program {        
        static 
int Main(string[] args) {

            if (
args.Length != 3) {
                
Console.WriteLine("Please enter your API token, your chatID and the message.");
                
Console.WriteLine("Usage: TeleLennard <bottoken <chatID> <test to send>");
                return 
1;
            }
            
ServicePointManager.Expect100Continue true;
            
ServicePointManager.SecurityProtocol SecurityProtocolType.Tls12;
            
string apiToken args[0];
            
string chatId args[1];
            
string message args[2];

            var 
toto "https://api.telegram.org/"+apiToken+"/sendMessage?chat_id="+chatId+"&text=" message;
            
WebRequest request WebRequest.Create(toto);
            
            
Stream rs request.GetResponse().GetResponseStream();
            
StreamReader reader = new StreamReader(rs);
            
string line "";
            
StringBuilder sb = new StringBuilder();
            while (
line != null) {
                
line reader.ReadLine();
                if (
line != null)
                    
sb.Append(line);
            }
            
string response sb.ToString();

            
Console.WriteLine(message);
            return 
0;
        }
    }

The NinjaScript:
 
Code
                            
public class TeleTest Strategy

    
{        
        
string apiToken "botXXX";
                
string chatId "0123456798";
        
string a "Is Sam";
        
string b "a genius";
        
string c "or what?";
        
string msg;
        
string exeToRun = @"C:\Users\sam\Source\repos\Tele\bin\Release\Tele.exe"
        
        private 
void sendToTelegram(object msg){        
            
ProcessStartInfo startInfo = new ProcessStartInfo();        
            
startInfo.FileName exeToRun;
            
startInfo.Arguments apiToken+" "+chatId+" "+msg;
            
startInfo.WindowStyle ProcessWindowStyle.Hidden;
            
Process.Start(startInfo);
        }
        
        protected 
override void Initialize()
        {
            
CalculateOnBarClose true;            
            
Thread thread = new Thread(sendToTelegram);
            
msg "\""+a+" "+b+" "+c+"\"";
            
thread.Start(msg);            
        }
    } 



Hello



Could you check the below code to see if you could find out why is not working


//Set-up for telegram BOT
private DateTime dateTime;
private string botUrl = "https://api.telegram.org/bot{0}/sendMessage?chat_id={1}&text={2}";
private string apiKey = "4902146:AAHrSh0GVj_2TDeGiXiSDTr0DVKsF02y9J A";
private string chatId = "-1001278608";
private string messageText = "";
private string instrumentName = "";
private string contractMonth = "";
private string signalSeries = "";
private string CurrentDate = "";
private string dataSeriesDate = "";
private string indicatorName = "HeikenAshi CandleSticks Entry \n";




/For Telegram Bot
if (CurrentDate == dataSeriesDate && TelegramAlert == true)
{
signalSeries = indicatorName + instrumentName + " " + contractMonth + " " + vCall.ToString() + " CE";
messageText = signalSeries;
botUrl = "https://api.telegram.org/bot{0}/sendMessage?chat_id={1}&text={2}";
botUrl = String.Format(botUrl, apiKey, chatId, messageText);
WebRequest request = WebRequest.Create(botUrl);
request.GetResponse();

Reply With Quote
  #10 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,765 since Jun 2009
Thanks Given: 3,825
Thanks Received: 4,629


Hard to say without more details about the error message.

Success requires no deodorant! (Sun Tzu)
Follow me on Twitter Reply With Quote




Last Updated on February 19, 2023


© 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