fxDreema

    • Register
    • Login
    • Search
    • Back to the main page
    • Categories
    • Recent
    • Tags
    • Popular
    • Search

    [Custom Block Release] Send a message or screenshot to Telegram Blocks

    Tutorials by Users
    35
    55
    26383
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Spuzy
      Spuzy last edited by Spuzy

      Hello, I've made custom blocks to send a telegram message and or screenshot some time ago, but there had to be some modifications to the original files and such so I'll release a version that works with fxdreema and the code for the custom functions and blocks.

      https://www.mql5.com/en/articles/2355
      This are the includes we will be using, credits to for the code and possibility of using telegram api within metatrader go to ANDREY VOYTENKO from mql5 forums.

      go there and download telegram.zip at the bottom of the post.
      extract the include folder into your MQL4/5 folder and overwrite any files if asked to do so.
      0_1562983072106_cc4cdf9c-770d-4fb1-9f52-f7196828bcaf-image.png
      your numbers folder will be different depending on the broker you use, make sure you put it in the right folder or you can do it for every numbers folder so all your meta trader clients have the code necessary.

      the current jason.mqh has compatibility issues with fxdreema because fxdreema declares variables c and v on a global status which jason.mqh also uses hence errors. I have modified the jason.mqh to work with fxdreema and you can get the code here https://pastebin.com/525haAXi
      go at the bottom of the link and you will see a box with text inside, this is the raw text, click inside press ctrl+a to select all text inside and then copy that and paste it over jason.mqh which you can open with your metaeditor which is included with all metatraders(I think). and press compile to save it.
      (you must use this new edited file in every numbers folder otherwise you will get errors, I recommend first editing the file then placing it in every numbers folder if you have more than one)

      on fxdreema builder click on custom and then create custom blocks
      0_1562983398643_3b34b148-9c0d-4c5c-bc2d-ea6099840d0a-image.png

      in this editor you will need to create 2 blocks 0_1562983433154_9a8e4d7b-a11a-41f5-91aa-1a5f54079b52-image.png

      in the send screenshot block paste the code from this link https://pastebin.com/aegjAZyqand at the bottom under "Global variables,includes" paste this code
      #include <Telegram.mqh>

      so it looks like this 0_1562983589002_0e8f17ab-657c-4694-9165-96cc47920e66-image.png

      now you will need to make custom parameters that will be used within the block
      follow these screenshots exactly how I have made it https://imgur.com/a/2dtgq1S
      There are 2 notes. after you make all parameters open up is_channel parameters and click on the arrow next to the 2 options we made. under the "true" option choose channel_id and under the "false" option choose chat_id like shown in the screenshots.
      this is also true for current_chart parameter but choose _symbol and _period.
      if you follow it exactly like shown in the screenshots you will have no problems. so please make sure you follow it exactly.

      now in send message block put this code https://pastebin.com/ykGmW16r
      and again put #include <Telegram.mqh> under the global variables,includes box

      screenshots for parameters are here https://imgur.com/a/bKjHvRl

      now click on the New button in the bottom right corner under Custom Functions 0_1562983985066_30b0c577-4913-4d87-8141-1b31787f73ed-image.png
      delete the default code inside and paste this code and click save
      https://pastebin.com/y0zL8hSA

      if you want to make the block telegram blue color so they look nice click on settings and use #0088CC for color
      0_1562984072485_e1adab59-7bb9-4d4b-8f75-4e2842a47755-image.png
      0_1563242291691_f1e2adf1-a63b-4018-9bd9-c6bd48978c69-image.png

      now you will need to allow your metatrader client to access https://api.telegram.org
      go to tools-options 0_1562984144203_523c167f-143a-45ac-b4be-12190a7737ca-image.png

      go to Expert Advisors tab, enable "Allow WebRequests for listed URL:" option and paste the url above into the box
      0_1562984202058_b8248b40-ddd2-43de-b4d9-76e636a0169d-image.png

      Since we are using includes that are not hosted on fxdreema servers you must always download .mql4/5 file, not .ex file
      you must open it up in metaeditor and compile it yourself.

      Now to setup the actual bot and how to get Chat ID.
      On telegram search for BotFather and open up a chat with him
      0_1563109263266_c5e805d5-3654-4765-9ce1-acbc0259f584-image.png
      click start and type in /newbot and follow the instructions, once you are done you will get your bot's token
      0_1563109436752_61b484c2-0db6-4d39-8eca-773732097640-image.png
      copy and paste that token into the "token" part of the blocks.
      you can make a string variable with your token and use the variable in the blocks so you don't need to copy it always.
      Make sure to share the token with no one.

      if you want to send to a channel you need to make a public one and then copy it's adress into the channel name box
      0_1563110433900_162886c0-77be-4d03-8306-7ae7cbf35925-image.png

      if you want to send to a group make a new group and to it add IDBot and your bot
      0_1563110609913_6781b76f-a2d0-4783-9a64-54926fe7722a-image.png
      type /getgroupid to get your group's ID and then kick out IDBot and you can Pin his message so you have easy access to the ID if you'll need it again/often. Be sure to kick out IDBot.
      now take your ID and put it in the ID Box
      0_1563110798914_26be9a91-5944-464e-8d98-e4f3e67d4b73-image.png

      Channel name is a string value while Chat ID is int. so if you will be making variables for them for easier use in fxdreema make sure you give them the right type, string or int.

      That should be it, if there are any problems be sure to notify me as I haven't done a lot of testing.
      if my tutorial is missing something or is unclear please notify me I will edit it up to make this available to everyone.

      Edit 1. Added "_callback(1);" at the end of the blocks code so you can connect other blocks after the telegram blocks.
      unfortunately fxdreema custom blocks currently can't have 2 outputs (one yellow for if the block received error and didn't send a message) so any blocks connected after it will be activated even if the telegram block received some kind of error and didn't send the message.

      Edit 2. To send to a private channel follow these steps

      1. Login under your account at web version of Telegram : https://web.telegram.org
      2. Find your channel. See to your url, it should be like https://web.telegram.org/#/im?p=c1055587116_11052224402541910257
      3. Grab "1055587116" from it, and add "-100" as a prefix.*
        so your Chat ID would be -1001055587116

      don't use option send to channel but use Group and make it into an int variable, just like with groups

      C T 2 Replies Last reply Reply Quote 3
      • l'andorrà
        l'andorrà last edited by

        Impressive work! 😮 I wish I could do the same.

        (English) I will try to help everyone in these fxDreema forums. But if you want to learn how to use the platform in depth or more quickly, I can help you with my introductory fxDreema course in English at https://www.theandorraninvestor.eu.

        (Català) Miraré d’ajudar tothom en aquests fòrums d’fxDreema. Tanmateix, si vols aprendre a fer servir la plataforma amb més profunditat o més de pressa, t’hi puc ajudar amb el meu curs d’introducció a fxDeema en català a https://www.theandorraninvestor.eu/ca.

        (Español) Intentaré ayudar a todo el mundo en estos foros de fxDreema. Sin embargo, si quieres aprender a usar la plataforma en profundidad o más deprisa, te puedo ayudar con mi curso de introducción a fxDreema en español en https://www.theandorraninvestor.eu/es.

        1 Reply Last reply Reply Quote 0
        • Monaco
          Monaco Banned last edited by

          hank you very much for your great contribution, I have successfully compiled your code but I recive an error when executing the ea. I hope your contribution thanks!0_1563048734735_1563007455350-screenshot_20190713-090729.png 0_1563048763094_1563007532921-screenshot_20190713-091833 (1).png 0_1563048777576_1563007532921-screenshot_20190713-091833.png

          Spuzy 1 Reply Last reply Reply Quote 0
          • Spuzy
            Spuzy @Monaco last edited by

            @realjoker I forgot to write a tutorial for setting up the actual bot, I will update my post now

            1 Reply Last reply Reply Quote 1
            • E
              ezzyxo last edited by

              Thanks @Spuzy mine works well. Im trying to get it to be sent to a private channel, any ideas how to? been trying to change the channel_name string to a int channel_id but having no luck here. (i've 0 coding skills)

              Spuzy 1 Reply Last reply Reply Quote 0
              • Spuzy
                Spuzy @ezzyxo last edited by

                @ezzyxo updated the post 😄 check at the bottom

                Zackry 1 Reply Last reply Reply Quote 2
                • Zackry
                  Zackry @Spuzy last edited by Zackry

                  @spuzy hello spuzy , first of all thank a lot for such a detailed tutorial.

                  secondly i am trying this according to the steps you mentioned and when i download the source code i got 2 errors, it was some syntax errors , 0_1569450998999_Screenshot_7.png


                  so i did this :

                  0_1569451017407_Screenshot_8.png

                  and now the error are gone..

                  but there is no message or the screenshot in the channel when the trade is created , i am sure i am doing something wrong

                  please have a look at the below image , is this the way to do it ?
                  0_1569451157944_Screenshot_9.png

                  1 Reply Last reply Reply Quote 0
                  • Spuzy
                    Spuzy last edited by

                    I see that the pastebin for tele screenshot was deleted for some reason, if you re-wrote it you must of forgot the comma there, make sure that all the parameters are exactly as on screenshot. and make sure you allow https://api.telegram.org for WebRequests in your meta trader. check the expert tab in meta trader once you try to send a screenshot for text that Printed, that should give you some info on the error, if this doesn't fix it screenshot the error message and post it here.

                    Zackry 1 Reply Last reply Reply Quote 2
                    • Zackry
                      Zackry @Spuzy last edited by Zackry

                      @spuzy sorry for my previous post , apparently it was my stupid mistake , i was trying to post in the telegram channel , but i havent added the bot in the channel , (i must be going insane 😄 :D)
                      anyways the whole tutorial is amazing , it easy to understand and its working perfectly many thanks for making the tutorial...

                      just a quick question , how do i make it post the trade open price and the tp sl and lot size in telegram channel ?

                      1 Reply Last reply Reply Quote 0
                      • Spuzy
                        Spuzy last edited by Spuzy

                        0_1569506164668_7def6979-4120-484d-96ac-695291a0e101-image.png

                        just format your message in the custom mql block however you want.
                        DoubleToString will convert a double value into a string. the number 2 and the _Digits is how many decimal points you want.
                        for instance _Digits will return a number of how many decimals there is in the current symbol, EURUSD has 5 for instance. so _Digits will return the number 5. so for open price you want the whole price to show, but not more. for lots since 0.01 is usually the minimum you don't need more than 2 decimals.

                        if you're gonna use pips for sl and tp you are fine with 1. but if you're using price level then use _Digits so the whole price is displayed.

                        Zackry M 4 Replies Last reply Reply Quote 1
                        • Zackry
                          Zackry @Spuzy last edited by Zackry

                          @spuzy perfect,
                          thanks again.

                          1 Reply Last reply Reply Quote 0
                          • Zackry
                            Zackry @Spuzy last edited by Zackry

                            @spuzy is there a way to make it work with the pending orders ? cuz i am trying to use for each pending order block and its not working maybe because of the condition of "on trade (event data)

                            Edited : Never mind its working for pending orders as well

                            1 Reply Last reply Reply Quote 0
                            • Zackry
                              Zackry @Spuzy last edited by

                              @spuzy do you know what could be causing it to send two messages for every trade that is opened ? and the messages are a bit different from one another ...

                              0_1569523131193_Screenshot_12.png

                              S 1 Reply Last reply Reply Quote 0
                              • Spuzy
                                Spuzy last edited by

                                the second messge doesn't seem to be formated correctly either, I don't know, you must have it connected badly. the blocks only sends 1 message based on the inputs and that's it

                                Zackry 1 Reply Last reply Reply Quote 1
                                • Zackry
                                  Zackry @Spuzy last edited by Zackry

                                  @spuzy said in [Custom Block Release] Send a message or screenshot to Telegram Blocks:

                                  hi spuzy everything was sorted out but all of a sudden it started to miss some code apparently its not picking the sendMessage code,
                                  0_1570088350436_Screenshot_3.png
                                  [
                                  [
                                  but obviously the code is inside the block
                                  0_1570088393156_Screenshot_4.png
                                  but its not being included in the code

                                  1 Reply Last reply Reply Quote 0
                                  • Spuzy
                                    Spuzy last edited by

                                    ah yes, you're right, this is my bad, I've out both functions inside one custom function, so if send screenshot function isn't called the telegram message one also won't be

                                    I will edit my main post to fix this.

                                    go to the low right corner and click to edit the telegramsendscreenshot function, scroll down to find the sendmessage function, cut it out and paste the code in a new function

                                    0_1570284621156_54606b06-8967-4be7-a7fe-461892fda2fb-image.png

                                    Zackry 1 Reply Last reply Reply Quote 1
                                    • Zackry
                                      Zackry @Spuzy last edited by

                                      @spuzy
                                      Did and now errors are gone but there is still no message or screenshot in the telegram channel, strange thing is that it was working previously, but then it started giving the above mentioned error and now it's no longer working

                                      H 1 Reply Last reply Reply Quote 0
                                      • H
                                        Hadees @Zackry last edited by Hadees

                                        @zackry try deleting the sendmessage function as it is already defined in sendscreenshot. I followed it and had problems with the send message but got around it by putting the variable in the picture text http://icecream.me/a8f3038debc8b6bfd3fc5e638f78d9d4

                                        1 Reply Last reply Reply Quote 0
                                        • A
                                          abubakar last edited by abubakar

                                          thanks a lot for this tutorial..
                                          i have done all the steps.. but its not sending message to channel or group
                                          added bot to channel and group both with admin permission..
                                          added webrequest, added api, added channel name added token..
                                          no compilation error..
                                          but still not sending message

                                          0_1572521237380_4c8ce4b5-49cb-4fb6-a577-3f73deaf3cd0-image.png

                                          0_1572521267636_ba7fe201-c8ac-4cd2-807b-574a6511f7d8-image.png
                                          0_1572521434228_85ada636-a9dd-45a2-833c-9b5d656fec07-image.png

                                          0_1572521994698_32c82967-9967-4dce-b65b-a7da01c812ee-image.png

                                          on my mt4 no trade button

                                          1 Reply Last reply Reply Quote 0
                                          • Spuzy
                                            Spuzy last edited by

                                            check the experts tab for error, also try adding the block to oninit connected with a pass block, so when you add the EA to the chart it will immediately send a message, if that works that means your on trade block is wrong, if not then read the experts tab for errors and post them here

                                            T 1 Reply Last reply Reply Quote 1
                                            • 1
                                            • 2
                                            • 3
                                            • 1 / 3
                                            • First post
                                              Last post

                                            Online Users

                                            B
                                            A
                                            T
                                            M
                                            E
                                            C

                                            20
                                            Online

                                            146.7k
                                            Users

                                            22.4k
                                            Topics

                                            122.6k
                                            Posts

                                            Powered by NodeBB Forums | Contributors