Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1374
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Somebody taught you badly. The _LastError variable will store the value until the next error occurs.
Well, look, at the beginning of the main code the following error occurs
ERR_INVALID_DATETIME
4010
Incorrect date and/or time value
And then an object is created by the code and _LastError is rewritten to
ERR_OBJECT_NOT_FOUND
4202
Graphic object not found
If the _LastError check is at the end of the code, as I usually do, I will get 4202 and just ignore it. That is, error 4010 will remain unnoticed. Where am I wrong?
It is a requirement of the marketplace that no execution errors are received from the broker's server\dc.
Thanks, didn't know that, thought all errors were forbidden.
Well, look, at the beginning of the main code, for example, the following error occurs:
ERR_INVALID_DATETIME
4010
Incorrect date and/or time value
And then an object is created by the code and _LastError is rewritten to
ERR_OBJECT_NOT_FOUND
4202
Graphic object not found
If the _LastError check is at the end of the code, as I usually do, I will get 4202 and just ignore it. That is, error 4010 will remain unnoticed. Where am I going wrong?
Thanks, didn't know that, thought all errors are forbidden.
Exactly. You're not wrong...
Hello, can anyone give me a hint.
I'm writing the time values of each bar specifically into an array. There is a limit of 3000 bars on the chart.
The task:
- To shift the array of values at each new bar.
I cannot adjust it to work properly.
Am I correctly shifting the array on a new bar if (this.m_rt-this.m_pc)=1?
Hello, can anyone give me a hint.
I'm writing the time values of each bar specifically into an array. There is a limit of 3000 bars on the chart.
The task:
- To shift the array of values at each new bar.
I cannot adjust it to work properly.
Am I right to shift the array on a new bar if (this.m_rt-this.m_pc)=1?
I.e. the size of array must be exactly 3000 and at formation of a new bar the zero index should be overwritten first ......... and in the end write new value?
If I understood correctly, what's the point of the loop? Just copy the array itself into the null index starting from the first one, and then write the new value into the last index.
If no object is found, this is the object search error...
ERR_OBJECT_NOT_FOUND
4202
Graphic object not found
No need to alerter it...
Did a couple of tests... Here's what happens. In MQL5, it is not necessary to use ObjectFind() when creating objects.
The object may be created without any preliminary check of its existence (just using ObjectCreate). Even inside the OnTick such code will not cause any _LastError errors.
I do not know how it is implemented in the depths of MQL5 system code, perhaps there is some check already uploaded there that the object will be created only if it is not yet present. But it turns out that at least when creating an object inside MQL5, ObjectFind() is not needed. And all its properties are invariably updated at every tick.
This cannot be said about MQL4. The creation of an object over an existing one will cause a 4200 ("The object already exists")error. It means that the use ofObjectFind() is obligatory for its creation.This leaves me with a simple possibility to close its properties from constant updates without generating _LastError errors.
Please confirm my conclusions.
I.e. the size of the array should be exactly 3000 and when a new bar is formed, the zero index should be overwritten first ......... and the new value should be added to the end?
If I understood correctly, why do I need a loop? Simply, the array itself should be copied into the null index starting from the first one, and then the new value should be appended to the last index.
Well, yes, it's clear, but if there is a break, for example, a delay, two bars appeared, I'm writing them down.
Thanks a lot, I understand, I will try through CopyTime.
Did a couple of tests... Here's what happens. In MQL5, it is not necessary to use ObjectFind() when creating objects.
The object can be created without any preliminary check of its existence (just using ObjectCreate). Even inside the OnTick code this code will not cause any _LastError errors.
I do not know how it is implemented in the depths of MQL5 system code, perhaps there is some check already uploaded there that the object will be created only if it is not yet present. But it turns out that at least when creating an object inside MQL5, ObjectFind() is not needed. And all its properties are invariably updated at every tick.
This cannot be said about MQL4. The creation of an object over an existing one will cause a 4200 ("The object already exists")error. It means that the use ofObjectFind() is obligatory for its creation.This leaves me with a simple possibility to close its properties from constant updates without generating _LastError errors.
Please confirm my conclusions.
Well yes it seems clear, but if there is a break, e.g. delay, two bars appeared, I write them down.
Thank you, I understand, I'll try through CopyTime.
Well, if you do it via CopyTime, there's no problem at all. Just copy from the current 3000 bars and that's it.
How do I set the level of the regular trailing stop in the program code when placing a pending order or opening a position from the market?
How this is done manually is clear. Programs for non-standard trailing stops are not interesting.
Thank you in advance.
Why doesn't such a design work? Where is the error... (the log is empty)
And the log is empty.