How objects work

 

hello


i would like to know why we use ObjectsTotal(0)-1 when we loop objects instead of only Objects Total(0)


and what is the function of _FUNCTION_ when printing error?



Please

 
shelvio massaete:

hello


i would like to know why we use ObjectsTotal(0)-1 when we loop objects instead of only Objects Total(0)


and what is the function of _FUNCTION_ when printing error?



Please

__FUNCTION__ Is a predefined macro, it prints the function name where it is located in.

Same goes for __LINE__ and __FILE__ and __FUNCSIG__

EDIT:

the macros don't print, they hold the information as a const string r-value.

You can assign it to a string variable.
 
shelvio massaete:

hello


i would like to know why we use ObjectsTotal(0)-1 when we loop objects instead of only Objects Total(0)


and what is the function of _FUNCTION_ when printing error?



Please

ObjectsTotal depends on the context, please show code you are referring to.
 
shelvio massaete: i would like to know why we use ObjectsTotal(0)-1 when we loop objects instead of only Objects Total(0)
If you have n objects, their indexes are [0 … n-1]
 
shelvio massaete:

hello


i would like to know why we use ObjectsTotal(0)-1 when we loop objects instead of only Objects Total(0)


and what is the function of _FUNCTION_ when printing error?



Please

For you as a newbie you might read this:

    If you place the cursor on an MQL function (e.g. __FUNCTION__) and press F1, you will see the reference directly, many with examples to copy and paste - the fastest form to code.
    https://www.mql5.com/en/articles/496
    https://www.mql5.com/en/articles/100
    and for debugging: https://www.metatrader5.com/en/metaeditor/help/development/debug
    https://www.mql5.com/en/search#!keyword=cookbook
    "Bear in mind there's virtually nothing that hasn't already been programmed for MT4/MT5 and is ready for you - so searching gives better results than AI or ChatGPT!" (Carl Schreiber):
    => Search in the articles: https://www.mql5.com/en/articles
    => Search in the codebase: https://www.mql5.com/en/code
    => Search in general: https://www.mql5.com/en/search or via Google with: "site:mql5.com .." (forgives misspelling)
Quick Start: Short Guide for Beginners
Quick Start: Short Guide for Beginners
  • www.mql5.com
Hello dear reader! In this article, I will try to explain and show you how you can easily and quickly get the hang of the principles of creating Expert Advisors, working with indicators, etc. It is beginner-oriented and will not feature any difficult or abstruse examples.