Features of the mql5 language, subtleties and tricks - page 80

 
Vitaly Muzichenko:

I did it, it didn't show any bullshit. Confused by the fact that the shift should probably be -720

P.S. Again, I know that the shift +2 hours - written on the site, but the robot does not know.

No need to believe the sites. The actual shift is 3 hours.

The required result: "Find the current time server TimeServer ()" I did not get it right, maybe I'm doing it wrong.

// https://www.mql5.com/ru/docs/dateandtime/timetradeserver
datetime TimeTradeServer()
{
  return(TimeGMT() - TimeServerGMTOffset());
}
 
fxsaber:

You don't have to believe the websites. The actual shift is 3 hours.

I checked on 4 terminals and it is correct.


Thanks for your time!

 

Forum on trading, automated trading systems and testing trading strategies

Discussion of article "Cross-Platform Expert Advisor: Signals"

fxsaber, 2018.04.03 06:26

MQLInfoInteger(MQL_TESTER) || MQLInfoInteger(MQL_OPTIMIZATION) == MQLInfoInteger(MQL_TESTER)
 

Forum on trading, automated trading systems and testing trading strategies

Libraries: Symbol

fxsaber, 2018.04.06 08:20

If you need to change some properties of a custom symbol, in some cases you need to do it BEFORE importing quotes.

That's why I strongly recommend to set all properties of a symbol first, and only then perform import.

For example, if you want to setSYMBOL_TRADE_TICK_VALUE and SYMBOL_TRADE_TICK_SIZE, you should do it before importing ticks/bars.

 
// Копирование всех баров без обращения к торговому серверу
CopyRates(Symb, PERIOD_M1, 0, (int)SeriesInfoInteger(Symb, PERIOD_M1, SERIES_BARS_COUNT), Rates);
 
fxsaber:

Large arrays are nice, of course, but you have to remember that size matters.

 
Nikolai Semko:

Large arrays are certainly a good thing, but you have to keep that in mind.

It has nothing to do with this.

 
fxsaber:

This has nothing to do with it.

Who knows...
Because one element of MqlRates weighs 60 bytes.

Of course, if you're using just one array of 10000 elements, then it's fine.

But if you've got a bunch of similar arrays made of synthetic symbols, and each one is 100000 big, then expect a drastic (more than by an order of magnitude) decrease of access speed to array elements.

Keeping an eye on the optimization of array sizes won't hurt, and that's a good style. That's all. I just said that it's something to keep in mind.

 
Nikolai Semko:

Who knows...
One MqlRates element weighs 60 bytes.

Of course, if you're using just one array of 10000 elements, then it's fine.

But if you've got a bunch of similar arrays made of synthetic symbols, and each one is 100000 big, then expect a drastic (more than order of magnitude) decrease of speed.

Keeping an eye on array size optimization is a good style. That's all. I only said that you should keep it in mind.

That example wasn't about array sizes in any way. The point was not to request the history from the trade server and, therefore, get the bars that are already present in the Terminal as quickly as possible.

 
fxsaber:

This example does not refer to the size of arrays. The point was not to request the history from the trading server and, accordingly, to quickly get the bars that are already available in the terminal.

Yeah, I don't know what it was about.

I just saw your line of code, which would probably create an array larger than the CPU cache.

Reason: