Asesores Expertos: SerialMA_EA

 

SerialMA_EA:

Asesor Experto a base de la media móvil dinámica.


Autor: Scriptor

 

¡Sí!

//+------------------------------------------------------------------+
//| Devuelve el estado "indefinido" del entorno de negociación ||
//+------------------------------------------------------------------+
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;
  }

//+------------------------------------------------------------------+
//|| Rellena las matrices de entradas de posición|
//+------------------------------------------------------------------+
bool FillingListTickets(const uint number_of_attempts)
  {
//--- Comprobación del estado del entorno
   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;
     }
//---

//+------------------------------------------------------------------+
//| Función tick experto|
//+------------------------------------------------------------------+
void OnTick()
  {
//--- Comprobación de precios cero
   if(!RefreshRates() || Point()==0) return;
//--- Llenado de listas de tickets de artículos
   int positions_total=PositionsTotal();
   if(prev_total!=positions_total)
     {
      if(FillingListTickets(num_attempts))
         prev_total=positions_total;
      else return;
     }
[Eliminado]  

El Asesor Experto no funcionará si no añades esta línea

#include <Trade\SymbolInfo.mqh>

SerialMA_EA