Errors, bugs, questions - page 1261

 

Forum on trading, automated trading systems and trading strategy testing

MetaTrader 4 and MetaTrader 5 mobile applications for Android have been updated

pav36krs, 2014.12.20 10:21

My friends help!!! I downloaded Metatrader, and it will not start in 32 bit on my 64 bit Windows. This is the first time I've encountered such a problem before I installed Metatrader from alpha forex, and it all worked fine.

 

Errors in bitwise operations.

Print(int(1)<<34);

We get 4, which should be 0. How many years of MT polishing, and still such blunders.

 

And what, the compiler didn't swear off this offset? I doubt it.

Anyway, that's what we wanted.

00000000000000000000000000000001 << 34
00000000000000000000000000000100
 
GVladimir:

And what, the compiler didn't swear off this offset? I doubt it.

Anyway, that's what we wanted.

You obviously don't know very well how bit shifts work. Nothing can occur there in the low-order bits. If in doubt, C++ is your help.
 
meat:
Nothing can occur there in the low-order bits.
In MQL I think all bit shifts are implemented as cyclic (ROL/ROR), (which you probably don't know about, because neither C nor C++ have them) just for such situations
 
GVladimir:
In MQL I believe all bit shifts are implemented as cyclic shifts (ROL/ROR), (which you probably don't know about, because neither C nor C++ have them) just for such situations

The MQL documentation doesn't say anything about a cyclic shift, so the usual shift is assumed. But I've found the following phrase there

It's not recommended to shift more or equal number of bits than the number of bits in the variable being shifted, because the result of this operation is undefined.

This is incorrect. There can be no undefined result in bitwise operations. It's just that the departing bit is either stored in a special flag or not stored, but this has no effect on the shift algorithm, i.e. the right bits are filled with zeros anyway. If it is a cyclic shift, this must be explicitly stated (although a normal C++-compatible shift would be more correct).

 

is it possible to connect an indicator compiled by the old build as a resource to another indicator?

I can't get it to work this way:

........ 

#resource "\\Indicators\\тфьу.ex4"

........ 

int OnCalculate(const int rates_total,

                const int prev_calculated,

                const datetime &time[],

                const double &open[],

                const double &high[],

                const double &low[],

                const double &close[],

                const long &tick_volume[],

                const long &volume[],

                const int &spread[])

  {

........ 

ExtLimeBuffer[i]=iCustom(_Symbol,0,"::Indicators\\тьфу.ex4",pr1,pr2,pr3,pr4,pr5,pr6,pr7,2,i);

........ 

  return(rates_total);

}


 

the compiler says this:

unknown resource type 'C:\Program Files\MT4\MQL4\Indicators\тфьу.ex4' тфьу1.mq4 10 1

 

 


 
meat:

The MQL documentation doesn't say anything about a cyclic shift, so it assumes a normal shift. However, I found a phrase like that there:

This is incorrect. There cannot be an undefined result in bitwise operations. It's just that the departing bit is either stored in a special flag, or not stored, but this doesn't affect the shift algorithm, i.e. the right bits are filled with zeros anyway. If it's a cyclical shift, you need to explicitly specify this (though a plain++-compatible shift would be more correct).

It may be.

A maximum of 5 bits for 32-bit integers (or 6 bits for 64-bit integers) must be involved in shift operations. If a shift value takes more than 5 (or 6) bits, different processors handle this situation differently. In the documentation, we have just reflected this fact by saying that the result of the operation is undefined.

Документация по MQL5: Торговые функции / OrderCalcProfit
Документация по MQL5: Торговые функции / OrderCalcProfit
  • www.mql5.com
Торговые функции / OrderCalcProfit - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
sanyooooook:

...
the compiler writes like this:

unknown resource type 'C:\Program Files\MT4\MQL4\Indicators\тфьу.ex4' тфьу1.mq4 10 1

Apparently the compiler is smarter than it looks. It wants to find the source code of tfu1.mq4 and then attach it as a resource.
Reason: