OrderSend keeps opening orders and ignoring conditional - page 2

 
DavidMQL4:

Hi pipPod, the varaible is datetime declared within the OnTick{} block (so I guess local) and is not static. I am a bit confused about the 'static' in the fact that..., does it Scenario A. - retain the value assigned to it during the 'lifetime' of the EA, in other words until removed from the chart?, or does it Scenario B. - retain the value all the way through the whole code until it reaches the bottom and then can get a new value once a new tick comes along?

 

I will try your suggestion changing the code to static, but the reason I asked the question above is because I need this variable ready to get a new value once the actual candle it is working on completes and a new 'Bar' opens, opening the readiness of the variable to get a new value. 

It retains the value until a new value is assigned to it when the order is sent( UBand01_OOT=Time[0];). If it's declared locally or non-static, every time a new tick comes in, the variable will be equal to zero. So Time[0] will always be bigger than UBand01_OOT.

The following will only open an order once per bar for each condition, iow maximum 2 orders per bar. 

static datetime UBand01_OOT,UBand02_OOT;

if((Close[0]>Cls0_ULevelValue_01) && (Close[0]<Cls0_ULevelValue_02)) // Tests whether the Close[0] is within pre-determined level 1 and 2

   if((Time[0]>UBand01_OOT) && (TIME0vsTIME1_Drctn==1)) // It tests whether there has already an order placed after the Current Bar Opening Time.

     {

      UBand01_OrdSend=OrderSend(Symbol(),OP_SELL,SzSell_01,Bid,0,0,0,NULL,00,0,clrRed);

      UBand01_OOT=Time[0];

     }
//---------------------------------------------------------------------------------------------  

if((Close[0]>Cls0_ULevelValue_02) && (Close[0]<Cls0_ULevelValue_03)) // Tests whether the Close[0] is within pre-determined level 2 and 3

   if((Time[0]>UBand02_OOT) && (TIME0vsTIME1_Drctn==1))

     {

      UBand02_OrdSend=OrderSend(Symbol(),OP_SELL,SzSell_02,Bid,0,0,0,NULL,00,0,clrRed);

      UBand02_OOT=Time[0];

     }
 
Marco vd Heijden:

I mean a simple 1 Minute delay between orders.

If you need less then use a simple counter.

All right, I will work on this, thank you for your help.