MT5 and speed in action - page 88

 
fxsaber:

One is enough.

int CTickSeriesCollection::IndexTickSeries(const string symbol)
  {
   const CTickSeries *obj=new CTickSeries(symbol==NULL || symbol=="" ? ::Symbol() : symbol);
   ...
   ...
   ...
  }

Additionally I check for "". I myself always use NULL when calling methods for the current character.

 
Artyom Trishkin:

Your code will not give acceleration.

 
fxsaber:
It is hard for me to explain obvious things. It is possible to speed up GetMarketWatchTick in this code.
const MqlTick GetMarketWatchTick( const string &Symb )
{
  MqlTick Tick = {0};

  SymbolInfoTick(Symb, Tick);

  return(Tick);
}

void OnTick()
{
  MqlTick Ticks[1];
  
  Ticks[0] = GetMarketWatchTick(_Symbol);
  ArrayPrint(Ticks);
}

Do you think that even if _Symbol is passed as Symbol parameter, a string will be passed to SymbolInfoTick()?

I don't think there are no checks inside standard functions for string equality to the current symbol, and such explicit parameters start checking "full speed" if a cache for the current symbol is at hand.

 

The acceleration takes place at compile time, not at runtime.

The compiler makes this substitution:

SymbolInfoTick(_Symbol, Tick) -> SymbolInfoTickInside(Tick);
SymbolInfoTick(NULL, Tick) -> SymbolInfoTickInside(Tick);
SymbolInfoTick(::Symbol(), Tick) -> SymbolInfoTickInside(Tick);

In all other cases, no substitution is made.

 
fxsaber:

The acceleration takes place at compile time, not at runtime.

The compiler makes this substitution:

In all other cases, no substitution is made.

Well. That's what I'm talking about - your code will NOT speed up the regular function for the NOT current character. Nor will it speed up the current character.

And mine won't. And it never has. I had no illusions about it either. But I always use Symbol() or NULL when calling regular functions if my function is passed NULL or "". This calls a fast code of regular function - where data is taken from cache for current symbol.
If my function call uses Symbol() or _Symbol - is it NOT checked inside standard function if it coincides with current symbol? Will it really execute the code with full-range checks of the current symbol? I cannot believe it...

 
Artyom Trishkin:

Well. That's what I'm talking about - your code will NOT speed up the regular function for the NOT current character. Nor will it speed up the current character.

Perhaps someone can explain it to you more clearly. It didn't work for me.

 
fxsaber:

Perhaps someone can explain it to you more clearly. I didn't get it.

What are you witchcrafting to speed up the regular functions?

You are using substitution of the value of the current character when you pass it to the staff function to make it use the data for the current character from the cache. This does NOT speed up the normal function, it uses its speed for the current character.

You CANNOT speed up something you do not have access to the source of. You are using the standard technique to call the function correctly. But I'm not sure, if Symbol is specified by string as "EURUSD" when working on EURUSD, i.e. it's using the current symbol, then the staff function won't check if the string "EURUSD" is equal to Symbol() and won't use data from cache, but will start checking the symbol at full speed.

So, where is the acceleration of the regular function? If it exists, it is more than interesting and useful.

 
fxsaber:

Is it the same in MT4? And in MT5-Tester how is it?

Is it the same with CopyTicks?

 
fxsaber:

Perhaps someone can explain it to you more clearly. I didn't get it.

It is more likely that you have failed to understand my question. I repeated it several times (and this question was NOT about "speeding up the regular function").

 
Slava:

If a normal string parameter is specified instead of Symbol(), _Symbol or NULL, then full checks are performed and properties are queried as well.

For some reason, this explanation does not say that if the string parameter is the same as the current character, then no checks are made against the full program.

Reason: