function definition unexpected ????? - page 3

 
RaptorUK:

ticket and ticket2 are globally declared,  you don't need to pass then when you call the function . . .

change these

to these 


there is something wrong white the function  and now its driving me nuts )-;

 i been trying also to put  it like thise ,but it refuse to work (the code ok there is no error)

code:

 
 bool ClosePendingOrder(string symbol )
 {
    
     //int ticket2;
     OrderSelect(ticket, SELECT_BY_TICKET);
         
        
         if (ticket > 0 && OrderType()==OP_BUY)
             {
              OrderSelect(ticket2,SELECT_BY_POS);
             //  }
               //if (ticket2>0 && OrderType() !=OP_SELL) 
                  
             //  {    
                  bool orderx= OrderDelete(ticket2,Red);   
             } 
     return(0);
              
    }
 

 thanks!

 
er007:


there is something wrong white the function  and now its driving me nuts )-;

 i been trying also to put  it like thise ,but it refuse to work (the code ok there is no error)

What does it do ?  what does it not do ?  don't just say "it doesn't work"  be specific . . .

 
Try this . . .

void ClosePendingOrder(string symbol )
   {
   OrderSelect(ticket, SELECT_BY_TICKET);
        
   if (ticket > 0 && OrderType()==OP_BUY)
      {
      if ( OrderSelect(ticket2, SELECT_BY_TICKET ) && 
      OrderType() == OP_SELLLIMIT || OrderType() == OP_SELLSTOP ) 
         {    
         if( !OrderDelete(ticket2,Red) )    
            {
            Print("OrderDelete failed, ticket ", ticket2, " Error # ", GetLastError() );
            }    
         } 
      }
   return;
   }

 Your 2nd OrderSelect()  was wwrong,  select by ticket not by POSITION . . . .   read the Documentation  OrderSelect()

 
RaptorUK:

What does it do ?  what does it not do ?  don't just say "it doesn't work"  be specific . . .

 
Try this . . .

 Your 2nd OrderSelect()  was wwrong,  select by ticket not by POSITION . . . .   read the Documentation  OrderSelect()

it give an 4108 error:

 https://www.mql5.com/en/forum/119826

 and i got thise on also:

 2013.01.20 20:25:24 2012.11.02 00:00  10 point test GBPUSD,Daily: unknown ticket 40 for OrderDelete function

 it didn't delete any STOP_SELL ORDER.

 

does someone know how to dell white thise one?(except taking the screen and drop it out of the window (-;)  


 
er007:

it give an 4108 error:

 https://www.mql5.com/en/forum/119826

 and i got thise on also:

 2013.01.20 20:25:24 2012.11.02 00:00  10 point test GBPUSD,Daily: unknown ticket 40 for OrderDelete function

 it didn't delete any STOP_SELL ORDER.

 

does someone know how to dell white thise one?(except taking the screen and drop it out of the window (-;)  



ERR_INVALID_TICKET4108Invalid ticket.

RaptorUK 

 do you mind if i will open new thread for thise error?

thanks 

 
er007:

ERR_INVALID_TICKET4108Invalid ticket.

RaptorUK 

 do you mind if i will open new thread for thise error?

thanks 

That's a good idea the original issue has been addressed.
 
One thing worth mentioning . . .  it's not clear from your code under which circumstances a pending order should be deleted,  your Buy and Sell pending orders are not placed as a pair,  there are different conditions under which they are placed, so there is no simple logical way to determine that they are a pair,  so if there is only one pending order how do you know if it is to be left open or deleted ?
 
RaptorUK:
One thing worth mentioning . . .  it's not clear from your code under which circumstances a pending order should be deleted,  your Buy and Sell pending orders are not placed as a pair,  there are different conditions under which they are placed, so there is no simple logical way to determine that they are a pair,  so if there is only one pending order how do you know if it is to be left open or deleted ?


the expert open every new candle 2 pending orders one at the high of the previous candle , and one at low of the previous candle, no meter what time frame that is the basic logic ,every new candle 2 pending and pending from the last bar expire. and so on.

 

i think may by i am  missing orderselect on the function before the delete order(i changed it and added a  selectorder ,no error any more but not working also so...) 

the idea came from here:

 

 https://www.mql5.com/en/forum/130539

 

is it possible  in order to delete one pending to use only ticket instead  (ticket1 ,ticket 2 ) ?

thanks! 

 
er007:


the expert open every new candle 2 pending orders one at the high of the previous candle , and one at low of the previous candle, no meter what time frame that is the basic logic ,every new candle 2 pending and pending from the last bar expire. and so on.


That may be what you intended but that isn't what your code will always produce.  You have the following conditions:

   if  (Check1 >= Threshold && Check2 >= Threshold && O < H)     
      {    
      ticket = OrderSend(Symbol(), OP_BUYSTOP, Lot, H + P + Spread, 0, H + P - SL + Spread, H + P + TP + Spread, NULL, 0, iTime( Symbol(), PERIOD_D1, 0 ) + 86400);


   
   //================================ condition for ORDER SELL ==================== 

   if(Check1 >= Threshold && Check2 >= Threshold && O > L)  
      {   
      ticket = OrderSend(Symbol(), OP_SELLSTOP, Lot, L - P, 0, L - P + SL, L - P - TP, NULL,0,iTime( Symbol(), PERIOD_D1, 0 ) + 86400);

The Check1 and Check2 tests are common to Buy and Sell pending orders  but you then have a test of Open[0] vs High[1] and Open[0] vs Low[1]  so, for example,  if Bar 1 closes at it's High and Bar 0 opens at that same price or higher you may get a OP_SELLSTOP but not an OP_BUYSTOP.  

 

Look at the code,  tell me I am wrong ? ?

Reason: