[英]send message from metatrader4 to telegram bot in python
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).我正在致力于使 metatrader 4 中生成的交易信号自动化。想法是将买入/卖出信号编码为消息并发送到 python 电报接收器代码,该代码将解码消息并采取适当的行动(例如使用提供的经纪人向经纪人下订单python API)。 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 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我的要求不是在移动设备上使用电报帐户,而是在元交易者中需要它
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). MT4 EA 代码:一旦生成买入/卖出信号,就会向我的第一个电报机器人(称为 A_bot)发送一条消息。
A_bot: forwards the received message to second bot(call it B_bot) A_bot:将接收到的消息转发给第二个机器人(称为 B_bot)
python server on vps: same token as that of B_bot is listening to incoming messages. vps 上的 python 服务器:与 B_bot 相同的令牌正在侦听传入消息。 in other words python version of B_bot is listening to incoming messages.换句话说,python 版本的 B_bot 正在侦听传入的消息。
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.因此,当 A_bot 将 MT4 EA 收到的消息转发给 B_bot 时,python 服务器接收到相同消息的副本。 So in python server code now i am able to process the message and place order accordingly.所以现在在 python 服务器代码中,我能够处理消息并相应地下订单。 so the original problem is i can't do this with just A_bot.所以最初的问题是我不能只用 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.为此,我正在使用 android 应用程序 Tforwarder。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.