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

 
fxsaber:

The need arises to transfer by reference without modification - for speed, or the object.

If there is no need to pass it for modification, then you can just ignore everything I've written.)

Do you have a real example in MQL5 when this problem occurs?

The real example of convenience is not enough.

I seem to have described everything in detail, both in words and in codes. If it seems incomprehensible to you for some reason, then obviously you do not face the described problems, and I congratulate you on that. ) Sleep well, dear fellow.

My post was probably aimed more at hardcore templators, as well as lovers of boring type controls.

 
Alexey Navoykov:

It is often necessary to pass some variable as a template argument by reference to modify it. But the existing C++ template specification, unfortunately, does not allow to specify the non-constancy of the argument explicitly, as it happens in usual functions:

First, C++ just has much richer template possibilities, and second, C++ has SFINAE, which allows you to make things so messy that they make your hair stand on end.

That's what it may look like:

template<class T>
    static void const_check(T & t){
        BOOST_STATIC_ASSERT(! boost::is_const<T>::value);
    }
but in general it's the same as with a pointer. you can't directly set that the type you want should not be a pointer, but you can do it through non-compiled specialization.
 
TheXpert:

this may look like this

As far as I understand, it causes a compilation error in the function body (which can be called anyway), but the process of template selection is not affected. The manipulation of the return type of the function value is required. Anyway, never mind. But all this is implemented there not only through templates, but also through the decltype specifier, which is absent in MQL and should be used.

 
Alexey Navoykov:

My post was probably aimed more at hardcore templators, as well as nerdy type control lovers.

I thought that after writing TypeToBytes I became more competent in templates.

 
fxsaber:

I thought that after writing TypeToBytes I became more competent in templates.

I realized now that the phrase "hardcore pattern maker" in relation to MQL sounds ironic. It's like a "certified MQL programmer". ))

There is nothing especially complicated to do on templates, not only because of the lack of additional functionality of the language, but also because of the incorrect operation of the existing one. Constantly bumping into bugs.

 

Forum on trading, automated trading systems and trading strategies testing

Bugs, bugs, questions

Slava, 2018.09.19 06:37

To place an object above all others, regardless of the order, you must first make it invisible on all timeframes, and then return visibility back
 

Good afternoon!

The documentation explicitly states that while the OnTickhandler is running https://www.mql5.com/ru/docs/runtime/event_fire#newtick

handler is not processing new incoming ticks. Is the same true forOnBookEvent, OnTimer, OnChartEventhandlers or not.

The question is caused by the fact that in all of the above handlers I use my own tick handling.

Документация по MQL5: Программы MQL5 / События клиентского терминала
Документация по MQL5: Программы MQL5 / События клиентского терминала
  • www.mql5.com
Сразу же после того, как клиентский терминал загрузит программу (эксперт или пользовательский индикатор) и запустит процесс инициализации глобальных переменных, будет послано событие Init, которое обрабатывается функцией OnInit(), если она есть. Это событие также генерируется после смены финансового инструмента и/или периода графика, после...
 
Andrey Kotrin:

Good afternoon!

The documentation explicitly states that while the OnTickhandler is running https://www.mql5.com/ru/docs/runtime/event_fire#newtick

Is the same true for OnBookEvent, OnTimer, OnChartEvent handlers or not.

The question is caused by the fact that in all of the listed handlers I use my own tick handler.

Not exactly correct.

Forum on trading, automated trading systems and strategy testing

Libraries: HistoryTicks

fxsaber, 2018.04.10 17:53

Combat EA on high frequency symbol (200-350 ticks per minute) with frequent trade orders (several times per minute) and 100 ms ping in standard mode loses ~5% ticks.

In HistoryTicks mode there are no losses.


You can easily use multicurrency OnTick in MT5.

 
fxsaber:

Definitely not correct.


SZY You can safely use multicurrency OnTick under MT5Z

Thanks for the link! The problem is not in the loss of ticks, but in possible partial update of information when processing the current one. I had a similar problem when organizing trading robots that simultaneously trade

Since the robot is oriented on a real server itis impossible touse third-party dll, and therefore mutex, so I used GlobalVariableSetOnCondition emulation.

 
Andrey Kotrin:

Thanks for the link! Actually the problem is not in the loss of ticks, but in possible partial updating of information when processing the current one. I had a similar problem when organizing communication between robots simultaneously trading

Since my robot is used in a web-hosting system anddoes not allowto use third-party dlls and therefore mutex, I used GlobalVariableSetOnCondition emulation.

Maybe you will be good to use Resources for data transfer.

Reason: