Quote:
Originally Posted by Michel
To detect a new bar there are several solutions:
1)
PHP Code:
if(Volume[0] == 1) CloseOrders();
Not very reliable, for example if the terminal has to be restarted you may loose the first tick of the bar.
2)
PHP Code:
if(BarsCnt < Bars) {BarsCnt = Bars; CloseOrders();}
Not very reliable, for example if new bars are added to the left of the chart.
3)
PHP Code:
if(Time1 < Time[0]) {Time1 = Time[0]; CloseOrders();}
Better, but again, restarting the terminal may produce wrong behaviors.
So my opinion is that the best is to write the lifetime max of each order into the order itself, using the "Comment" field :
PHP Code:
OrderSend(..., ""+(Time[0] + Period()*60), ..);
Then you can scan the orders and check :
PHP Code:
if(TimeCurrent() > OrderComment()) OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 0, CLR_NONE);
. This is a good solution because if you have several orders to close, you have all the time needed to do it.
|
i got the error below.what does ot mean?
PHP Code:
'>' - different types in comparison F:Program FilesMetaTrader - FXOpenexpertsEMA_10.mq4 (88, 22)
I make it like this
for the send order
PHP Code:
OrderSend(Symbol(),OP_BUY,Lots,Ask,0,Ask-25*Point,Ask+TakeProfit*Point, ""+(Time[0] + Period()*60),SystemMagicNumber,0,Blue);
and for the close order
PHP Code:
if(TimeCurrent() > OrderComment())
{
OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 0, CLR_NONE);
}
and i got the error shown above.
Is it right?