您现在的位置:外汇网 > 外汇随笔 >

「电脑版mt4」MT4一键开仓多单和空单的脚本

2020-08-09 09:13来源:kjc外汇网编辑:kjc人气:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
//+------------------------------------------------------------------+
//|                                                          116.mq4 |
//|                                          Copyright 2016, 鲁班外汇 |
//|                                              http://www.lubanea.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, EA欧米伽教程"
#property link      "https://www.lubanea.com"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   buy(0.1,500,250,"buy",123456);
   sell(0.1,500,250,"sell",123457);
  }
//+------------------------------------------------------------------+
bool buy(double lots, double zhisun, double zhiying, string zhushi, int haoma)
  {
    bool a=false;
    int t=OrdersTotal();
    for(int i=0;i<t;i++)
      {
        if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
          {
            if(OrderSymbol()==Symbol() && OrderType()==OP_BUY && OrderComment()==zhushi && OrderMagicNumber()==haoma)
              {
                a=true;
                break;
              }
          }
      }
     if(a==false)
      {
        ResetLastError();
        if(zhisun!=0 && zhiying!=0)
          {
            if(!OrderSend(Symbol(),OP_BUY,lots,Ask,0,Ask-zhisun*Point,Ask+zhiying*Point,zhushi,haoma,Red))
              {
                printf("[biao]开单失败,请查询错误代码: "+(string)GetLastError());
                return(false);
              }
          }
        if(zhisun!=0 && zhiying==0)
          {
            if(!OrderSend(Symbol(),OP_BUY,lots,Ask,0,Ask-zhisun*Point,0,zhushi,haoma,Red))
              {
                printf("[biao]开单失败,请查询错误代码: "+(string)GetLastError());
                return(false);
              }
          }
        if(zhisun==0 && zhiying!=0)
          {
            if(!OrderSend(Symbol(),OP_BUY,lots,Ask,0,0,Ask+zhiying*Point,zhushi,haoma,Red))
              {
                printf("[biao]开单失败,请查询错误代码: "+(string)GetLastError());
                return(false);
              }
          }
        if(zhisun==0 && zhiying==0)
          {
            if(!OrderSend(Symbol(),OP_BUY,lots,Ask,0,0,0,zhushi,haoma,Red))
              {
                printf("[biao]开单失败,请查询错误代码: "+(string)GetLastError());
                return(false);
              }
          }
      }
    
    return(true);
  }
bool sell(double lots, double zhisun, double zhiying, string zhushi, int haoma)
  {
    bool a=false;
    int t=OrdersTotal();
    for(int i=0;i<t;i++)
      {
        if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
          {
            if(OrderSymbol()==Symbol() && OrderType()==OP_SELL && OrderComment()==zhushi && OrderMagicNumber()==haoma)
              {
                a=true;
                break;
              }
          }
      }
     if(a==false)
      {
        ResetLastError();
        if(zhisun!=0 && zhiying!=0)
          {
            if(!OrderSend(Symbol(),OP_SELL,lots,Bid,0,Bid+zhisun*Point,Bid-zhiying*Point,zhushi,haoma,Green))
              {
                printf("[biao]开单失败,请查询错误代码: "+(string)GetLastError());
                return(false);
              }
          }
        if(zhisun!=0 && zhiying==0)
          {
            if(!OrderSend(Symbol(),OP_SELL,lots,Bid,0,Bid+zhisun*Point,0,zhushi,haoma,Green))
              {
                printf("[biao]开单失败,请查询错误代码: "+(string)GetLastError());
                return(false);
              }
          }
        if(zhisun==0 && zhiying!=0)
          {
            if(!OrderSend(Symbol(),OP_SELL,lots,Bid,0,0,Bid-zhiying*Point,zhushi,haoma,Green))
              {
                printf("[biao]开单失败,请查询错误代码: "+(string)GetLastError());
                return(false);
              }
          }
        if(zhisun==0 && zhiying==0)
          {
            if(!OrderSend(Symbol(),OP_SELL,lots,Bid,0,0,0,zhushi,haoma,Green))
              {
                printf("[biao]开单失败,请查询错误代码: "+(string)GetLastError());
                return(false);
              }
          }
      }
    
    return(true);
  }

打开MT4软件,按”F5″打开MQL4编纂器,建立一个新的文本,然后复制以上代码,粘贴到剧本中,编译留存即可,然后在MT4软件坐标的导航,剧本文件夹下即可找到你建立的剧本名称的文本.

(本文主要讲述:「电脑版mt4」MT4一键开仓多单和空单的脚本,希望你从中受益)

版权与免责声明

  • 凡本网注明"来源:外汇交流-kjc外汇网的所有作品,版权均属于kjc外汇网,转载请必须注明https://www.kjcwh.com/note/1452.html。违反者本网将追究相关法律责任。
  • 本网转载并注明自其它来源的作品,目的在于传递更多信息,并不代表本网赞同其观点或证实其内容的真实性,不承担此类作品侵权行为的直接责任及连带责任。其他媒体、网站或个人从本网转载时,必须保留本网注明的作品来源,并自负版权等法律责任。
  • 如涉及作品内容、版权等问题,请在作品发表之日起一周内与本网联系,否则视为放弃相关权利。







外汇书籍

《奥马哈之雾》这本书适合初学者吗?

《奥马哈之雾》这本书适合初学者吗?



返回首页