Thread: Ask!
View Single Post
  #1065 (permalink)  
Old 04-28-2008, 12:56 PM
bearfoot090 bearfoot090 is offline
Junior Member
 
Join Date: Dec 2007
Posts: 5
bearfoot090 is on a distinguished road
Quote:
Originally Posted by Michel View Post
To detect a new bar there are several solutions:

1)
PHP Code:
if(Volume[0] == 1CloseOrders(); 
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 BarsCloseOrders();} 
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(), 0CLR_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 (8822
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(), 0CLR_NONE);  
    } 
and i got the error shown above.
Is it right?
Reply With Quote