Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 103
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
e.g., copy the whole file.
1. When an order is opened, write the ticket in the variable global level or static, and then monitor this order until it is blue in color, oops, until it is closed by comparison OrderCloseTime() > 0. If the close time is greater than zero, the order is closed.
2. The substitution for the GOTO operator is much more efficient. Read the documentation about the functions.
Is there any way of showing me an example? How do I wait for the previous trade to close?
double loss = 100;
int start()
{
int order;
if(OrdersTotal()==0)
{
order = OrderSend(Symbol(),OP_BUY,Lot,Ask,1*Point,Ask-loss*Point,Ask+loss*Point); // Вверх
order = OrderSend(Symbol(),OP_SELL,Lot,Bid,1*Point,Bid+loss*Point,Bid-loss*Point); // Вниз
}
return(0);
}
//+------------------------------------------------------------------+
Is there any way of showing me an example? How do I wait for the previous trade to close?
double loss = 100;
int start()
{
int order;
if(OrdersTotal()==0)
{
order = OrderSend(Symbol(),OP_BUY,Lot,Ask,1*Point,Ask-loss*Point,Ask+loss*Point); // Вверх
order = OrderSend(Symbol(),OP_SELL,Lot,Bid,1*Point,Bid+loss*Point,Bid-loss*Point); // Вниз
}
return(0);
}
//+------------------------------------------------------------------+
The simplest one is the sequence of actions. First, we try to do something with an already open order, and then, if there is no open order, we try to set it.
We divide position handling and opening of a new order into two separate user-defined functions. Then in the OnTick() function check for the presence of open orders and call one or the other function according to the result obtained.
It looks like this in words:
{
if(OrdersTotal() > 0)
открытие();
else
сопровождение();
}
bool открытие()
{
// здесь код открытия
}
bool сопровождение()
{
// здесь код сопровождения
}
This is the case if the account provides, but more often it is the case of working of other Expert Advisors or opening orders manually.
Can I programmatically select the start date of the account history in the terminal?
You can. This will be the first order in the history with type 6 - balance operation.
I don't need the first order in the history ... the history is opened to the maximum I need the history from a certain date ... which I will set programmatically (apparently the question was streamlined at the expense of details)
But the question is still "streamlined", so I will say that we should skip the orders the open time of which is earlier than that "specific date".
The answer is also that you can.
But the question still remains "streamlined", so I would say that we should skip orders whose opening time is earlier than this "certain date" ... of course it did not occur to me ... but 7 years is a very large number of orders ...
the question is underlined in red in the screenshot ... so the question is not streamlined?
Of course it didn't occur to me to filter by date ... but in 7 years there are a lot of orders .
In the screenshot, the question is underlined in red and you have to put a certain date there... so the question is not streamlined?
What exactly do you want to do programmatically?
I don't understand your question :(
What exactly do you want to do programmatically?
where it is underlined in red, enter the date and essentially click ok... it determines the depth of history in the report