Download MetaTrader 5
To add comments, please log in or register
Trade with MetaTarder 5. Download it right now!
Amin0xy
41
Amin0xy 2014.09.04 22:56 

I need a code that allow's  me to open only one order per hour on a single symbol.


 this is the  sell condition 

 if(Close[1] > Open[1])
   {
double S=MathAbs(High[0]-Close[1]); 
double Sp=S/Point; 
if(Sp>=20)
result=OrderSend(Symbol() , OP_SELL , lot , Bid , Slippage , Bid+SL*Point , Bid-TP*Point, "" ,MagicNumber , 0 , Green);
Comment(Sp);

 waiting for your help ...thanks in advance :)

Simon Gniadkowski
Moderator
17963
Simon Gniadkowski 2014.09.05 07:11  
Amin0xy:

I need a code that allow's  me to open only one order per hour on a single symbol.


 this is the  sell condition 

 waiting for your help ...thanks in advance :)

Search for "once per bar" ad use the H1 timeframe.

For example: https://forum.mql4.com/63605#975674  or  https://forum.mql4.com/34592/page2#854419   

Amin0xy
41
Amin0xy 2014.09.05 16:48  
thanks you ..but i didn't find something specific ...please i need the exact cmd that force the system to make only one trade per bars
Simon Gniadkowski
Moderator
17963
Simon Gniadkowski 2014.09.06 19:51  
Amin0xy:
thanks you ..but i didn't find something specific ...please i need the exact cmd that force the system to make only one trade per bars

I gave you two links . . . do some reading and learning.
Amin0xy
41
Amin0xy 2014.09.08 00:23  

thank u any way 

i did find this ..and its worked

 

static bool IsNewBar;
static datetime LastBarOpenAt;


start()
 {

 if(LastBarOpenAt == Time[0]) // This tick is not in new bar
    {
     IsNewBar=false;
    }
  else
    {
      LastBarOpenAt = Time[0];
      IsNewBar = true;    
    }

if(IsNewBar)
{
// the rest of the code..................................................

// ................................................................
}
 
/
To add comments, please log in or register