有您的持续关注
我们会做得更好

MT4挂单脚本 挂买L单 BUYLIMIT BUYSTOP



MT4挂单脚本 挂买L单 BUYLIMIT  BUYSTOP 该脚本可以实现按指定距离 手数 挂买单

MQL4源码如下:

    
 //+------------------------------------------------------------------+
 //|                                                       挂买单.mq4 |
 //|                      www.125808047.com. |
 //|                                        http://www.125808047.com|
 //+------------------------------------------------------------------+
 #property copyright "www.125808047.com."
 #property link      "http://www.125808047.com/"
 #property show_inputs
 extern double     最小手数 = 0.01;
extern string a1="自动模式设为0累加设为1固定";
 extern int        自动模式 = 0;
 extern double 第一单手数=0.01;
 extern double 上第1档手数=0.01;
 extern double 上第2档手数=0.01;
 extern double 上第3档手数=0.01;
 extern double 上第4档手数=0.01;
 extern double 上第5档手数=0.01;
 extern double 上第6档手数=0.01;
 extern double 上第7档手数=0.01;
 extern double 下第1档手数=0.01;
 extern double 下第2档手数=0.01;
 extern double 下第3档手数=0.01;
 extern double 下第4档手数=0.01;
 extern double 下第5档手数=0.01;
 extern double 下第6档手数=0.01;
 extern double 下第7档手数=0.01;
extern double 上挂单距离=20;
 extern double 下挂单距离=30;
 extern int    编码magic            = 88888885;
 extern double 上挂单次数=50;
 extern double 下挂单次数=10;
extern double MaxLots=0.2;
 int gd_180;
 int gd_181;
 int gd_182;
 int li_0;
int init() {
    li_0 = 1;
   if (Digits == 5.0 || Digits == 3.0) li_0 = 10;
 
   return (0);
 }
 int start()
  {
 Counts();
OrderSend(Symbol(), OP_BUY, 第一单手数, Ask, 2*li_0, 0, 0,WindowExpertName( ) , 编码magic, 0, Blue);
 Sguada();
 Xguada();
 
 
   return(0);
  }
 //+------------------------------------------------------------------+
 void Sguada()
 {
     for (int li_132 = 上挂单次数; li_132 > 0; li_132--) {
               RefreshRates();
               Counts();
               OrderSend(Symbol(), OP_BUYSTOP, GetLots1(自动模式), Ask+(gd_181+1)*上挂单距离*li_0*Point, 2*li_0, 0, 0,"买突破单"+"-"+Symbol() , 编码magic, 0, Blue);
               if (GetLastError() != 0) {
                  Print("Buy OrderSend 3 failed with error #", GetLastError());
                  Sleep(1000);
               }
               if(上挂单次数<=gd_181) break;
            }
           
            }
 void Xguada()
 {
     for (int li_132 = 下挂单次数; li_132 > 0; li_132--) {
               RefreshRates();
               Counts();
               OrderSend(Symbol(), OP_BUYLIMIT, GetLots(自动模式), Ask-(gd_182+1)*下挂单距离*li_0*Point, 2*li_0, 0, 0,"买挂单"+"-"+Symbol() , 编码magic, 0, Blue);
               if (GetLastError() != 0) {
                  Print("Buy OrderSend 3 failed with error #", GetLastError());
                  Sleep(1000);
               }
               if(下挂单次数<=gd_182) break;
            }
           
            }
void Counts() {  
   gd_180 = 0;
   gd_181 = 0;
   gd_182 = 0;
   for (int cn = OrdersTotal() - 1; cn >= 0; cn--) {
      OrderSelect(cn, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() != Symbol()||编码magic!=OrderMagicNumber( ) ) continue;
      if (OrderSymbol() == Symbol()) {
        if (OrderType() == OP_BUY&&编码magic==OrderMagicNumber( )) gd_180 ++;
         if (OrderType() == OP_BUYSTOP&&编码magic==OrderMagicNumber( )) gd_181 ++;
         if (OrderType() == OP_BUYLIMIT&&编码magic==OrderMagicNumber( )) gd_182 ++;
      }
   }
 }
 double GetLots(int flag)
{
   double Lots ;
   Counts();
 
      if(flag==0)
      {
       
 
 switch(gd_182)
 {
 case 0:
 {
 Lots =下第1档手数 ;
 break;
 }
 case 1:
 {
 Lots =下第2档手数 ;break;
 }
 case 2:
 {
 Lots =下第3档手数 ;break;
 }
 case 3:
 {
 Lots =下第4档手数 ;break;
 }
 case 4:
 {
 Lots =下第5档手数 ;break;
 }
 case 5:
 {
 Lots =下第6档手数 ;break;
 }
 case 6:
 {
 Lots =下第7档手数 ;break;
 }
       
 }
 
 }
   if(flag==1) Lots = 第一单手数 ;
    
      if(Lots < 第一单手数) Lots = 第一单手数;
      if(Lots > MaxLots) Lots = MaxLots;
  
   return(Lots);
 }
 double GetLots1(int flag)
{
   double Lots = 第一单手数;
   Counts();
 
      switch(flag)
      {
         case 0:
         {
             switch(gd_181+1)
 {
 case 1:
 {
 Lots =上第1档手数 ;
 break;
 }
 case 2:
 {
 Lots =上第2档手数 ;break;
 }
 case 3:
 {
 Lots =上第3档手数 ;break;
 }
 case 4:
 {
 Lots =上第4档手数 ;break;
 }
 case 5:
 {
 Lots =上第5档手数 ;break;
 }
 case 6:
 {
 Lots =上第6档手数 ;break;
 }
 case 7:
 {
 Lots =上第7档手数 ;break;
 }
       
 }
           
            break;
            }
         case 1:
            Lots = 第一单手数 ;
            break;
      }
      if(Lots < 第一单手数) Lots = 第一单手数;
      if(Lots > MaxLots) Lots = MaxLots;
  
   return(Lots);
 }

如您喜欢此文章请点下面分享按钮↴峰汇在线 » MT4挂单脚本 挂买L单 BUYLIMIT BUYSTOP
上一篇:
下一篇:
分享到:更多 ()

评论 抢沙发

评论前必须登录!