Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 557
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
OrderSelect() is executed inside the terminal, there is no request to the server. So, there is nothing wrong with accessing the list of orders on every tick. Most Expert Advisors do this.
And your question about the array is related to the architecture of the program. In case of a complex EA that operates with a large amount of orders, this is absolutely necessary. If the Expert Advisor operates with a single order with simple logic, the array is redundant.
It is only worth to mention the fact that even if we have an array of orders, we cannot do without calling OrderSelect(). After all, we have to check at every tick whether the order still exists or not. Also its parameters might be changed.
Guys, tell me how to deal and where to start!
Example: I have 15 orders with 0.01 lot. I need to close some trade(s) with 0.07 lot size at some point.
My question is, how can I close 7 orders or 0.07 in one OrderClose(...)?
If I put 0.07 at once it does not see trades with volume 0.01.
I am new to programming.
I received a tip on how to make a counter in the form ofcountS .
It should close three deals of 0.01 lots per minute. Now, we have a question how to convert it so that all orders are calculated in order.
If we setfor(int i=OrdersTotal()-1; i>=0; i--){ the last orders will be counted in order,
If for(int p=0; p<OrdersTotal(); p++){ then go from the first through one order.
Counter works, but when the lot size is 0.15, for example, it doesn't close 0.03 lots and closes 0.01 lots every minute.
What would you advise to add?
How do I make it possible to close part of the total lot regardless of the number and lot size of orders?A tip on how to make acountS counter.
There should be three trades of 0.01 lots closed per minute. Now I have a question how to convert it so that all orders are counted in order.
If we setfor(int i=OrdersTotal()-1; i>=0; i--){ the last orders will be counted in order,
If for(int p=0; p<OrdersTotal(); p++){ then go from the first through one order.
Counter works, but when the lot size is 0.15, for example, it doesn't close 0.03 lots and closes 0.01 lots every minute.
What would you advise to add?
How do I make it possible to close part of the total lot regardless of the number and lot size of orders?When setting this problem (very strange, by the way), you need to work with the list of "Account History". At each new iteration, we should go through this list and find orders which were closed during the current minute and sum up their volume. If there is not enough volume, then sort it as needed (so don't ask how, it is up to you) and take a single order. Close it at 0.01. On the next iteration, start again.
When setting such a task (a very strange one, by the way), you have to work with the "Account history" list. At each new iteration you should go through this list and find the orders which have been closed during the current minute, summing up their volume. If there is not enough volume, then sort it as needed (so don't ask how, it is up to you) and take a single order. To close it at 0.01. At the next iteration all over again.
I will try! Thank you
can't configure the mail sending from the terminal
I can't get it to work with myl.ru but now I've configured it the same way and it won't send the test message.
did someone deal with it ?
if for yourself (not for sale) then the right treatment for mail problems is :
1) get a mailer on localhost to handle forwarding, guarantee delivery and don't mess around with authorisation and anti-spam protection. Otherwise EAs will very quickly end up on all sorts of blacklists.
This is not difficult - there is a built-in win smtp and free with simple settings, in a pinch you can script yourself :-)
2) Use an alternative to SendMail() . To control the whole process, to send smarter reports, with tags, flags, optionally in html and with pictures.
When you combine 1+2 you get a total of 3 :-) so it's a sensible and stable solution.
more about sending mail : https://www.mql5.com/ru/blogs/post/718364
-----
If you need help about specifics of SendMail and MT setup, then please attach screenshots, source code extracts, error diagnostics...
So it's not just a "subterranean knock"
Do I understand correctly that "TimeCurrent()" will return the time of the last tick when it is called from a user function?
Yes
Greetings!
An order can be accessed using theOrderSelect command by its number.
Question, is it possible to know the numbers of existing orders in advance, so as not to go through them all? For example, we can memorize this number when opening a new order.
I understand that this number is assigned in order starting from 1. What are the possible nuances?
Thank you very much.
Greetings!
An order can be accessed using the OrderSelect command by its number.
Question, is it possible to know the numbers of existing orders in advance, so as not to go through them all? For example, we can memorize this number when opening a new order.
I understand that this number is assigned in order starting from 1. What are the possible nuances?
Thank you very much.
OrderSend
OrderSelect
Broke my brain, help please!
I have written a correlation calculation unit. But OANDA and investing.com give completely different results! It's funny - they don't match each other either!
Where am I wrong?
The current currency pair is EURUSD, I check correlation with GBPUSD.
extern string SubSymbol = "GBPUSD";
extern int correlation_time = 24; // how many hours to check the correlation of the selected currency pairs
.....
// ------------------------ block of correlation calculation --------------------------------------
int period = 15;
int bars_number = MathRound(correlation_time*60/period);
double symbol_avg = 0;
double symbol_avg = 0;
double symbol_price[], double subsymbol_price[];
double x,y;
int j;
int shift = 0;
ArrayResize(symbol_price, bars_number);
ArrayResize(subsymbol_price, bars_number);
for (j=0; j < bars_number; j++)
{
symbol_price[j] = (iHigh(NULL,period,j+shift) - iLow(NULL,period,j+shift))/2;
subsymbol_price[j] = (iHigh(SubSymbol,period,j+shift) - iLow(SubSymbol,period,j+shift))/2;
symbol_avg = symbol_avg + symbol_price[j];
subsymbol_avg = subsymbol_avg + subsymbol_price[j];
}
symbol_avg = symbol_avg/bars_number;
subsymbol_avg = subsymbol_avg/bars_number;
double ss_xx = 0;
double ss_xy = 0;
double ss_yy = 0;
for (j=0; j < bars_number; j++)
{
x = symbol_price[j] - symbol_avg;
y = subsymbol_price[j] - subsymbol_avg;
ss_xy = ss_xy + x*y;
ss_xx = ss_xx + x*x;
ss_yyy = ss_yy + y*y;
}
double correlation = ss_xy/MathSqrt(ss_xx*ss_yyy);
Alert(correlation, " ", bars_number);
ArrayFree(symbol_price);
ArrayFree(subsymbol_price);
// ------------------------ end of correlation calculation block ---------------------------------