Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1581
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
Tell me, what is the += operator for? After all, there is zero in the array... Therefore, a simple assignment operator = is enough here.
Tell me, what is the += operator for? After all, there is zero in the array... Therefore, a simple assignment operator = is enough here
I typed it on the site, and then I couldn't edit it. You need to sleep at night, not to suffer with codes :)
Since the indices on which the value of an element changes do not have a simple dependence (like every next element is 7 greater than the previous one), it is necessary to have them in the code. The multiplier by which R is multiplied is an arithmetic progression with a step of 1. Therefore, we can implement that code approximately like this:
Note that for i < 10 and i < 18 the multiplier does not change, so the number 10 is not included in the bounds array of index bounds.
If the multipliers can change in different ways, they can also be organised as an array:
One more thing like this. The array initialisation string is of the following form:
is guaranteed to initialise only the first element of the array with zero. Try executing this code:
and you will see in the output:
For full initialisation, you must either list all 100 values for an array of 100 elements in parentheses, or use the ArrayInitialize() function, for example.
But in your task, you don't need to initialise the array because you are not modifying the existing initial values, but assigning new ones each time.
Thank you!
I will take the second option.
Add one more loop with 7 and a check for R. Write indexing for R. Even without it, the code is disgusting.
I don't understand anything.
I don't get it.
Good day and good mood everyone!
The article contains the code of the function of checking the sufficiency of funds for a trade operation:
What is highlighted in yellow is that we first declared the price variable and assigned the Ask price value to it, and literally after the line where the order type is checked, the Bid value is assigned accordingly.
Question - why can't Bid be assigned at the stage of declaring the price variable at once, or is there some sacred meaning here?
Regards, Vladimir.
Good day and good cheer everyone!
The article contains the code of the function to check if there are enough funds to perform a trade operation:
What is highlighted in yellow is that we first declared the price variable and assigned the Ask price value to it, and literally after the line where the order type is checked, the Bid value is assigned accordingly.
Question - why can't Bid be assigned immediately at the stage of declaring the price variable or is there some sacred meaning here?
Regards, Vladimir.
Vladimir, why do you need such perversions? It is easier to use the OrderCheck() function. Moreover, the MqlTradeRequest structure can be kept declared at the level of global variables and after a successful check can be used without filling it again before OrderSend().
When you get the margin size, you have to perform arithmetic operations... And here everything is already calculated in the structure.
Vladimir, why such perversions??? It is easier to use the OrderCheck() function. Moreover, the MqlTradeRequest structure can be kept declared at the level of global variables and after a successful check can be used without re-filling before OrderSend().
When you get the margin size, you have to perform arithmetic operations... And here everything is already calculated in the structure.
What if EA is set on more than one pair?
OrderCheck() is somehow more reliable.Vladimir, why such perversions??? It is easier to use the OrderCheck() function. Moreover, the MqlTradeRequest structure can be kept declared at the level of global variables and after a successful check can be used without re-filling before OrderSend().
When you get the margin size, you have to perform arithmetic operations... And here everything is already calculated in the structure.
Hi Alexey, I understand your variant, Vitaly's hint is reasonable too.
But still! This code is taken from an article written by MetaQuotes specialists and I have no reason not to trust them. I just had a question I would like to get an answer to. ))
Regards, Vladimir.