Download MetaTrader 5

Need Help!!! It´s about to set max Open Trades in a Period

To add comments, please log in or register
Documentation is available in CHM and PDF. Download it in any convenient form!
Hansie 2014.11.14 09:29 

Good Morning evereyone,


 Iám a Newbie in Coding at All, but i learn very fast =D and it´s really fun to create and modify EA´s. 

Well here is my problem, whitch i try to solve.


 I´ve made a EA based on one Moving Average, witch Buys and sells when the prev candle[2] was closed  over/under the MA and  closed under/over the next candle [1] of the MA .

Well in Periods Like M5 or M15 i didn´t have this Problem , but  for example on a H4 period i have a Signal-Candle witch is 4 Hours valid.

That means, that in this 4 Hours he can open as many Positions, as much money i have. That´s why iám looking for a function, witch allowdes the EA to open max 2 in this Period.

I hope one of you had a solution for me, because google coudn´t help me at all.


greets to all of you  :o) 

Carl Schreiber
Carl Schreiber 2014.11.14 09:40  

I set my time-limits generally in this way

datetime IsValid; //global definition
void OnTick(){
   if ( ... ) IsValid = TimeCurrent()+ 4*3600;// valid for 4h = 14400sec.
   if (TimeCurrent() < isValid ) { open as much as you can..}
To add comments, please log in or register