OnTrade x OnTick | Dúvida Simples - página 2

 

Prezados,

Num outro fórum encontrei a seguinte proposta:


enum ENUM_MARKET_STATES {

   FECHADO = -1,

   SEM_CONEXAO = 0,

   ABERTO = 1

};

ENUM_MARKET_STATES Analyze::mercadoStatus(string ativo) {

   if (TerminalInfoInteger(TERMINAL_CONNECTED)) {   

      ENUM_TIMEFRAMES tempoGrafico = PERIOD_M1;

      datetime time[];

      CopyTime(ativo, tempoGrafico, 0, 1, time);

      int segundosRestantesDaBarra = ( (int)time[0]  - (int)TimeCurrent() + PeriodSeconds(tempoGrafico) );  

      if(segundosRestantesDaBarra < 0) {

         return FECHADO;

      } else {

         return ABERTO;

      }

   }    

   return SEM_CONEXAO;

}

Vou testar melhor.

Razão: