DELETE ORDER EXE. Q&A

 

///////////////////////////////////////////////////////////////////////////////////////////////
void TIME_DEL()
{
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
continue;


RefreshRates();
if((OrderType()==OP_BUYSTOP) || (OrderType()==OP_BUYLIMIT))
OrderDelete(OrderTicket());
if((OrderType()==OP_SELLSTOP) || (OrderType()==OP_SELLLIMIT))
OrderDelete(OrderTicket());
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////

int start()

{

if (Hour() >=0 && Minute()==13 || Hour() <=23 && Minute()==13)
{

if (orderstotal <=1)

{

.....................

}

return(0);

}

if (Hour() >=0 && Minute()==19 || Hour() <=23 && Minute()==19)
{TIME_DEL();}

Q....

OPEN ORDER TIME....EVERHOUR EVERYMINUTE 13, OPEN ORDER

AND, EVERYMINUTE 19, OP_BUYSTOP && OP_SELLSTOP, DELETE ORDER

BUT, EVERYMININUT 19, NOT EXE. DELETE ORDER.....25 DELETE ORDER EXE.(BELOW PICTURE)

HELP ME PLEASE!

 
kurosia:

int start()

{

if (Hour() >=0 && Minute()==13 || Hour() <=23 && Minute()==13)
{

if (orderstotal <=1)

{

.....................

}

return(0);

}

if (Hour() >=0 && Minute()==19 || Hour() <=23 && Minute()==19)
{TIME_DEL();}

Q....

You should check the Precedence rules. Logical OR has higher precedence than Logical AND, so your expressions are actually being evaluated as:

(Hour() >=0) && (Minute()==19 || Hour() <=23) && (Minute()==19) , which doesn't make sense.


Secondly, why add the Hour() criterion to your expression if u use all hours anyway (Hour() returns 0,1,...23). U should just do this:

if ( Minute() == 19 )


Please make sure u don't have missing bars in history (from the 19th minute to the 24th minute of that hour in your example), if u do then that explains it.

p.s. please use the SRC button to post code next time...

 

Another thought - are u using 'Every Tick' model? Do u have M1 history for the pair u r testing on?

If u r testing on a large time-frame with a simpler model, or don't have M1 history, then ticks might come every few minutes...

 
gordon:

You should check the Precedence rules. Logical OR has higher precedence than Logical AND, ...

p.s. please use the SRC button to post code next time...

From the manual.pdf I have:

^ Bitwise exclusive OR From left to right
| Bitwise OR operation From left to right
&& Logical AND From left to right
|| Logical OR From left to right
= Assignment From right to left

Making && higher as is common in most programming languages. Always add parenthesize instead of relying on presidence. The If statement translates to Minute()==19 all hours. If a tick doesn't come in during that minute it won't close.

Minute()>=19 && Minute()<=59

would be safer.

 
WHRoeder:

Making && higher as is common in most programming languages. Always add parenthesize instead of relying on presidence.

I agree, I usually use parentheses myself so I never actually think about it. But the online manual states this clearly:

Each group of operations in the table has the same priority. The higher is the priority, the higher is the position of the group in the table. The precedence rules determine the grouping of operations and operands.

...

||     Logical OR                        From left to right
&&     Logical AND                       From left to right

Is your PDF manual a recent one?

 

Verified the online version (Logical OR has higher precedence than Logical AND):

int start()
  {
   bool result_1 = true || false && false;  
   bool result_2 = (true || false) && false;  
   bool result_3 = true || (false && false);  
   
   Print ( "true || false && false   = ", result_1 );
   Print ( "(true || false) && false = ", result_2 );
   Print ( "true || (false && false) = ", result_3 );
  }

Output:

2010.02.10 23:26:20	test EURCHF,H1: true || false && false   = 0
2010.02.10 23:26:20	test EURCHF,H1: (true || false) && false = 0
2010.02.10 23:26:20	test EURCHF,H1: true || (false && false) = 1
Reason: