How to close opened trade on next days ?

 

 Hi All,

 I am coding a system which will be placing only one trade per day .

On the next day if market meets my requirements  , selected order must be reversed , e.g. sell into buy 

 If the requirements are not met-> the postion should be opened till system reverse it . In that time new trades do not be filled!

  .........

 Attached code cause that the new order can be opened and closed at the same day ;/

 What is more next day occurs new trades without closing previous trade.;/

Please help me :) 

 I attached file .

Files:
 

Hi,

just an idea:


- use D1 timeframe, and check the  numbers of d1 candles

- in the expert init() sections:

int bars_on_the_chart=Bars;

in the expert start() sections:


if (bars_on_the_chart<Bars)  //new day

{

//close orders ...

//open orders ....

bars_on_the_chart=Bars;


}

Reason: