[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 275

 

Good night all!

Could you please tell me if I open a position like this?

   order_id = OrderSend(Symbol(),OP_BUY,1.0,Ask,3,0,0,"expert comment",255,0,Green);
   if(ticket<1)
     {
      error=GetLastError();
      Print("send_orders, error = ",ErrorDescription(error));
      return;
     }

What is the best way to close it, if my Expert Advisor can open only one position?

How about this:

OrderClose(OrderTicket(),1,Bid,3,Red);
 

It is not clear how to get a unique order number. And how to know that this order is the right one. Please share your experience!

 
BBSL:

It is not clear how to get a unique order number. And how to know that this order is the right one. Please share your experiences!


See here https://docs.mql4.com/ru/trading/OrderSelect

When you have chosen the order, you only need to check whether it is the right one or not. If it is not needed, we move on to the next order and check it again. Until the right one is found

 

I am trying to master MT5.

When installing one Expert Advisor I faced a small problem - the work of this Expert Advisor is possible only after loading a certain history, i.e., install it and wait until the loading is completed. The worst thing is that it seems that this history is not saved, because on another day everything repeats.

Can you please explain if there is any way to save the downloaded history? Thank you.

 
Vinin:


Look here https://docs.mql4.com/ru/trading/OrderSelect

Once you have selected an order, all you have to do is check whether it is the right one or not. If it is not, move on to the next one and check again. Until the right one is found.


I have looked through a textbook up and down...

Does it mean that we know the number of order?

I think we need to use OrderTicket();, to get the number, right?

 
BBSL:


I've been through the textbook up and down...

Does this mean that the order number is known?

You should use OrderTicket();, to get the number, right?


OrderTicket() can be used by pre-selecting it with OrderSelect(). And any operation on an order requires it to be pre-selected using OrderSelect()
 
hedger:

I am trying to master MT5.

When installing one Expert Advisor I faced a small problem - the work of this Expert Advisor is possible only after loading a certain history, i.e., install it and wait until the loading is completed. The worst thing is that it seems that this history is not saved, because on another day everything repeats.

Can you please explain if there is any way to save the downloaded history? Thank you.


If we're talking about ticks, you could write code that saves the data file, but you'd have to load it from a file in ekspert. Would it make sense to just keep the computer running?
 
Vinin:

OrderTicket() can be used by pre-selecting it with OrderSelect(). And any operation with an order requires its pre-selection using OrderSelect()


In other words:

if(OrderSelect(0, SELECT_BY_POS)==true){

OrderClose(OrderTicket(),1,Bid,3,Red);

}
 
BBSL:

If we are talking about ticks, you can write code that saves the data file, but you will need to load from a file in ekspert. Maybe it makes sense just to keep the computer on?

If Expert Advisor is pips, then data should be "fresh", for old ones there will be only noise...
 
BBSL:

Good night all!

Could you please tell me if I open a position like this?

What is the best way to close it, if my Expert Advisor can open only one position?

Maybe it goes like this:

This is a strange way to do it... When opening a position, you assign the ticket number to one variable, and you check another one...

order_id = OrderSend(Symbol(),OP_BUY,1.0,Ask,3,0,0,"expert comment",255,0,Green);
   if(ticket<1)

And OrderSend() returns -1 (minus one) in case of failure, and you check for less than one, when you need less than zero

This is the first thing that catches your eye. But I think you have a lot of interesting things there... :)

Reason: