-1

I am working on automating the trade signals generated in metatrader 4. Idea is to encode the buy/sell signals into message and send to a python telegram receiver code which will decode the message and take appropriate action (like placing orders with broker using broker provided python APIs). any idea how this can be done?

I have so far tried below code, which receives message from my telegram account and replies same text back. https://github.com/python-telegram-bot/python-telegram-bot/blob/master/examples/echobot2.py

my requirement is instead of using telegram account on mobile, i need it in the metatrader

  • it is not clear what you want to do. do you need to send message from mt4 to a telegram channel? or receive message from the channel? mt4 -> Telegram -> TG wrapper to parse message into python -> process message in python so here are three actions, which of them you have problem with? – Daniel Kniaz Oct 25 '18 at 13:38
  • i need the last method. mt4 -> Telegram -> TG wrapper to parse message into python -> process message in python – Shivaprashanth Hiremath Oct 26 '18 at 06:28
  • what is last method? There are three steps in the chain, if you cannot solve issues with wrapper -> process message and send trade request using broker's api - show your code and why do you think the github link didnt help you – Daniel Kniaz Oct 26 '18 at 08:06
  • let me put the requirement in a different way. on mt4, in an indicator function, i will call telegram api to send a message to one dedicated telegram account. i dont need to see this message received in my telegram app. but i want to instead read this message using python. for ex: if the message sent by mt4 to one telegram account is 'APPLE:BUY' then this message will be processed in python (which is in listening mode 24/7) running in a VPS and it will place the order for buying the stock. – Shivaprashanth Hiremath Oct 26 '18 at 08:36
  • oh, i see. MT4 -> telegram works fine, is it correct? then it is not clear why you tagged your question as MQL4 – Daniel Kniaz Oct 26 '18 at 09:53
  • send message function inside mt4 code (ext mq4) is what i need. right now i have a python code which is in listening mode always. whenever i sent a message from my mobile from my telegram bot account, that message is received by python. but how do i send message from mt4 code is my question. i think i got confused with mq4 and mql4. sorry for that. – Shivaprashanth Hiremath Oct 26 '18 at 11:18
  • there is quite a lot of code to copy and paste. here is an article explaining how to send message from MQL https://www.mql5.com/en/articles/2355, a library is also available for speeding up development – Daniel Kniaz Oct 26 '18 at 18:31
  • i have tried this exact code. when i send some text from mt4, i receive it in my mobile telegram app. but i want it to be received in the python which is listening on a vps. i beleive this is not happening because while sending message we use chat_id to identify the recipient. so its going to telegram app. i want to know how do we redirect the same text to python – Shivaprashanth Hiremath Oct 27 '18 at 14:24
  • you asked about `how do i send message from mt4 code is my question.` and now you say that `but i want it to be received in the python which is listening on a vps.` do you think that someone here knows better than you what you need? show your MCVE in order to go further with a problem that you have – Daniel Kniaz Oct 27 '18 at 18:42

1 Answers1

-1

today with bit of struggle i figured out a way to achieve my requirement. not an efficient solution but its working. so i am explaining below,

MT4 EA code: once buy/sell signals generated, a message is sent to my first telegram bot (call it A_bot).

A_bot: forwards the received message to second bot(call it B_bot)

python server on vps: same token as that of B_bot is listening to incoming messages. in other words python version of B_bot is listening to incoming messages.

so when A_bot forwards the message recieved by MT4 EA to B_bot, copy of same message is received is received by python server. So in python server code now i am able to process the message and place order accordingly. so the original problem is i can't do this with just A_bot. there is an extra step involved to forward message from one telegram bot to another to make it work. for this i am using android app Tforwarder.