Especialistas: SerialMA_EA

 

SerialMA_EA:

EA com base numa média móvel dinâmica.


Autor: Scriptor

 

Muito bem!

//+------------------------------------------------------------------+
//| Retorna o estado "indefinido" do ambiente de negociação.
//+------------------------------------------------------------------+
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;
  }

//+------------------------------------------------------------------+
//|| Preenche as matrizes de bilhetes de posição|
//+------------------------------------------------------------------+
bool FillingListTickets(const uint number_of_attempts)
  {
//--- Verificando o estado do ambiente
   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;
     }
//---

//+------------------------------------------------------------------+
//| Função de tique de especialista|
//+------------------------------------------------------------------+
void OnTick()
  {
//--- Verificação de preços zero
   if(!RefreshRates() || Point()==0) return;
//--- Preenchimento de listas de tíquetes de itens
   int positions_total=PositionsTotal();
   if(prev_total!=positions_total)
     {
      if(FillingListTickets(num_attempts))
         prev_total=positions_total;
      else return;
     }
[Excluído]  

O Expert Advisor não funcionará se você não adicionar esta linha

#include <Trade\SymbolInfo.mqh>

SerialMA_EA