Time Set Trading Problems - Also How to Set Time Gaps

 

In the simple EA Example of have here, the open trade time setting works, the Close trades time does not?

It appears there is more code needed here. I am trying to have the EA or EA'S trade at certain times of the day

for  different currency pairs. This is my first use or attempt using the Time code for trading. Am still a little new

with it. My preference is to be able to have it selectable for start and closing the trades, then open at a new time and close .

Example:  Open at 8am and close at 12 noon.  Open again at 8pm and close at 9:30pm. Open again at 2am and close at 7am.

Right now the way the EA is working is it just starts at the correct set time and carrys the trades through beyond the close setting.

I am new to using the Switch code but it looks as though this needed here? 

Files:
 

I may have to look more at your code (no promises) but try to count down to zero when closing/deleting orders - click here Loops and Closing or Deleting Orders 

and using 

if(Volume[0]>1) return;

is also bad idea. When a new bar come, is very rare that Volume [0] is equal zero, so it's not easy to get Volume [0] == 0,

maybe use

static datetime TimeCurrent;

if (TimeCurrent == Time [0]) return;

TimeCurrent = Time [0];

Not compiled nor tested for logic - may have an error :)