TMGM

0.16 Point
. 欧元点差

0.32 Point
. 黄金点差

[【MT4】专题] MT4多空各开一单EA框架模板【EA】

[复制链接]
admin 发表于 2017-1-26 20:25:01 | 显示全部楼层 |阅读模式
查看: 4784|回复: 0
  1. //+------------------------------------------------------------------+
  2. //|                                    MT4多空各开一单EA框架模板.mq4 |
  3. //|                                                                  |
  4. //|                                             http://www.lh321.com |
  5. //+------------------------------------------------------------------+
  6. //======================================
  7. //---软件界面参数设置
  8. #property copyright   "+点击【领汇网】查看更多实用软件"
  9. #property link        "http://www.lh321.com"
  10. #property description "【领汇网】   :www.lh321.com"
  11. #property description "【软件版本】:多空各开一单EA框架模板"//软件版本【界面显示】
  12. #property description "【授权期限】:永久"
  13. #property version     "    【领汇网】www.lh321.com"   //软件版本【标题显示】
  14. #property description "【作者 QQ】:83898578"
  15. #property description "【作者Q群】:34604068"
  16. #property description "【E  A简介】:(EA)启动自动多空各下一单,同时设置止损止盈!"
  17. #property description "【软件性质】:本软件由领汇网编译优化,免费发行使用,未经授权,禁止商业化!"
  18. #property strict //通过该指令编译模式严谨控制所有的错误
  19. //======================================

  20. input double Lots =0.1;       //【手数】手数设置
  21. input double stoploss = 300;      //【止损】输入100等于10点距离
  22. input double takeprofit = 600;     //【止盈】输入100等于10点距离
  23. input string comment_Buy = "多单";   //【多单注释】
  24. input string comment_Sell = "空单";  //【空单注释】
  25. input int magic = 123;  //【订单批号】
  26. //+------------------------------------------------------------------+
  27. //| Expert initialization function                                   |
  28. //+------------------------------------------------------------------+
  29. int OnInit()
  30.   {
  31. //---
  32.    
  33. //---
  34.    return(INIT_SUCCEEDED);
  35.   }
  36. //+------------------------------------------------------------------+
  37. //| Expert deinitialization function                                 |
  38. //+------------------------------------------------------------------+
  39. void OnDeinit(const int reason)
  40.   {
  41. //---
  42.    
  43.   }
  44. //+------------------------------------------------------------------+
  45. //| Expert tick function                                             |
  46. //+------------------------------------------------------------------+
  47. void OnTick()
  48.   {
  49. //---
  50. buy(Lots,stoploss,takeprofit,comment_Buy,magic);  //开多单:

  51. sell(Lots,stoploss,takeprofit,comment_Sell,magic);  //开空单:
  52.   }
  53. //+------------------------------------------------------------------+

  54. //开多单扫描
  55. bool buy(double lots,double zhisun, double zhiying,string zhushi,int haoma) //扫描开出的单子
  56.   {
  57.     bool b=false; bool a=0;
  58.     int t=OrdersTotal();
  59.     for(int i=0;i<t;i++)
  60.       {
  61.         if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
  62.           {
  63.             if(OrderSymbol()==Symbol() && OrderType()==OP_BUY && OrderComment()==zhushi && OrderMagicNumber()==haoma)
  64.               {
  65.                 b=true;
  66.                 break;
  67.               }
  68.           }
  69.       }
  70.      if(b==false)
  71.       {
  72.         if(zhisun!=0 && zhiying!=0)
  73.          {
  74.            a=OrderSend(Symbol(),OP_BUY,lots,Ask,0,Ask-zhisun*Point,Ask+zhiying*Point,zhushi,haoma,Red);
  75.          }
  76.         else if(zhisun==0 && zhiying!=0)
  77.          {
  78.            a=OrderSend(Symbol(),OP_BUY,lots,Ask,0,0,Ask+zhiying*Point,zhushi,haoma,Red);
  79.          }
  80.         else if(zhisun==0 && zhiying==0)
  81.          {
  82.            a=OrderSend(Symbol(),OP_BUY,lots,Ask,0,0,0,zhushi,haoma,Red);
  83.          }
  84.         else if(zhisun!=0 && zhiying==0)
  85.          {
  86.            a=OrderSend(Symbol(),OP_BUY,lots,Ask,0,Ask-zhisun*Point,0,zhushi,haoma,Red);
  87.          }
  88.       }
  89.    
  90.     return(a);
  91.   }
  92.    
  93.     //开空单扫描
  94. bool sell(double lots,double sl,double tp, string com,int sellmagic) //扫描开出的单子
  95.    {
  96.      int a=0;
  97.      bool zhaodan=false;
  98.         //获取开单信息
  99.      for(int i=0;i<OrdersTotal();i++)
  100.       {
  101.        if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
  102.        {
  103.        string zhushi=OrderComment();//注释
  104.        int ma=OrderMagicNumber();//标记
  105.        if(OrderSymbol()==Symbol() && OrderType()==OP_SELL && zhushi==com && ma==sellmagic)
  106.          {
  107.          zhaodan=true;
  108.          break;
  109.          }
  110.         }
  111.        }
  112.        if(zhaodan==false)
  113.         {
  114.          if(sl==0 && tp!=0)
  115.          {
  116.           a=OrderSend(Symbol(),OP_SELL,lots,Bid,50,0,Bid-tp*Point,com,sellmagic,0,White);
  117.          }
  118.          else if(sl!=0 && tp==0)
  119.          {
  120.           a=OrderSend(Symbol(),OP_SELL,lots,Bid,50,Bid+sl*Point,0,com,sellmagic,0,White);
  121.          }
  122.          else if(sl==0 && tp==0)
  123.          {
  124.           a=OrderSend(Symbol(),OP_SELL,lots,Bid,0,0,0,com,sellmagic,0,White);
  125.          }
  126.          else if(sl!=0 && tp!=0)
  127.          {
  128.           a=OrderSend(Symbol(),OP_SELL,lots,Bid,0,Bid+sl*Point,Bid-tp*Point,com,sellmagic,0,White);
  129.          }
  130.         }
  131.         
  132.      return(a);
  133.     }
复制代码

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ| 小黑屋|手机版|Archiver|【领汇网】

GMT+8, 2024-5-20 07:49 , Processed in 1.080849 second(s), 27 queries .

【领汇网】© 小小网站领汇人生点滴.           ICP证:粤ICP备15007435号

© 2019-2020 Tksug.com.版权所有  DZ! X32

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