how to stop waiting for a handle when I invoke an indicator

SDMInvest  

I have created an expert advisor that searches, within all the symbols offered by the broker, which symbols in a specific timeframe satisfy certain requirements given by the values of several indicators.

Everything works well only that sometimes the call to get the handle takes a long time (I assume for the lack of data on the broker's server as the reference market of the symbol, typically a stock, is closed).

Is there a way to limit the waiting time and then generate an exception that allows me to discard the symbol and move on to the next one?

Below is the piece of code under observation (in this example I need only three values of simple moving average of the symbol):

double aSMA[];

ArraySetAsSeries(aSMA,true);

int    hSMA = iMA(Sym,iTimeFrame,SlowAveragePeriods,0,SlowAverageType,PRICE_CLOSE);

if(hSMA==INVALID_HANDLE) 

{ 

   //--- do something 

   GetLastError();

   return; 

} 

CopyBuffer(hSMA,0,0,3,aSMA);
William Roeder  

Perhaps you should read the manual, especially the examples.
   How To Ask Questions The Smart Way. (2004)
      How To Interpret Answers.
         RTFM and STFW: How To Tell You've Seriously Screwed Up.

They all (including iCustom) return a handle (an int). You get that in OnInit. In OnTick/OnCalculate (after the indicator has updated its buffers), you use the handle, shift and count to get the data.
          Technical Indicators - Reference on algorithmic/automated trading language for MetaTrader 5
          Timeseries and Indicators Access / CopyBuffer - Reference on algorithmic/automated trading language for MetaTrader 5
          How to start with MQL5 - General - MQL5 programming forum - Page 3 #22 (2020)
          How to start with MQL5 - MetaTrader 5 - General - MQL5 programming forum - Page 7 #61 (2020)
          How to call indicators in MQL5 - MQL5 Articles (2010)

SDMInvest  
William Roeder #:

Perhaps you should read the manual, especially the examples.
   How To Ask Questions The Smart Way. (2004)
      How To Interpret Answers.
         RTFM and STFW: How To Tell You've Seriously Screwed Up.

They all (including iCustom) return a handle (an int). You get that in OnInit. In OnTick/OnCalculate (after the indicator has updated its buffers), you use the handle, shift and count to get the data.
          Technical Indicators - Reference on algorithmic/automated trading language for MetaTrader 5
          Timeseries and Indicators Access / CopyBuffer - Reference on algorithmic/automated trading language for MetaTrader 5
          How to start with MQL5 - General - MQL5 programming forum - Page 3 #22 (2020)
          How to start with MQL5 - MetaTrader 5 - General - MQL5 programming forum - Page 7 #61 (2020)
          How to call indicators in MQL5 - MQL5 Articles (2010)

Strange, but in this forum, every time I ask a question I get ironic and out of place answers. If I wrote that I search within the symbols offered by the broker it means that I do not have to query the data of only the symbol of the chart and therefore I have to release the data (their pointer) and initialize it again in order to obtain the data of the next symbol. But the problem is not here. The problem was: how to set, if it was expected, a timeout to wait after requesting a handle to the data to be able to abort the request and move on to the next symbol.
Questions that can be answered by the entire developer community. Those who feel like gurus and do not want to provide answers but only make their knowledge weigh without sharing it are asked to refrain. Thank you.
Carl Schreiber  
SDMInvest:

I have created an expert advisor that searches, within all the symbols offered by the broker, which symbols in a specific timeframe satisfy certain requirements given by the values of several indicators.

Everything works well only that sometimes the call to get the handle takes a long time (I assume for the lack of data on the broker's server as the reference market of the symbol, typically a stock, is closed).

Is there a way to limit the waiting time and then generate an exception that allows me to discard the symbol and move on to the next one?

Below is the piece of code under observation (in this example I need only three values of simple moving average of the symbol):

The number of handle is limited. Maybe you have to release the indicators when you move to the next symbol. If your EA invokes a new handle the indicator has to be calculated (for the numbers of bars of the chart I guess) this might take a while.

William Roeder  
SDMInvest #: Strange, but in this forum, every time I ask a question I get ironic and out of place answers.

Perhaps it is how you ask your questions.
     How To Ask Questions The Smart Way. (2004)
          Be precise and informative about your problem

Your code certainly is not waiting for the newly created handle to update. And therefor is wrong.

Your code also doesn't synchronize the other symbols. And therefor is wrong.

Reason: