[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 422

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
Good afternoon. My question is as follows. In the MQL4 book found at MQL4.community, in the "Standard Functions" section of the "String Functions and Data Conversion Functions" section, the following example of the strings.mq4 Expert Advisor is given (given in full from the book)
... continued...
At the end of subsection StringSubstr Function in brackets is the following phrase: "separately we must note that in the first for loop (my note: it must be deinit() as there is no other way to delete objects) we cannot delete objects since after every deletion the number of objects and their numbering will change and some object names will be skipped". But in the cited EA there is no second for loop at all. Moreover, the variable Quant_Del defined in deinit() function before the for loop is initialized with zero, while the variable i was not defined anywhere before the for loop.
it turns out that the above code just trivially omits several program lines.
So the 1st question is as follows: Was it really a trivial omission of several lines or is it such a tricky program that a novice cannot grasp its meaning without outside help?
Further... In the same chapter of the same section, there is a link to the same Expert Advisor (in the attached file) before the cited text that, when clicked, opens the same Expert Advisor in MetaElitor. But the text of this Expert Advisor is different: the deinit() function looks like this
Then, if "combine" the phrase "Separately, please note that you cannot delete objects in the first for loop, because in this case the total number of objects and their numbering will change after each deletion, and some object names will be skipped as a result" AND text deinit() function of the last variant, I have the 2nd question:
Question. Why cannot I delete objects in the first for loop by placing the ObjectDelete(Obj_Name) function inside the if statement...? Something like:
Why after each deletion "... The total number of objects will change"...? Because in this case, the Quant_Objects variable, which determines the total number of objects, gets its value equal to ObjectsTotal(), FORWARD the for loop?
P.S. Thanks in advance for the answer, in order not to litter the forum.
Good afternoon, I made a block to calculate magic buy open positions, but the problem is that if the block works on different currency pairs, then the block only produces results for one currency pair (the last open position). How can I fix the code (without changing the magic) so that the block gives results for each currency pair?
... continued...
At the end of subsection StringSubstr Function in brackets is the following phrase: "separately we must note that in the first for loop (my note: it must be deinit() as there is no other way to delete objects) we cannot delete objects since after every deletion the number of objects and their numbering will change and some object names will be skipped". But in the cited EA there is no second for loop at all. Moreover, the variable Quant_Del defined in the function deinit() before the for loop is initialized with zero, while the variable i was not defined anywhere before the for loop.
It turns out that the above code just trivially omits several program lines.
So the 1st question is as follows: Was it really a trivial omission of several lines or is it such a tricky program that a novice cannot grasp its meaning without outside help?
Further... In the same chapter of the same section, there is a link to the same Expert Advisor (in the attached file) before the cited text that, when clicked, opens the same Expert Advisor in MetaElitor. But the text of this Expert Advisor is different: the deinit()function here looks like this
Then, if "combine" the phrase "Separately, please note that you cannot delete objects in the first for loop, because in this case the total number of objects and their numbering will change after each deletion, and some object names will be skipped as a result" ANDtext deinit() function of the last variant, I have the 2nd question:
Question. Why cannot I delete objects in the first for loop by placing the ObjectDelete(Obj_Name) function inside the if statement?
Why after each deletion "... The total number of objects will change"...? Because in this case, the Quant_Objects variable, which determines the total number of objects, gets its value equal to ObjectsTotal(), FORWARD the for loop?
P.S. Thanks in advance for the answer, in order not to litter the forum.
Expand the loop backwards and delete as much as you can
Did I understand you correctly? You should think of the deinit function (and the loop in particular) as follows:
This data is needed to calculate the difference between buy and sell orders.
let's assume one buy order with the volume of 0.09 lots and two sell orders with the total volume of 0.11 lots were opened, the difference between them will be 0.09-0.11=-0.02, or if possible the difference between their values.
Well then the function OrderLots.
Good afternoon, I made a block to calculate magic buy open positions, but the problem is that if the block works on different currency pairs, then the block only produces results for one currency pair (the last open position). How can I fix the code (without changing magic) so the block will calculate for all currency pairs?
Change:
To:
How do I replace the stop loss in pips in the EA, with a stop loss above the last candle?