Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Plans for Telegram Support?

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

    #16
    please add my vote
    +1

    Comment


      #17
      Hello danalec,

      I've added your vote to SFT-3265
      Heath R.NinjaTrader Customer Service

      Comment


        #18
        +1


        and some more text because your forum is forcing me to

        Comment


          #19
          Cyph3r , I've added your vote for SFT-3265

          For any future users who would like to add their vote to this feature request, please continue to comment and your vote will be added to our internal tracking. However, we will no longer be confirming votes with a post.

          Comment


            #20
            +1
            Please count my vote too

            Comment


              #21
              telegram is not popular with many people.

              Comment


                #22
                Hello,

                At OsloTrading we have developed a Script to send information about your trades to any Telegram´s channel or group.

                You can request more information by email: [email protected]

                Best regards.

                Comment


                  #23
                  Adding Telegram support is a bad idea.

                  It would dilute the support effort of the Ninja Trader Staff without adding anything significant and it would dilute the effectiveness of this forum as answers/help would then be spread out in different locations.

                  This forum has great features and a nicely searchable database of answers.

                  Further, do Telegram posts last forever or do they disappear after some time?
                  If they disappear then the support staff would likely be answering the same questions over and over...

                  Would the Telegram posts be easily searchable like this forum?
                  Telegram doesn't really have posts or threads right?
                  So it would be a mess.

                  What features do you think this forum is lacking that Telegram can do?

                  It sounds like the few here that want Telegram support are simply used to using Telegram and aren't considering the actual features...

                  Bad idea.

                  Comment


                    #24
                    iTrade777

                    Ya, you totally correct.
                    They did not think deep what ninjatrader 8 is.

                    In stead of asking extra feature, why don't they spend time on writing the program.
                    ** Always asking for unrelated feature and thus making the real feature will be delayed.

                    Comment


                      #25
                      They are making hard time to the customer service.

                      Comment


                        #26
                        Please add my vote to this request. Thanks a lot!
                        octaviogarcia
                        NinjaTrader Ecosystem Vendor - octaviogarciatrader

                        Comment


                          #27
                          There is an easy way to incorporate NT with Telegram without having to use imports. You can use the native Telegram API found here. Telegram APIs

                          First create your bots and channels and get your token and chat Ids. There is plenty of info on the web on how to do that.


                          Then you would use it as so.

                          add your using statements in declarations

                          Code:
                          using System.Net;
                          using System.Net.Http;
                          variables

                          Code:
                          private const string API_TOKEN  = "botXXXXX"; //Bot Token
                          private const string chat_id = "-XXXXXX"; // you need the hyphen
                          Then use this function

                          Code:
                          public void SendTelegramTextMessage(string Msg)
                          {
                          
                          // string result = "Empty"; // you can use if you want to verify it worked
                          
                          string url = @"https://api.telegram.org/API_TOKEN/sendMessage?chat_id=" + CHAT_ID +"&text="+Msg;
                          
                          HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                          request.AutomaticDecompression = DecompressionMethods.GZip;
                          
                          using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                          using (Stream stream = response.GetResponseStream())
                          using (StreamReader reader = new StreamReader(stream))
                          
                          // result = reader.ReadToEnd(); // you can use if you want to verify it worked
                          // return result
                          }
                          If you want to send an image. You can do it two ways. An image you have already or send a screenshot.

                          To send an image file with a caption

                          Code:
                          using System.Windows.Media.Imaging;
                          Code:
                          public async Task SendPhoto (string Caption)
                          {
                          
                          try
                          {
                          
                          string url = @"https://api.telegram.org/" + API_TOKEN + "/sendPhoto?chat_id=" + chatId;
                          string filePath = (FILEPath + "\\image.png");
                          
                          var fileName = filePath.Split('\\').Last();
                          
                          using (var form = new MultipartFormDataContent())
                          {
                          form.Add(new StringContent(chatId.ToString(), Encoding.UTF8), "chat_id");
                          form.Add(new StringContent(Caption.ToString(), Encoding.UTF8), "caption");
                          form.Add(new StringContent("true", Encoding.UTF8), "disable_notification"); // Turn on or off the notifcation
                          
                          
                          using (FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
                          {
                          form.Add(new StreamContent(fileStream), "photo", fileName);
                          
                          using (var client = new HttpClient())
                          {
                          await client.PostAsync(url, form);
                          }
                          }
                          }
                          }
                          catch (Exception ex)
                          {
                          Print(ex.ToString());
                          }
                          }
                          Now the override for a screenshot.


                          Code:
                          public async Task SendPhoto(string Caption, byte[] bytes)
                          {
                          
                          MemoryStream ms = new MemoryStream(bytes);
                          try
                          {
                          string url = @"https://api.telegram.org/" + API_TOKEN +"/sendPhoto?chat_id=" + chatId;
                          
                          using (var form = new MultipartFormDataContent())
                          {
                          form.Add(new StringContent(chatId.ToString(), Encoding.UTF8), "chat_id");
                          form.Add(new StringContent(Caption.ToString(), Encoding.UTF8), "caption");
                          form.Add(new StringContent("true", Encoding.UTF8), "disable_notification"); // I disable notifications but you can turn this on.
                          
                          form.Add(new StreamContent(ms), "photo", "image");
                          
                          using (var client = new HttpClient())
                          {
                          await client.PostAsync(url, form);
                          }
                          }
                          }
                          catch (Exception ex)
                          {
                          Print(ex.ToString());
                          }
                          }

                          Then I call it like so below. This example sends the current chart image screenshot using the override.

                          Code:
                          using System.Threading;
                          using System.Threading.Tasks;
                          
                          private static int threadLock = 0;
                          Code:
                          public void SendTelegramChartImage(string Caption)
                          {
                          
                          if(ChartControl == null) return; //Ensure a Strategy is Attached to a chart before continuing
                          
                          
                          if (0 == Interlocked.Exchange(ref threadLock, 1)) //0 indicates that the method is not in use.
                          {
                          try
                          {
                          ForceRefresh();
                          this.ChartControl.Dispatcher.InvokeAsync(() =>
                          {
                          
                          NinjaTrader.Gui.Chart.Chart chart = Window.GetWindow(this.ChartControl) as NinjaTrader.Gui.Chart.Chart;
                          RenderTargetBitmap screenCapture = chart.GetScreenshot(ShareScreenshotType.Chart);
                          
                          
                          if (screenCapture != null) // Just a boolean I use to control whether it does it or not. Remove it if you want.
                          {
                          try
                          {
                          BitmapFrame outputFrame = BitmapFrame.Create(screenCapture);
                          
                          
                          using (MemoryStream ms = new MemoryStream())
                          {
                          PngBitmapEncoder png = new PngBitmapEncoder();
                          png.Frames.Add(outputFrame);
                          png.Save(ms);
                          SendPhoto(Caption,ms.ToArray());
                          }
                          }
                          catch (IOException io)
                          {
                          NinjaTrader.Code.Output.Process(uniqueStrategy + ": Could not take Telegram Screenshot " + io, PrintTo.OutputTab1);
                          }
                          }
                          });
                          }
                          catch (Exception ex)
                          {
                          NinjaTrader.Code.Output.Process(uniqueStrategy + ": Could not save Telegram Screenshot " + ex, PrintTo.OutputTab1);
                          }
                          
                          Interlocked.Exchange(ref threadLock, 0); //Release the lock
                          }
                          
                          }

                          I hope this helps everyone.
                          Last edited by cutzpr; 08-12-2021, 10:17 AM.

                          Comment


                            #28
                            Hi guys, We have this script for Telegram connected to ninjatrader.

                            I think this will solve the problem for you. Greetings

                            Comment


                              #29
                              Originally posted by cutzpr View Post
                              There is an easy way to incorporate NT with Telegram without having to use imports. You can use the native Telegram API found here. Telegram APIs

                              First create your bots and channels and get your token and chat Ids. There is plenty of info on the web on how to do that.


                              Then you would use it as so.

                              add your using statements in declarations

                              Code:
                              using System.Net;
                              using System.Net.Http;
                              variables

                              Code:
                              private const string API_TOKEN = "botXXXXX"; //Bot Token
                              private const string chat_id = "-XXXXXX"; // you need the hyphen
                              Then use this function

                              Code:
                              public void SendTelegramTextMessage(string Msg)
                              {
                              
                              // string result = "Empty"; // you can use if you want to verify it worked
                              
                              string url = @"https://api.telegram.org/API_TOKEN/sendMessage?chat_id=" + CHAT_ID +"&text="+Msg;
                              
                              HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                              request.AutomaticDecompression = DecompressionMethods.GZip;
                              
                              using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                              using (Stream stream = response.GetResponseStream())
                              using (StreamReader reader = new StreamReader(stream))
                              
                              // result = reader.ReadToEnd(); // you can use if you want to verify it worked
                              // return result
                              }
                              If you want to send an image. You can do it two ways. An image you have already or send a screenshot.

                              To send an image file with a caption

                              Code:
                              using System.Windows.Media.Imaging;
                              Code:
                              public async Task SendPhoto (string Caption)
                              {
                              
                              try
                              {
                              
                              string url = @"https://api.telegram.org/" + API_TOKEN + "/sendPhoto?chat_id=" + chatId;
                              string filePath = (FILEPath + "\\image.png");
                              
                              var fileName = filePath.Split('\\').Last();
                              
                              using (var form = new MultipartFormDataContent())
                              {
                              form.Add(new StringContent(chatId.ToString(), Encoding.UTF8), "chat_id");
                              form.Add(new StringContent(Caption.ToString(), Encoding.UTF8), "caption");
                              form.Add(new StringContent("true", Encoding.UTF8), "disable_notification"); // Turn on or off the notifcation
                              
                              
                              using (FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
                              {
                              form.Add(new StreamContent(fileStream), "photo", fileName);
                              
                              using (var client = new HttpClient())
                              {
                              await client.PostAsync(url, form);
                              }
                              }
                              }
                              }
                              catch (Exception ex)
                              {
                              Print(ex.ToString());
                              }
                              }
                              Now the override for a screenshot.


                              Code:
                              public async Task SendPhoto(string Caption, byte[] bytes)
                              {
                              
                              MemoryStream ms = new MemoryStream(bytes);
                              try
                              {
                              string url = @"https://api.telegram.org/" + API_TOKEN +"/sendPhoto?chat_id=" + chatId;
                              
                              using (var form = new MultipartFormDataContent())
                              {
                              form.Add(new StringContent(chatId.ToString(), Encoding.UTF8), "chat_id");
                              form.Add(new StringContent(Caption.ToString(), Encoding.UTF8), "caption");
                              form.Add(new StringContent("true", Encoding.UTF8), "disable_notification"); // I disable notifications but you can turn this on.
                              
                              form.Add(new StreamContent(ms), "photo", "image");
                              
                              using (var client = new HttpClient())
                              {
                              await client.PostAsync(url, form);
                              }
                              }
                              }
                              catch (Exception ex)
                              {
                              Print(ex.ToString());
                              }
                              }

                              Then I call it like so below. This example sends the current chart image screenshot using the override.

                              Code:
                              using System.Threading;
                              using System.Threading.Tasks;
                              
                              private static int threadLock = 0;
                              Code:
                              public void SendTelegramChartImage(string Caption)
                              {
                              
                              if(ChartControl == null) return; //Ensure a Strategy is Attached to a chart before continuing
                              
                              
                              if (0 == Interlocked.Exchange(ref threadLock, 1)) //0 indicates that the method is not in use.
                              {
                              try
                              {
                              ForceRefresh();
                              this.ChartControl.Dispatcher.InvokeAsync(() =>
                              {
                              
                              NinjaTrader.Gui.Chart.Chart chart = Window.GetWindow(this.ChartControl) as NinjaTrader.Gui.Chart.Chart;
                              RenderTargetBitmap screenCapture = chart.GetScreenshot(ShareScreenshotType.Chart);
                              
                              
                              if (screenCapture != null) // Just a boolean I use to control whether it does it or not. Remove it if you want.
                              {
                              try
                              {
                              BitmapFrame outputFrame = BitmapFrame.Create(screenCapture);
                              
                              
                              using (MemoryStream ms = new MemoryStream())
                              {
                              PngBitmapEncoder png = new PngBitmapEncoder();
                              png.Frames.Add(outputFrame);
                              png.Save(ms);
                              SendPhoto(Caption,ms.ToArray());
                              }
                              }
                              catch (IOException io)
                              {
                              NinjaTrader.Code.Output.Process(uniqueStrategy + ": Could not take Telegram Screenshot " + io, PrintTo.OutputTab1);
                              }
                              }
                              });
                              }
                              catch (Exception ex)
                              {
                              NinjaTrader.Code.Output.Process(uniqueStrategy + ": Could not save Telegram Screenshot " + ex, PrintTo.OutputTab1);
                              }
                              
                              Interlocked.Exchange(ref threadLock, 0); //Release the lock
                              }
                              
                              }

                              I hope this helps everyone.
                              I've been trying all day to get this to work, but I can't manage to send a screenshot.
                              Text messages work, but no pics.

                              No errors or anything helpful.
                              Maybe that's because of the uniqueStrategy you're using? What does it contain?

                              Any ideas?

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by alifarahani, Today, 09:40 AM
                              6 responses
                              38 views
                              0 likes
                              Last Post alifarahani  
                              Started by Waxavi, Today, 02:10 AM
                              1 response
                              18 views
                              0 likes
                              Last Post NinjaTrader_LuisH  
                              Started by Kaledus, Today, 01:29 PM
                              5 responses
                              15 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by Waxavi, Today, 02:00 AM
                              1 response
                              12 views
                              0 likes
                              Last Post NinjaTrader_LuisH  
                              Started by gentlebenthebear, Today, 01:30 AM
                              3 responses
                              17 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Working...
                              X