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 bortz, 11-06-2023, 08:04 AM
                47 responses
                1,609 views
                0 likes
                Last Post aligator  
                Started by jaybedreamin, Today, 05:56 PM
                0 responses
                9 views
                0 likes
                Last Post jaybedreamin  
                Started by DJ888, 04-16-2024, 06:09 PM
                6 responses
                19 views
                0 likes
                Last Post DJ888
                by DJ888
                 
                Started by Jon17, Today, 04:33 PM
                0 responses
                6 views
                0 likes
                Last Post Jon17
                by Jon17
                 
                Started by Javierw.ok, Today, 04:12 PM
                0 responses
                16 views
                0 likes
                Last Post Javierw.ok  
                Working...
                X