What is order_id ?

 

I do not know what is "order_id" in orderclose.

Please help me!

 
toi10005doi:

I do not know what is "order_id" in orderclose.

Please help me!

There is no "order_id" in OrderClose()
 
In the example on OrderClose() it's the ticket number which you want to close. If you want to close the the order which has already been selected by OrderSelect(), then just use OrderTicket().
 

Thank everybody! :))

Can you show me an example, please. 

 
toi10005doi:

Thank everybody! :))

Can you show me an example, please. 

You will find examples in this thread:  Loops and Closing or Deleting Orders
 

My EA just do 1 order per time. So, please show me the code close it when the conditon done.

Thank!! 

 
toi10005doi:

My EA just do 1 order per time. So, please show me the code close it when the conditon done.

Thank!! 


There is no EA closing several trades the same moment..... It is always done one by one

How to close correctly selected trades read  Loops and Closing or Deleting Orders

 
<SNIP>

 

Please tell me what's wrong with my code!! Thank.

 
toi10005doi:

<SNIP>

 

Please tell me what's wrong with my code!! Thank.

Please edit your post . . . 


Please use this to post code . . . it makes it easier to read.

 
RaptorUK:
You will find examples in this thread:  Loops and Closing or Deleting Orders


toi10005doi:

for(i=1; i<=OrdersTotal(); i++)

 

Please tell me what's wrong with my code!! Thank.


Did you bother to read the thread I gave a link to ?  
 

@Raptor:

Yes, But i harly undertood because i just star to write EA. Sr for bother you.

int start()
{
   int i ,times;
   double DIPlus1;
   double DIPlus0;
 
   double DIMinus1;
   double DIMinus0;
   
   double Main1;
   double Main0;
   
   double MACD_main;
   double MACD_signal;
   double Rsi;
   
   double err = 25;
   
   int MagicNumber1=220101,MagicNumber2=220102;
//----

//---
 
DIPlus1=iADX(NULL,0,14,PRICE_CLOSE,MODE_PLUSDI,1);
DIPlus0=iADX(NULL,0,14,PRICE_CLOSE,MODE_PLUSDI,0);
 
DIMinus1=iADX(NULL,0,14,PRICE_CLOSE,MODE_MINUSDI,1);
DIMinus0=iADX(NULL,0,14,PRICE_CLOSE,MODE_MINUSDI,0);

Main1=iADX(NULL,0,14,PRICE_CLOSE,MODE_MAIN,1);
Main0=iADX(NULL,0,14,PRICE_CLOSE,MODE_MAIN,0);

Rsi = iRSI(NULL,0,14,PRICE_CLOSE,0);

times = Minute() % 15 ==0 && Seconds() ==0;

//MACD_main = iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0); 
//MACD_signal = iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0);
   
//----
if(Minute() % 15 ==0 && Seconds() ==0)
{
  if( Main0 > err && Main1 < err && DIPlus0 > DIMinus0 && Rsi < 70 )

    
       OrderSend(Symbol(),OP_BUY,0.03,Ask,5,Ask-300*Point,Ask+300*Point,"","",1,Blue);
          
   

   if (Main0 > err && Main1 < err && DIPlus0 < DIMinus0  && Rsi > 30)
     
       OrderSend(Symbol(),OP_SELL,0.03,Bid,5,Bid+300*Point ,Bid-300*Point,"","",2,Red);
     
  //---
  if(OrdersTotal()>0)
      {
      for(i=1; i<=OrdersTotal(); i++)
      
         {        
            if (OrderSelect(i-1,SELECT_BY_POS)==true)
                  
             {
               if(Rsi >=70 )  
                  OrderClose(OrderTicket(),OrderLots(),Bid,2,Green); 
              if( DIPlus1 > DIMinus1 )
                   OrderClose(OrderTicket(),OrderLots(),Bid,2,Green); 
               
                if(Rsi <=30  )
                  OrderClose(OrderTicket(),OrderLots(),Ask,1,Green); 
              if( DIPlus1 < DIMinus1  )
                   OrderClose(OrderTicket(),OrderLots(),Ask,1,Green); 
            
                   
             }       
         }
       }  
   }
 return(0);
 }
   

 I don't understand why my order close instantly after it star.