找回密码
 立即注册

网络跟单服务端(局域网/公网/多账户管理)

[复制链接]

网络跟单服务端(局域网/公网/多账户管理)

[复制链接]
admin

235

主题

97

回帖

3万

积分

管理员

积分
35240
2021-10-26 21:05:00 | 显示全部楼层 |阅读模式

网络跟单服务端.exe

网络跟单服务端.exe


网络跟单服务端.exe

网络跟单服务端.exe


网络跟单服务端.exe

网络跟单服务端.exe



功能介绍:
1.支持开机自启动,隐藏到托盘后台运行
2.一键搭建服务器,IP/端口/请求秘钥自己设置
3.统计账户信息,选中账户右键即可平仓,所有账户一键全平
4.MT4和MT5EA用WebRequest函数来进行通讯,安全稳定,MT4仅支持80端口,MT5无端口限制
5.支持贴牌定制


软件接口例子: (mqh文件在最下面)


  1. //+------------------------------------------------------------------+
  2. //|                                                      ProjectName |
  3. //|                                      Copyright 2018, CompanyName |
  4. //|                                       http://www.companyname.net |
  5. //+------------------------------------------------------------------+
  6. #property version   "1.00"
  7. #property strict
  8. #include <HttpPost.mqh>
  9. MqlPOST HttpPost;
  10. input string                G_host="http://127.0.0.1/";//地址
  11. input string                G_port="80";//端口
  12. input string                G_key="mtctp";//秘钥
  13. string uRl=StringSubstr(G_host,0,StringLen(G_host)-1)+":"+G_port+"/";
  14. //+------------------------------------------------------------------+
  15. //|                                                                  |
  16. //+------------------------------------------------------------------+
  17. int OnInit()
  18.   {
  19.    HttpPost.loginout(uRl,"loginout",G_key);//提交一次登出(用于初始化状态)
  20.    return(INIT_SUCCEEDED);
  21.   }
  22. //+------------------------------------------------------------------+
  23. //|                                                                  |
  24. //+------------------------------------------------------------------+
  25. void OnDeinit(const int reason)
  26.   {
  27.    HttpPost.loginout(uRl,"loginout",G_key);//提交一次登出(用于初始化状态)
  28.   }
  29. //+------------------------------------------------------------------+
  30. //|                                                                  |
  31. //+------------------------------------------------------------------+
  32. void OnTick()
  33.   {
  34.   //Fun1();
  35.   //Fun2();
  36.   //Fun3();
  37.   }
  38. //+------------------------------------------------------------------+
  39. //|                                                                  |
  40. //+------------------------------------------------------------------+
  41. void Fun1()
  42.   {
  43. //+------------------------------------------------------------------+
  44. //|                          对冲交互跟单信息交换                        |
  45. //+------------------------------------------------------------------+
  46.    string order_msg="xx......";//提交当前账号订单字符串
  47.    ulong  hedging_order_number=0;//提交对冲跟单账号
  48.    string tmpStr=HttpPost.save_order_get_msg(uRl,order_msg,G_key,hedging_order_number);
  49. //把订单字符串和对冲跟单账号提交到服务器会返回对冲跟单账号持仓字符串
  50.    string firstChar = StringSubstr(tmpStr, 0, 2);
  51.    if(firstChar=="1/")//检测状态进行平仓
  52.      {
  53.       PlaySound("tick.WAV");
  54.       //OrderClose(-100,-1,"","symbol");//账户全部平仓代码
  55.       Print("网络跟单服务端->发送账户全部平仓命令");
  56.       HttpPost.save_state(uRl,"close",G_key);//保存状态
  57.      }
  58.    string msg = StringSubstr(tmpStr, 2);
  59.    //返回对冲跟单账号订单信息
  60.    
  61.    
  62.    
  63.   }
  64. //+------------------------------------------------------------------+
  65. //|                                                                  |
  66. //+------------------------------------------------------------------+
  67. void Fun2()
  68.   {
  69. //+------------------------------------------------------------------+
  70. //|                          普通跟单<发射端>                     |
  71. //+------------------------------------------------------------------+
  72.    string order_msg="xx......";//提交当前账号订单字符串
  73.    string tmpStr=HttpPost.save_order_get_msg(uRl,order_msg,G_key,0);
  74. //把订单字符串提交到服务器
  75.    string firstChar = StringSubstr(tmpStr, 0, 2);
  76.    if(firstChar=="1/")
  77.      {
  78.       PlaySound("tick.WAV");
  79.       //OrderClose(-100,-1,"","symbol");//账户全部平仓代码
  80.       Print("网络跟单服务端->发送命令");//保存状态
  81.       HttpPost.save_state(uRl,"close",G_key);
  82.      }
  83.   }
  84. //+------------------------------------------------------------------+
  85. //|                                                                  |
  86. //+------------------------------------------------------------------+
  87. void Fun3()
  88.   {
  89. //+------------------------------------------------------------------+
  90. //|                          普通跟单<接收端>                     |
  91. //+------------------------------------------------------------------+
  92.    ulong    copy_order_number=123456789;//提交跟单账号
  93.    string   tmpStr=HttpPost.get_msg(uRl,copy_order_number,G_key);
  94.           //tmpStr 跟单账号的持仓信息
  95.   }
  96. //+------------------------------------------------------------------+
