int MA_Period = 15, Count = 5, symbolCount; string symbolsList[]; struct SATR { int handle; double buffer[]; } atr[]; void OnInit() { symbolCount=SymbolsTotal(true); if( ArrayResize(symbolsList, symbolCount) < symbolCount ) ExpertRemove(); if( ArrayResize(atr, symbolCount) < symbolCount ) ExpertRemove(); for(int i=0;i<symbolCount;i++) { symbolsList[i] = SymbolName(i,true); atr[i].handle = iATR(symbolsList[i],PERIOD_D1,MA_Period); ArraySetAsSeries(atr[i].buffer,true); } } void OnTick() { for (int i=0; i<symbolCount; i++) { if( CopyBuffer(atr[i].handle,0,0,Count,atr[i].buffer) < Count ) continue; for( int j=0;j<Count;j++ ) Print(atr[i].buffer[j]); // Print the value of the ATR } }
Konstantin Nikitin:
Thanks appreciate the help. The code won't execute past the CopyBuffer() line. Do I need to force the load of historical data somehow?
Franco:
Do I need to force the load of historical data somehow?
https://www.mql5.com/en/docs/series/timeseries_access
Look for the function CheckLoadHistory()
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
It's been a while, but I'm back trading again. There is something that I need to get done before I can start. I need to calculate indicator values for every symbol that is loaded. My code currently looks as follows to calculate the ATR< however the ATR CopyBuffer returns -1. Any idea what I'm doing wrong?
Is it possible to do this for 500 symbols? Can MT5 handle it?