Download MetaTrader 5
To add comments, please log in or register
Interested in MQL5 features? Find them in documentation!
Brian Kester
794
Brian Kester 2014.06.11 19:37 

Is this how to print when a new order opens?

 

 

if(OrdersTotal() ++)

Print(“a new Order has opened, OrdersTotal() is now = “+OrdersTotal() );


 

 

thanks pros  :) 

Алексей Тарабанов
7220
Алексей Тарабанов 2014.06.11 20:13  
c3po:

Is this how to print when a new order opens?


No. 
whroeder1
13627
whroeder1 2014.06.11 20:21  
c3po: Is this how to print when a new order opens?
if(OrdersTotal() ++)
Print(“a new Order has opened, OrdersTotal() is now = “+OrdersTotal() );
  1. OrdersTotal() returns a number (say 5). 5++ is 6. What does if(6) mean?
  2. You need to remember the old value so you know when it changes.
    static int OTcurrent; int OTprevious = OTcurrent; OTcurrent = OrdersTotal();
    if(OTcurrent > OTprevious) Print("new order");
  3. Do you care whether another EA or a human opened an order on another chart? Shouldn't you only care about your orders on your chart? You know that when you called OrderSend().
  4. If you want to know whether a pending order opened, then you need to look for an increase of your open orders.
    static int OTcurrent; int OTprevious = OTcurrent; OTcurrent = MyOrdersTotal(OP_BUY) + MyOrdersTotal(OP_SELL);
    if(OTcurrent > OTprevious) Print("new order");

Алексей Тарабанов
7220
Алексей Тарабанов 2014.06.11 21:00  
Yes, it`s so. But static mode is not realised correctly in mt4, so I recomend to use global data section. 
Ian Venner
2583
Ian Venner 2014.06.11 21:33  
tara:
Yes, it`s so. But static mode is not realised correctly in mt4, so I recomend to use global data section. 
what is wrong with static mode ?
Brian Kester
794
Brian Kester 2014.06.11 22:44  
WHRoeder:
static int OTcurrent; int OTprevious = OTcurrent; OTcurrent = OrdersTotal();
if(OTcurrent > OTprevious) Print("new order");


got it boss. This is like taking a snapshot with a video camera and comparing the two. Then MyOrdersTotal to filter out everything but current chart, symbol, magic, etc. Thanks.

/
To add comments, please log in or register