hy
could you help?
how close open order after x minuts independent of it's loss or win?
is a function of history where we can find and remember time's open order?
hy
could you help?
how close open order after x minuts independent of it's loss or win?
is a function of history where we can find and remember time's open order?
Hi przem81621,
In the extern parameters, add :
After the extern parameters, add :Code:extern bool UseTimeOut=false; extern double TimeOut=60; //in minutes
Before the OrderSend function, add :Code:datetime expiration; int ticket;
Just after the OrderSend function add :Code:ticket=
At the beginning of the Start function, add :Code:if(ticket>0)expiration=CurTime()+TimeOut*60*60;
Replace Close() by your close function.Code:if (UseTimeOut) { if(CurTime()>=expiration) { Close(); Print("Order closed due to TimeOut"); } }
Trading forex risk disclaimer. Exclusive EAs in the Elite section.
There are two ways of doing this. With both methods you need firstly to process the trades pool and select your order by symbol and magic number and open buy/sell.
The first way uses some code similar to this:
The problem with this approach is that if your position was taken on a Friday evening shortly before the market closed, you may find yourself unable to close the position.Code:if(TimeCurrent()-OrderOpenTime()>=Close_after_minutes*60) {ClosePosition();}
Instead you could use this second approach:
Obviously you would need to tidy this logic up a little bit and insert it at the correct places.Code:int OpenBar = iBarShift(NULL,0,OrderOpenTime()); if(OpenBar*Period()>=Close_after_minutes) {ClosePosition();}
Last edited by jezzer1961; 05-21-2009 at 19:24.
PipRider.com - The home of the PipRider EA. From $100 to over $1m in 10 year backtest, and it works LIVE too!!
Ooops, looks like Funyoo posted while I was typing.
Funyoo,
I think you might find that CurTime() is an obsolete MetaTrader function now. I'm pretty sure it's been replaced by TimeCurrent().
PipRider.com - The home of the PipRider EA. From $100 to over $1m in 10 year backtest, and it works LIVE too!!
Trading forex risk disclaimer. Exclusive EAs in the Elite section.