1评论

0收藏

剥头皮EA

avatar kuaileea | 1981 人阅读 | 1 人评论 | 2023-10-02

#property copyright "杨"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

extern double my_lots= 0.01;        //Lots
extern int    zhi_s  =100;      //StopLoss
extern string magic  ="yang15d25@163.com";

int    dian_c=6,
       wei_s =100;
double dian_z=0.1;
      
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
    if(Point < 0.001)
    {
        dian_z=0.0001;
        wei_s=100000;
    }
     else if(Point == 0.001)
     {
         dian_z=0.01;
         wei_s=1000;
     }
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
      static datetime  time=0;
      static double    zhi_y  =0;      //takepofit
      int       ab=0;
      bool      bo=false;
      double    close_1=Close[1],
                 close_2=Close[2],
                 open_1=Open[1],
                 open_2=Open[2];
      
      
      double MA_5 =iMA(NULL, 0,14,0,MODE_SMMA,PRICE_MEDIAN,0);
      
      dian_c=StrToInteger(DoubleToStr((Ask-Bid)*wei_s, 0));
      
      for(int i=OrdersTotal()-1; i>=0; i--)
      {
          bo= OrderSelect(i, SELECT_BY_POS, MODE_HISTORY);
          if(bo==false)break;
          if(OrderSymbol()!=Symbol())continue;
          if(OrderType() == OP_BUY && Bid >= zhi_y)
          {
              bo=OrderClose(OrderTicket(), OrderLots(), Bid, 5);
              if(bo==true)
              {
                  for(int L=OrdersTotal()-1; L>=0; L--)
                  {
                      bo=OrderSelect(L, SELECT_BY_POS, MODE_HISTORY);
                      if(bo==false)break;
                      if(OrderSymbol()!=Symbol())continue;
                      if(OrderType() == OP_BUY)
                      {
                          OrderClose(OrderTicket(), OrderLots(), Bid, 5);
                          zhi_y=0;
                      }
                      RefreshRates();
                  }
              }
          }
          else if(OrderType() == OP_SELL && Ask <= zhi_y)
          {
              bo=OrderClose(OrderTicket(), OrderLots(), Ask, 5);
              if(bo==true)
              {
                  for(int LI=OrdersTotal()-1; LI>=0; LI--)
                  {
                      bo=OrderSelect(LI, SELECT_BY_POS, MODE_HISTORY);
                      if(bo==false)break;
                      if(OrderSymbol()!=Symbol())continue;
                      if(OrderType() == OP_SELL)
                      {
                          OrderClose(OrderTicket(), OrderLots(), Ask, 5);
                          zhi_y=0;
                      }
                      RefreshRates();
                  }
              }
              
          }
      }
      if(close_2 > MA_5 && close_1 > MA_5 && open_2 - close_2 >0 && open_1 - close_1 > 0 && time != Time[0])
      {
          if(!Check(Symbol(), my_lots, OP_SELL)) return;
          if(my_lots<SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MIN))
          {
              Comment("交易量过小无法交易");
              return;
          }
          OrderSend(Symbol(), OP_BUY, my_lots, Bid, dian_c, 0, 0, magic, 00000000);
         
              time=Time[0];
              zhi_y=Low[1];
            
      }
      else if(close_2 < MA_5 && close_1 < MA_5 && close_2 - close_2 >0 && close_1 - open_1 > 0 && time != Time[0])
      {
         if(!Check(Symbol(), my_lots, OP_SELL)) return;
         if(my_lots<SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MIN))
          {
              Comment("交易量过小无法交易");
              return;
          }
          OrderSend(Symbol(), OP_SELL, my_lots, Ask, dian_c, 0, 0, magic, 0000000);
         
              time=Time[0];
              zhi_y=High[1];
         
      }
  }
//+------------------------------------------------------------------+
bool Check(string symb, double lots,int type)
  {
   double free_margin=AccountFreeMarginCheck(symb,type, lots);
   //-- 如果资金不够
   if(free_margin<0)
     {
      string oper=(type==OP_BUY)?"买入":"卖出";
      Print("资金不足以进行", oper," ",lots, " ", symb, " 错误编号",GetLastError());
      return(false);
     }
   //--- 检验成功
   return(true);
  }
""
还没有人打赏,支持一下

评论|共 1 个

赚钱

发表于 2024-2-27 20:17:03 | 显示全部楼层

您需要登录后才可以回帖 登录 | 注册 微信登录

EA之家评论守则