复制代码









网络跟单服务端.exe

12.35 MB, 下载次数: 1825

网络跟单服务端.exe

楼主
admin 楼主

235

主题

97

回帖

3万

积分

管理员

积分
35240
3 天前 | 显示全部楼层
HttpPost.mqh

  1. //+------------------------------------------------------------------+
  2. //|                                                     HttpPost.mqh |
  3. //|                                  Copyright 2023, MetaQuotes Ltd. |
  4. //|                                             https://www.mql5.com |
  5. //+------------------------------------------------------------------+
  6. #property copyright "Copyright 2023, MetaQuotes Ltd."
  7. #property link      "https://www.mql5.com"
  8. #property strict
  9. //+------------------------------------------------------------------+
  10. //|                                                                  |
  11. //+------------------------------------------------------------------+
  12. class MqlPOST
  13.   {
  14. public:
  15.                      MqlPOST();
  16.                     ~MqlPOST();
  17.    string            save_order_get_msg(string uRL, string mess = "NULL",string key= "NULL",long othernumber= 0);
  18.    string            get_msg(string uRL, long account,string key= "NULL",long othernumber= 0);
  19.    string            get_last_updated_time(string uRL, long account,string key= "NULL",long othernumber= 0);
  20.    string            loginout(string uRL, string mess = "NULL",string key= "NULL",long othernumber= 0);
  21.    string            save_state(string uRL, string mess = "NULL",string key= "NULL",long othernumber= 0);
  22.    string            make_web_request(string uRL, int type, long account = 0, string mess = "NULL", string key = "NULL",long othernumber= 0);
  23.   };
  24. //+------------------------------------------------------------------+
  25. //|                                                                  |
  26. //+------------------------------------------------------------------+
  27. void MqlPOST::MqlPOST()
  28.   {
  29.   }
  30. //+------------------------------------------------------------------+
  31. //|                                                                  |
  32. //+------------------------------------------------------------------+
  33. void MqlPOST::~MqlPOST()
  34.   {
  35.   }
  36. //+------------------------------------------------------------------+
  37. string MqlPOST::save_order_get_msg(string uRL, string mess = "NULL",string key= "NULL",long othernumber= 0)
  38.   {
  39.    return make_web_request(uRL, 1, -1, mess,key,othernumber);
  40.   }
  41. //+------------------------------------------------------------------+
  42. //|                                                                  |
  43. //+------------------------------------------------------------------+
  44. string MqlPOST::get_msg(string uRL, long account,string key= "NULL",long othernumber= 0)
  45.   {
  46.    return make_web_request(uRL, 2, account, "NULL",key,othernumber);
  47.   }
  48. //+------------------------------------------------------------------+
  49. //|                                                                  |
  50. //+------------------------------------------------------------------+
  51. string MqlPOST::get_last_updated_time(string uRL, long account,string key= "NULL",long othernumber= 0)
  52.   {
  53.    return make_web_request(uRL, 3, account, "NULL",key,othernumber);
  54.   }
  55. //+------------------------------------------------------------------+
  56. //|                                                                  |
  57. //+------------------------------------------------------------------+
  58. string MqlPOST::loginout(string uRL, string mess = "NULL",string key= "NULL",long othernumber= 0)
  59.   {
  60.    return make_web_request(uRL, 5, -1, mess,key,othernumber);
  61.   }
  62. //+------------------------------------------------------------------+
  63. //|                                                                  |
  64. //+------------------------------------------------------------------+
  65. string MqlPOST::save_state(string uRL, string mess = "NULL",string key= "NULL",long othernumber= 0)
  66.   {
  67.    return make_web_request(uRL, 4, -1, mess,key,othernumber);
  68.   }
  69. //+------------------------------------------------------------------+
  70. //|                                                                  |
  71. //+------------------------------------------------------------------+
  72. string MqlPOST::make_web_request(string uRL, int type, long account = 0, string mess = "NULL", string key = "NULL",long othernumber= 0)
  73.   {
  74. // 如果account未提供,使用当前登录账户
  75.    if(account ==0)
  76.       return "";
  77.    if(account < 0)
  78.       account = AccountInfoInteger(ACCOUNT_LOGIN);
  79.    string data = "accnumber=" + IntegerToString(account) +
  80.                  "&othernumber=" + IntegerToString(othernumber) +
  81.                  "&acctype=" + (TerminalInfoInteger(TERMINAL_X64) ? "MT5" : "MT4") +
  82.                  "&accbalance=" + DoubleToString(AccountInfoDouble(ACCOUNT_BALANCE),2) +
  83.                  "&accequity=" + DoubleToString(AccountInfoDouble(ACCOUNT_EQUITY),2) +
  84.                  "&accprofit=" + DoubleToString(AccountInfoDouble(ACCOUNT_PROFIT),2) +
  85.                  "&accmarginlevel=" + DoubleToString(AccountInfoDouble(ACCOUNT_MARGIN_LEVEL),2)+"%" +
  86.                  "&acclasttime=" + TimeToString(TimeLocal(),TIME_DATE|TIME_MINUTES|TIME_SECONDS) +
  87.                  "&acccompany=" + AccountInfoString(ACCOUNT_COMPANY) +
  88.                  "&state=" + "0" +
  89.                  "&msg=" + mess +
  90.                  "&key=" + key +
  91.                  "&type=" + string(type);
  92.    string headers = "Content-Type: application/x-www-form-urlencoded\r\n";
  93.    char result[];
  94.    string response = "";
  95.    uchar postData[];
  96.    StringToCharArray(data, postData, 0, WHOLE_ARRAY, CP_UTF8);
  97.    int res = WebRequest("POST", uRL, headers, 5000, postData, result, response);
  98.    if(res == 200)
  99.      {
  100.       string resultStr = CharArrayToString(result, 0, -1, CP_UTF8);
  101.       return resultStr;  
  102.      }
  103.    else
  104.      {
  105.       printf(uRL + " " + data);
  106.       Print("Web请求失败,错误代码:", res);
  107.      }
  108.    return "";
  109.   }
复制代码


QQ|订单查询|1机1码|许可证生成器|网站统计|www.mtctp.com |

GMT+8, 2025-10-29 20:10 , Processed in 0.066327 second(s), 23 queries .

qq 280726108 微信 bucaiea / Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表