简体   繁体   English

从metatrader4向python中的电报机器人发送消息

[英]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.

相关问题 如何从 MQL4 EA 流程(MetaTrader4 终端)运行 Python 脚本? - How to run a python script from an MQL4 EA-process ( MetaTrader4 Terminal )? 如何使用ZeroMQ从MetaTrader终端向python发送MQL4 / 5中的消息? - How to send a message in MQL4/5 from MetaTrader Terminal to python using ZeroMQ? 电报:使用机器人向私人群组发送消息 - Telegram: Send message to private group with bot 如何从vb.net实时从MetaTrader4终端(MT4)读取蜡烛数据 - How to read candle data from a MetaTrader4 Terminal ( MT4 ) from vb.net in realtime MetaTrader4终端,策略测试器:在交易发生之前如何从[结果窗口]跳至[图表]? - MetaTrader4 Terminal, Strategy Tester: how to jump from a [ Results Window ] to the [ Graph ] BEFORE a Trade Happens? 将互联网时间数据导入metatrader4 - Import internet time data into metatrader4 如何在 MetaTrader4 终端中获取当前毫秒数? - How to get current milliseconds in MetaTrader4 Terminal? 如何使用 MetaTrader4 错误代码刷新进行正确的错误处理? - How to use a MetaTrader4 Error Code Refresh for proper error handling? 在MQL4 MetaTrader4中根据Symbol()定义数组[专家顾问] - Defining an array, depending on Symbol(), in MQL4 MetaTrader4 [Expert Advisor] 如何在Metatrader4中基于帐户货币计算手数 - How to calculate lot based on account currency in Metatrader4
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM