EA: SerialMA_EA

 

SerialMA_EA:

基于动态移动平均线的智能交易系统。


作者: Scriptor

 

//+------------------------------------------------------------------+
//| 返回交易环境的 "未定义 "状态
//+------------------------------------------------------------------+
bool IsUncertainStateEnv(const string symbol_name,const ulong magic_number)
  {
   if(MQLInfoInteger(MQL_TESTER)) return false;
   int total=OrdersTotal();
   for(int i=total-1; i>WRONG_VALUE; i--)
     {
      if(OrderGetTicket(i)==0) continue;
      if(OrderGetInteger(ORDER_TYPE)>ORDER_TYPE_SELL) continue;
      if(OrderGetInteger(ORDER_MAGIC)!=magic_number) continue;
      if(!OrderGetInteger(ORDER_POSITION_ID) && OrderGetString(ORDER_SYMBOL)==symbol_name)
         return true;
     }
   return false;
  }

//+------------------------------------------------------------------+
//|| 填充位置票数组|
//+------------------------------------------------------------------+
bool FillingListTickets(const uint number_of_attempts)
  {
//--- 检查环境状态
   int n=0,attempts=int(number_of_attempts<1 ? 1 : number_of_attempts);
   while(IsUncertainStateEnv(symb,InpMagic) && n<attempts && !IsStopped())
     {
      n++;
      Sleep(sleep);
     }
   if(n>=attempts && IsUncertainStateEnv(symb,InpMagic))
     {
      Print(__FUNCTION__,": Uncertain state of the environment. Please try again.");
      return false;
     }
//---

//+------------------------------------------------------------------+
//| 专家勾选功能|
//+------------------------------------------------------------------+
void OnTick()
  {
//--- 检查零价格
   if(!RefreshRates() || Point()==0) return;
//--- 填写项目票清单
   int positions_total=PositionsTotal();
   if(prev_total!=positions_total)
     {
      if(FillingListTickets(num_attempts))
         prev_total=positions_total;
      else return;
     }
[删除]  

如果不添加这一行,智能交易系统将无法运行

#include <Trade\SymbolInfo.mqh>

SerialMA_EA