Stop Trading

 
How can I trade following thing:

I want that my expert stop trading at a certain time (for example 6 pm) and close all open position at this time
 
You must have an end time , a restart time and a Forbidden bool value. The system will not open trades when Forbidden==True
Then start will check if end time was reached. If end time was reached, initiate close of all trades and set Forbidden to true. If restart time is reached, set Forbidden to false...
 
got it, thx
I am still learning mql and try different things.

And what about stop trading at a certain point; for example: stop trading if GBPUSD reaches 1.97 (for today, but program starts following day again)
 
tbreaker:
got it, thx
I am still learning mql and try different things.

And what about stop trading at a certain point; for example: stop trading if GBPUSD reaches 1.97 (for today, but program starts following day again)
do it like this:
use these vars: int OldDay and int NowDay, defined globally (after externals and before function defs)
inside init make OldDay=Day(); NowDay=Day();
when start begins:
NowDay=Day();
if (NowDay!=OldDay) { Forbidden=False; OldDay=NowDay; }
...
if (MarketInfo("GBPUSD",MODE_BID)>=1.97) { Forbidden=True; //eventually call here a func to close all trades }