Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Sending message by GET http method

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

    Sending message by GET http method

    Hi.

    I would like to send messages from a strategy to a Telegram Bot and I don´t know what function in Ninjascript must I use in order to make a http GET method (with an URL).

    Example:
    https://api.telegram.org/bot<token>/sendMessage?chat_id=@channelusername&text=This+is+ a+test.

    Could you tell me which C# function must I use in Ninjascript?

    Thank you.
    Regards.

    #2
    Hello ccruells,

    This would be outside of what is supported by NinjaTrader.

    However, I would recommend you look into the WebClient class of C#.
    Provides common methods for sending data to and receiving data from a resource identified by a URI.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Send Telegram message from Ninjatrader Share services

      Were you able to achieve sending of telegram messages from ninjatrader?

      Comment


        #4
        Originally posted by ccruells View Post
        Hi.

        I would like to send messages from a strategy to a Telegram Bot and I don´t know what function in Ninjascript must I use in order to make a http GET method (with an URL).

        Example:
        https://api.telegram.org/bot<token>/sendMessage?chat_id=@channelusername&text=This+is+ a+test.

        Could you tell me which C# function must I use in Ninjascript?

        Thank you.
        Regards.
        Were you able to achieve sending of telegram messages from ninjatrader? If yes, please can you help or post what you achieved.

        Comment


          #5
          Originally posted by paragsatpute View Post
          Were you able to achieve sending of telegram messages from ninjatrader? If yes, please can you help or post what you achieved.
          Please read reply #2 from NT_ChelseaB

          Comment


            #6
            In terms of performance the HttpWebRequest class is a bit faster and adds a bit more functionality than WebClient

            Code:
            string result = string.Empty;
            string url = @"https://api.telegram.org/bot<token>/sendMessage?chat_id=@channelusername&text=This+is+ a+test.";
            
            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();
            }

            Comment


              #7
              Hi,
              It works.
              Thanks !!!
              Last edited by benjaminrc78; 01-17-2018, 01:49 PM.

              Comment


                #8
                Originally posted by benjaminrc78 View Post
                Hi,
                It works.
                Thanks !!!
                hey i know this is old but can you show me a example on how you got this to work

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by CortexZenUSA, Today, 12:53 AM
                0 responses
                1 view
                0 likes
                Last Post CortexZenUSA  
                Started by CortexZenUSA, Today, 12:46 AM
                0 responses
                1 view
                0 likes
                Last Post CortexZenUSA  
                Started by usazencortex, Today, 12:43 AM
                0 responses
                5 views
                0 likes
                Last Post usazencortex  
                Started by sidlercom80, 10-28-2023, 08:49 AM
                168 responses
                2,265 views
                0 likes
                Last Post sidlercom80  
                Started by Barry Milan, Yesterday, 10:35 PM
                3 responses
                11 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Working...
                X