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

 
fxsaber #:

I'm sure that, for example, GetMicrosecondCount can always be used to get guaranteed different values with any reasonable number of concurrently running programmes.

Careful, microseconds begin with program launch. Milliseconds begin with computer launch.
 
Dominik Egert #:
Careful, microseconds start by starting the programme. Milliseconds start with the start of the computer.

You can try to catch the same values in different programmes.

 
fxsaber #:

You can try to catch the same values in different programmes.

It'll be difficult to do on purpose. But if you rely on it being unique, you will encounter sooner or later occasionally the same value. Since this will be a "race condition", it gets very difficult to debug.

A better approach would be to actually use a UUID algorithm to increase the uniqueness.


 

Some near past the definition of anchor-points has changed. 

Is anyone able to help me decypher the meaning of this documentation, please:

https://www.mql5.com/en/book/applications/objects/objects_anchor


As far as I can see, it is now much more limited (and as my personal opinion weighs here, badly limiting possibilities) it seems, it is not clearly defined how to use what type of ENUM in what situations.

There are now two types of ENUMS, the original and a new version.  But the sample code isnt using them. How and in which sense are these two enums compatible to each other?

EDIT:

I personally find this to be much more confusing and limiting than required. - How do you put up a "Stop-Arrow" at the close price of a candle? - Its not possible anymore. This is usually considered to be a regression in functionality.

Also trying to calculate a proper offset to actually place the arrow at the "center" is impossible, because there is no way of determining the height. OBJPROP_WIDTH and OBJPROP_XSIZE both give NULL as result.

"A solution" is to use a textlabel and put in wingdings-font with the correct character-code to "emulate" the arrows drawn by the ObjectArrow type, this is not how this should be solved, as textlabels behave slightly different than arrows, and you cannot distinguish between an arrow and a textlabel anymore. - To accomplish this distinguation, you would need to hide some flag information within the alpha value of the color informaiton, but that is undocumented and prone to change behaviour. 


EDIT2:

OBJ_TEXT supports angle to rotate the displaying of the text on chart. - But the terminal is not able to render non-TTF-fonts properly when applying an angle to the textfield. The text wil lbe displayed outside of the expected textfield.

MQL5 Book: Creating application programs / Graphical objects / Defining anchor point on the object
MQL5 Book: Creating application programs / Graphical objects / Defining anchor point on the object
  • www.mql5.com
Some types of objects allow you to select an anchor point. The types that fall into this category include text label (OBJ_TEXT) and bitmap image...
 
Dominik Egert #:

This is not a bug as such, but a documented design change. MetaQuotes separated the concept of anchoring into two different enumerations:

  • ENUM_ANCHOR_POINT for text or bitmap objects (more flexible, with 9 possible positions).
  • ENUM_ARROW_ANCHOR for arrows, where anchoring is limited to TOP/BOTTOM or even fixed depending on the type of arrow (buy/sell/stop, etc.).

That is why it now seems more "limited": arrows are not intended for pixel-perfect control, but as quick graphic markers.

Properties such as OBJPROP_XSIZE or YSIZE are not supported in these objects, so you cannot calculate an offset to centre the icon exactly on the close.

If you need precision, the practical alternative is to use OBJ_LABEL or OBJ_BITMAP_LABEL with a font (e.g. Wingdings) or a custom bitmap. There you can control the anchor and, in some cases, the size.

In summary: Yes, it is a real limitation, but it is intentional and documented by MetaQuotes. For them, arrows are decorative elements with fixed logic, not freely positionable objects.

 
Miguel Angel Vico Alba #:

This is not a bug as such, but a documented design change. MetaQuotes separated the concept of anchoring into two different enumerations:

  • ENUM_ANCHOR_POINT for text or bitmap objects (more flexible, with 9 possible positions).
  • ENUM_ARROW_ANCHOR for arrows, where anchoring is limited to TOP/BOTTOM or even fixed depending on the type of arrow (buy/sell/stop, etc.).

That is why it now seems more "limited": arrows are not intended for pixel-perfect control, but as quick graphic markers.

Properties such as OBJPROP_XSIZE or YSIZE are not supported in these objects, so you cannot calculate an offset to centre the icon exactly on the close.

If you need precision, the practical alternative is to use OBJ_LABEL or OBJ_BITMAP_LABEL with a font (e.g. Wingdings) or a custom bitmap. There you can control the anchor and, in some cases, the size.

In summary: Yes, it is a real limitation, but it is intentional and documented by MetaQuotes. For them, arrows are decorative elements with fixed logic, not freely positionable objects.


I disagree. A regression it is. The documentation is incomplete and the behavior is more or less undefined, due to lack of proper documentation.

BTW, changes of such impact are always intentional, doesn't rectify the regression.

Edit: I haven't stated this to be a bug.
 
Dominik Egert #:

I disagree. This is a regression. Documentation is incomplete and behaviour is more or less uncertain due to lack of proper documentation.

BTW, changes of this kind are always intentional, it doesn't fix a regression.

It's been like this for years. Haven't seen any changes.

 
Artyom Trishkin #:

It's been like this for years. Haven't seen any changes.

It has changed, I am to lazy to figure when exactly, but 38xx had the old version.


EDIT: Sorry for the claim of it being changed in version 38xx, it is actually also already this way in version prior to 2000. - So I have actually missed it back then already. 

 
I have not found the iMAOnArray() function in the MQL5 Help. Is there a substitute for it?
 
Vitaly Murlenko #:
I have not found the iMAOnArray() function in the MQL5 Help. Is there a substitute for it?

No.

Check out my code that uses another coder's custom "iMaOnArray()" function as a substitute:

Code Base

Brooky Trend Strength for MT5

Ryan L Johnson, 2025.04.29 19:52

This indicator calls 3 other subwindow indicators. All files go in your Indicators folder.