MT4使用MQL连接Redis的插件

工作中需要将MT4的数据读取并且存储到Redis数据库中去,同时MT4读取Redis当中的数据用于下单的切换账户。
MT4支持使用MQL进行开发,通过调用标准的系统DLL实现系统调用,因此技术实现并不是太难,只需要按MQL的接口要求编写相应的CPP代码
编译成DLL即可实现所需要的功能。

在Windows平台上,连接Redis的客户端选用Hiredis作为连接客户端lib。



MT4 连接Redis 头文件定义,
MT4RedisPlugin.h

#define MT4_REDIS_ERR -1 /* Error */
#define MT4_REDIS_OK 0 /* OK */
#define MT4_REDIS_ERR_IO 1 /* error in read or write */
#define MT4_REDIS_ERR_EOF 3 /* eof */
#define MT4_REDIS_ERR_PROTOCOL 4 /* protocol error */
#define MT4_REDIS_ERR_OTHER 2 /* something else */

#define MT4_REDIS_CMD_SUCCESSED 0 /* Successed */
#define MT4_REDIS_CMD_FAILED -1 /* Failed */

//---
#define MT4_EXPFUNC __declspec(dllexport)

//+------------------------------------------------------------------+
//| Test Redis if is working |
//+------------------------------------------------------------------+
MT4_EXPFUNC int __stdcall RedisTest(const char* server, const int port);

//+------------------------------------------------------------------+
//| Excute Redis Command "GET key" |
//+------------------------------------------------------------------+
MT4_EXPFUNC wchar_t* __stdcall RedisGet(const wchar_t* key);

//+------------------------------------------------------------------+
//| Excute Redis Command "GET key" |
//+------------------------------------------------------------------+
MT4_EXPFUNC wchar_t* __stdcall RedisGetWithTimeout(const wchar_t* key,int timeout);

//+------------------------------------------------------------------+
//| Excute Redis Command "SET key value" |
//+------------------------------------------------------------------+
MT4_EXPFUNC int __stdcall RedisSet(const wchar_t* key, const wchar_t* value);

//+------------------------------------------------------------------+
//| Excute Redis Command "SET key value" |
//+------------------------------------------------------------------+
MT4_EXPFUNC int __stdcall RedisSetWithTimeout(const wchar_t* key, const wchar_t* value,int timeout);

//+------------------------------------------------------------------+
//| Excute Redis Command |
//+------------------------------------------------------------------+
MT4_EXPFUNC int __stdcall RedisCommand(const wchar_t* command);

//+------------------------------------------------------------------+
//| Excute Red
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值