Errors, bugs, questions - page 1658

 
Alexey Volchanskiy:

Regardless of the question, calling any function is always slower than accessing a variable on the stack, in this case nType.

Regardless of this obviousness, the question was about inline functions. I.e. is OrderType() not replaced at compile time by something like order.type.

Personally I always cache such MQLfunction calls, as in your second case.

As measurements have shown, it's unnecessary.

 
Sergei Vladimirov:

Regardless of this obviousness, the question was about inline functions. I.e. is OrderType() not replaced by something like order.type when compiling.

As measurements have shown, this is unnecessary.

Judging by internal implementation of arrays, the same ArraySize must be inline. But I always use it this way (I haven't measured it)

Instead of

for (int i = 0; i < ArraySize(Array); i++)

I use

const int Amount = ArraySize(Array);

for (int i = 0; i < Amount; i++)
In terms of performance, I was recently surprised by this fact

Forum on trading, automated trading systems & strategy testing

How do I go through an enumeration consistently?

fxsaber, 2016.08.22 09:13

Added static to the array. It's almost three times faster than switch! Trash such a switch. Thanks for the tip!
So, it seems it's better not to rely on the compiler's optimization, but always "help" it through the smallest function calls and use everywhere possible and logically const and static.
 
Sergei Vladimirov:

Regardless of this obviousness, the question was about inline functions. I.e. is OrderType() not replaced by something like order.type when compiling.

As the measurements showed, it's unnecessary.

You wrote it yourself:

Sergei Vladimirov2016.09.01 02:53 RU

Checked it myself. The second code runs 4 times faster. It's all clear, the question is off the table.

 
Sergei Vladimirov:
Tested it myself. The second code runs four times faster. All is clear, the question is removed.
Don't measure only in profiling/debug mode. There is no inline there at all. Only Release-version should be there.
 
Inv Андрей Иващенко:

Good afternoon!

Gentlemen officers, can you tell me where to start catching a bug?

Multicurrency Expert Advisor. After the first trade the tester stops.

Gives out an error, the code of which I can't find.

Yes, tester works fine from start date 2016.05.01. If I change this date - tester stops and error, log below.

Help please!

Reply to myself:

This is a bug in the tester. For now you need to add the handle of any technical indicator in OnInit to all symbols, on which the Expert Advisor works.

 
Alexey Volchanskiy:

You wrote it yourself:

Sergei Vladimirov2016.09.01 02:53 RU

Checked it myself. The second code runs 4 times faster. It's all clear, the question is off the table.

In the next comment I wrote figures: the gain with a single operation is 1 nanosecond. When optimising a strategy by ticks on a two-year stretch and several thousand runs, saving one ns might make sense. But in real trading...
 
A100:

In build 1398 the error 'EX5 loading failed' is still there (apparently not related to that example).

In fixed build 1400 error in similar case is now reproduced as 'pure virtual function call'. And without a comment it's fine

//Script1.mq5
typedef void (*fn)();
#import "Script2.ex5"
        void g( fn );
#import
void h() /*export*/ {} //если export без комментария - нормально
void OnStart() { g( h ); }
//Script2.mq5
#property library
typedef void (*fn)();
void g( fn f ) export { f(); }
 

Cannot be applied :: to resolve ambiguity


#import "Script1.ex5"
        void g();
#import "Script2.ex5"
        void g();
#import
typedef void (*fn)();
void OnStart()
{
        Script1::g(); //нормально
        Script2::g(); //нормально
        fn f = Script1::g; //Error
}
 
Inv Андрей Иващенко:

Answer to myself:

This is a bug in the tester. For now you need to add a handle of any technical indicator in OnInit to all symbols, on which the Expert Advisor works.

And it seems that the problem occurs when getting only the first tick on a new bar, the tester seems to "get stuck" and lags 1 bar behind, that is, the EA thinks that the bar does not exist and in visualization it really does not, but after a couple of seconds the bar appears, in the case of testing on M1 the correct value comes on the second tick (if I understand correctly), I hope the developers will fix this annoying moment as soon as possible ...

addition:

it turns out that to circumvent this moment now you have to artificially skip the first tick of a new bar...

 
Unable to make debugging of EA on RTS-9.16 BCS-MetaTrader5 by CTRL+F5. The tester writes
Tester  Leverage 1:1 set error

Reason: