Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 892
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
Guys who can help with this question. I want to declare a global variable of undefined type or arbitrary type. Then this variable will be used in functions where templates are applied. In other words, I call function and take array of any type, then calculations will be done and result will be returned by function and will be assigned to this variable. I want to store the result of calculation of these parameters in a variable, so I don't have to call the function for the second time. How can I find universal solution with fewest checks, can I convert variable type, or declare it as variable with macro, what can I do?
If I understand correctly, then
https://www.mql5.com/ru/docs/basis/oop/templates
I don't really understand this comment. You can open a locking position (opposite to the open position) with a free margin lower than the margin for the newly opened order (not in the lock). So where is 100% there?
Example:
USDJPY currency, leverage 1:100. Lot 0.1, the margin is 100
According to the specification the hedged margin is 50000, which means 50%
In order to open a locking position, 100 more funds must be available in the account. Otherwise, there will be an error ... do not remember the number, in general, not enough funds.
And only after opening a position the actual margin will be corrected according to the values given in the specification.
But, if there is only 50 available funds in the account, then you can open twice for 0.05
If I have understood correctly, then
https://www.mql5.com/ru/docs/basis/oop/templates
I already know about the use of template technology. This method allows you to return the type of a variable, but converting the type of one variable to another will not. It may not be possible.
Example:
USDJPY currency, leverage 1:100. Lot 0.1, the margin is 100
According to the specification, the hedged margin is 50,000, which means 50%.
To open a locking position, 100 more funds must be available in the account. Otherwise, there will be an error ... do not remember the number, in general, not enough funds.
And only after opening a position, the actual margin will be corrected according to the values in the specification.
But, if there is only 50 free funds in the account, then you can open twice for 0.05
Ok, maybe that's the way it is. We should check it out.
We should check on the price of an order. Then what about the MQL5 functionhttps://www.mql5.com/ru/docs/trading/ordercalcmargin?
The order open price is in the parameter. How does it work for crosses? How does it work for cross rates? Does MT5 know how to predict prices?
FreeNumFractals
i have already reinstalled mt5 and this indicator,but it has no effect.
FreeNumFractals
What is that indicator? I have no effect. Where is the link to it?
All right, maybe that's it. We'll have to check it out.
On the price of the order. What about the MQL5 functionhttps://www.mql5.com/ru/docs/trading/ordercalcmargin?
The order open price is in the parameter. How does it work for crosses? How does it work for cross rates? Can MT5 predict prices?
Well, you have to read everything carefully. Quote from the documentation:
The calculation is performed... i.e. the obtained value will be without taking into account the open position, and only then it will be corrected according to the specification if the opposite position is opened. This is what I was talking about.
Margin value... for pending orders is calculated "from the background" and may not correspond to the real value.
Great advice and a great science for the future!!! Went even a little further than that. Below is the result.
So it was:
So it became, the effectiveness of the approach is obvious!!! Thank you.
Thanks to Sergei and Alexey for the coloured stochastic indicator. You are very good. Respect!
So that my indicator data will replace the chart data.
And that all standard indicators of the client terminal can be thrown on this new chart. And for these indicators to work on my indicator's data, not on price bars.
There is a question like this. So, there is a loop
The 1stbreak is located not in first parentheses of the loop but in parentheses nested inside them. The 2ndbreak is even deeper nested in inner parentheses. As I understood in this casebreak simply doesn't work, to tell the truth I didn't understand if it worked or not but the program hung up and made unnecessary iterations. In order to exit a loop with a lot of conditions I added an exit flag to the loop. Maybe it seemed to me that it does not work, who thinks on this issue?