- Features of the mql5 language, subtleties and tricks
- Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes
- Artificial neural networks.
To close an order, you don't have to define the order type and the price corresponding to that type at all. It is sufficient to write OrderClosePrice()
void OnStart()
{
int i, total = OrdersTotal()-1;
for(i = total; i >= 0; i--)
{
if(OrderType() < OP_SELLSTOP)
{
if(!OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 100))
printf("***********");
}
}
}/********************************************************************/
There are many more inaccuracies in the help. TakeSetIndexBuffer(), for example.What is wrong in the help?
"Parameters
index
[in] Number of the indicator buffer. Numbering starts with 0. The number must be less than the value declared in #property indicator_buffers." (this statement is not true)
The #property indicator_buffers specifies the number of buffers to display. Perhaps what the help means, although I haven't checked this, is that, the buffers used for calculation don't need to be given a number by SetIndexBuffer(). But what I have checked is that if the buffer used for calculation is given a number with SetIndexBuffer(), its value can be retrieved via iCustom().
Since the developers are visiting the thread - there is a question about "subtleties and tricks":
Example of a formatted print: PrintFormat("Bid=%.5f", Bid)
Question: is there any way, instead of a fixed precision (here5), to specify a condition in the format description so that the precision depends on _Digits? To do without 'preprocessing' like PrintFormat("Bid=%s", DoubleToString(Bid, _Digits))
Question: instead of a fixed precision (here5), is it possible to specify a condition in the format description so that the precision depends on _Digits?
- www.mql5.com
Описание проблемы
I am writing an indicator in MQL4. I faced an undocumented feature of the DRAW_HISTOGRAM style.
To display the values on the chart, I need two buffers: for the upper value of the histogram and for the lower one. When mapping the indicator array buffers, if the buffers for the style will have values 0 and 1, 2 and 3, 4 and 5, etc. everything is displayed normally. However, if the style buffers are assigned values starting with OTHER, i.e. 1 and 2, 3 and 4, 5 and 6, the histogram lines will not be displayed correctly in the graph, although the values in the data window will be correct.
Please add a mention of this peculiarity to the documentation, or correct it, because it's not always the case that the DRAW_HISTOGRAM style description will start with an even buffer!
Forum on trading, automated trading systems and trading strategy testing
-Aleks-, 2017.02.07 18:21
Can you please tell me if in MT4 Expert Advisor, if a custom indicator with more than one graphical buffer is consistently called, then recalculation happens at each call or all buffers are calculated at once and you can refer to the indicator in the code many times and not expect to waste resources. I am also interested to know what will happen if the code is not completed (runs longer than a tick), but the indicator value changes.
Forum on trading, automated trading systems and strategy testing
Slawa, 2017.02.08 08:20
All buffers are calculated at once. Quietly interrogate the values of the indicator - there will be no recalculationIn MT4 the indicator called from the Expert Advisor works in the flow of this EA and on a copy of its historical data. You can loop the Expert Advisor, but at the same time you will receive the indicator data calculated at the time of OnTick call. Until you call RefreshRates. RefreshRates updates historical data of the Expert Advisor, after that all its data will be recalculated at the first call of the indicator
To close an order, you do not have to specify the order type and price corresponding to this type. It is enough to write close at price OrderClosePrice()
So, you can use OrderClosePrice only AFTER the corresponding OrderSelect. Because OrderSelect copies the data for Order(const)-functions once, and the same RefreshRates is not able to update them.
I.e. if, for example, OrderClosePrice fails to close, then you must do OrderSelect again before the next attempt (RefreshRates is not required).
ZS This thread is from 2005! Here are detailed arguments of developers.
It's a shame...
---
So that the post is not useless:
instead of StringGetCharacter("a", 0) you can write just 'a'- often needed when parsing strings into parts with StringSplit
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use