What is order_id ? - page 4

 
2012.11.01 00:13:27 2012.09.27 15:33  Tester: take profit #13 at 1765.27 (1765.27 / 1765.80)
2012.11.01 00:13:27 2012.09.27 15:33  Tester: take profit #12 at 1765.25 (1765.27 / 1765.80)
2012.11.01 00:13:27 2012.09.27 15:15  ADX XAUUSD,M15: open #13 buy 0.03 XAUUSD at 1762.27 sl: 1759.27 tp: 1765.27 ok
2012.11.01 00:13:27 2012.09.27 15:15  ADX XAUUSD,M15: open #12 buy 0.03 XAUUSD at 1762.25 sl: 1759.25 tp: 1765.25 ok
2012.11.01 00:13:27 2012.09.27 13:20  Tester: stop loss #11 at 1754.73 (1754.67 / 1755.20)
2012.11.01 00:13:25 2012.09.27 08:30  ADX XAUUSD,M15: open #11 buy 0.03 XAUUSD at 1757.73 sl: 1754.73 tp: 1760.73 ok
2012.11.01 00:13:25 2012.09.27 08:24  Tester: stop loss #10 at 1757.50 (1756.97 / 1757.50)
2012.11.01 00:13:24 2012.09.27 06:15  ADX XAUUSD,M15: open #10 sell 0.03 XAUUSD at 1754.50 sl: 1757.50 tp: 1751.50 ok
2012.11.01 00:13:23 2012.09.27 04:15  Tester: take profit #8 at 1756.40 (1756.41 / 1756.94)
2012.11.01 00:13:23 2012.09.27 04:14  Tester: take profit #9 at 1755.93 (1755.94 / 1756.47)
2012.11.01 00:13:22 2012.09.26 23:45  ADX XAUUSD,M15: open #9 buy 0.03 XAUUSD at 1752.93 sl: 1749.93 tp: 1755.93 ok
2012.11.01 00:13:21 2012.09.26 21:45  ADX XAUUSD,M15: open #8 buy 0.03 XAUUSD at 1753.40 sl: 1750.40 tp: 1756.40 ok
2012.11.01 00:13:14 2012.09.26 14:37  Tester: stop loss #6 at 1760.83 (1760.80 / 1761.33)
2012.11.01 00:13:10 2012.09.26 07:32  Tester: stop loss #7 at 1761.54 (1761.52 / 1762.05)
2012.11.01 00:13:10 2012.09.26 05:15  ADX XAUUSD,M15: open #7 buy 0.03 XAUUSD at 1764.54 sl: 1761.54 tp: 1767.54 ok
2012.11.01 00:13:10 2012.09.26 05:14  Tester: stop loss #4 at 1764.65 (1764.14 / 1764.67)
2012.11.01 00:13:09 2012.09.26 04:45  ADX XAUUSD,M15: open #6 buy 0.03 XAUUSD at 1763.83 sl: 1760.83 tp: 1766.83 ok
2012.11.01 00:13:09 2012.09.26 04:07  Tester: take profit #5 at 1762.74 (1762.77 / 1763.30)
2012.11.01 00:13:09 2012.09.26 03:15  ADX XAUUSD,M15: open #5 buy 0.03 XAUUSD at 1759.74 sl: 1756.74 tp: 1762.74 ok
2012.11.01 00:13:08 2012.09.26 02:00  ADX XAUUSD,M15: open #4 sell 0.03 XAUUSD at 1761.65 sl: 1764.65 tp: 1758.65 ok
2012.11.01 00:13:06 2012.09.25 19:42  Tester: stop loss #3 at 1761.53 (1761.51 / 1762.04)
2012.11.01 00:13:06 2012.09.25 19:30  ADX XAUUSD,M15: open #3 buy 0.03 XAUUSD at 1764.53 sl: 1761.53 tp: 1767.53 ok
2012.11.01 00:12:57 2012.09.25 03:57  Tester: stop loss #2 at 1767.82 (1767.30 / 1767.83)

That's here. As you see, no close order 


 

I don't see the output from this line of code . . .  are you running the correct version of your EA ?

Print("DIPlus1: ", DoubleToStr(DIPlus1, Digits), " DIMinus1: ", DoubleToStr(DIMinus1, Digits), " Main0: ",DoubleToStr(Main0, Digits), " Rsi: ",DoubleToStr(Rsi, Digits) );
 

Yes. I use MetaEditor from my MT4 software.

This is my whole code . Do you have any advice for me?

int start()
{
   int i ,times;
   string DIPlus1;
   string DIPlus0;
 
   string DIMinus1;
   string DIMinus0;
   
   string Main1;
   string Main0;
   string Main2;
   
   string MACD_main;
   string MACD_signal;
   string Rsi;
   
   string err = 26;
   string x = 70;
   string xx = 30;
   
   double sl = 300;
   double tp = 300;
   
   int MagicNumber1=1234,MagicNumber2=4321;
//----
/*DIPlus1=DoubleToStr(  DIPlus1, 4);
DIPlus0=DoubleToStr(    DIPlus0, 4);
DIMinus1=DoubleToStr(   DIMinus1, 4);
DIMinus0=DoubleToStr(   DIMinus0, 4);
Main1=DoubleToStr(      Main1, 4);
Main0=DoubleToStr(      Main0, 4);
Rsi=DoubleToStr(        Rsi, 4);
//err=DoubleToStr(err,4);
//x=DoubleToStr(x,4);
//xx=DoubleToStr(xx,4);*/

//---
 
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);
Main2=iADX(NULL,0,14,PRICE_CLOSE,MODE_MAIN,2);

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(DIPlus1 > DIMinus1)
         
           if( Main0 > err && Main1 < err &&   Rsi < x )

    
                OrderSend(Symbol(),OP_BUY,0.03,Ask,5,Ask-sl*Point,Ask+tp*Point,"",1234,0,Blue);
    }      
   
    {if(DIPlus1 < DIMinus1)
            if (Main0 > err && Main1 < err &&    Rsi > xx)
     
                OrderSend(Symbol(),OP_SELL,0.03,Bid,5,Bid+sl*Point ,Bid-tp*Point,"",4321,0,Red);
    }
}
     
  //---
 int PositionIndex;    
 
int TotalNumberOfOrders;  

TotalNumberOfOrders = OrdersTotal();   

for(PositionIndex = TotalNumberOfOrders - 1; PositionIndex >= 0 ; PositionIndex --)  
   {
   if(  OrderSelect(PositionIndex, SELECT_BY_POS, MODE_TRADES) ) continue;   
   
               Print("DIPlus1: ", DoubleToStr(DIPlus1, Digits), " DIMinus1: ", DoubleToStr(DIMinus1, Digits), " Main0: ",DoubleToStr(Main0, Digits), " Rsi: ",DoubleToStr(Rsi, Digits) );
   
               if( OrderMagicNumber() == MagicNumber2      
               && OrderSymbol() == Symbol()          
               && OrderType() == OP_BUY         
               || OrderType() == OP_SELL )  
                  {
                  if( DIPlus1 > DIMinus1 || Main0 < err || Rsi < xx)
                     {
                        if(! OrderClose(OrderTicket(),OrderLots(),Bid,3,Green))
                           Print("Order Close failed, order number: ", OrderTicket(), " Error: ", GetLastError() );
                     } 
                  }
               if( OrderMagicNumber() == MagicNumber1      
               && OrderSymbol() == Symbol()          
               &&  OrderType() == OP_BUY          
               || OrderType() == OP_SELL )  
                  { 
                     if( DIPlus1 < DIMinus1 || Main0 < err || Rsi > x  )
                        {
                           if(! OrderClose(OrderTicket(),OrderLots(),Ask,3,Green))  
                              Print("Order Close failed, order number: ", OrderTicket(), " Error: ", GetLastError() );
                        } 
                      
                  }

   
    }
 return(0);
 }
   
 

I think you need a   !   in this line . . . 

if( ! OrderSelect(PositionIndex, SELECT_BY_POS, MODE_TRADES) ) continue;   //  <--  modify this line
 

You need to sort out this line,  it makes no sense . . .  what is it supposed to be doing ?

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

You need to sort out this line,  it makes no sense . . .  what is it supposed to be doing ?

 

 

2012.11.01 19:16:00 2012.09.27 23:45  New USDCAD,M15: invalid double number as parameter 1 for DoubleToStr function
 Can you tell me what this error is ? 
 
toi10005doi:
2012.11.01 19:16:00 2012.09.27 23:45  New USDCAD,M15: invalid double number as parameter 1 for DoubleToStr function
 Can you tell me what this error is ? 
The first parameter you are passing to the DoubleToStr() function is invalid . . .  did you look at the documentation for the DoubleToSrt() function ?  show the line of code that generates the error.
 
RaptorUK:
The first parameter you are passing to the DoubleToStr() function is invalid . . .  did you look at the documentation for the DoubleToSrt() function ?  show the line of code that generates the error.

int start()
{
   int i ,times;
   string DIPlus1;
   string DIPlus0;
 
   string DIMinus1;
   string DIMinus0;
   
   string Main1;
   string Main0;
   
   string MACD_main;
   string MACD_signal;
   string Rsi;
   
   string err = 25;
   string x = 70;
   string xx = 30;
   
   double sl = 300;
   double tp = 100;
   
   int MagicNumber1=1234,MagicNumber2=4321;
//----
 
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)
      {
      if( DIPlus0 > DIMinus0  && Rsi < x )
         OrderSend(Symbol(),OP_BUY,0.03,Ask,5,Ask-sl*Point,Ask+tp*Point,"",MagicNumber1,0,Blue);
      
      if( DIPlus0 < DIMinus0  && Rsi > xx )
         OrderSend(Symbol(),OP_SELL,0.03,Bid,5,Bid+sl*Point ,Bid-tp*Point,"",MagicNumber2,0,Red);
      }     
      
   }
     
  //---
 int PositionIndex;    
 
int TotalNumberOfOrders;  

TotalNumberOfOrders = OrdersTotal();   

for(PositionIndex = TotalNumberOfOrders - 1; PositionIndex >= 0 ; PositionIndex --)  
   {
   if( ! OrderSelect(PositionIndex, SELECT_BY_POS, MODE_TRADES) ) continue;   
   
    Print("DIPlus1: ", DoubleToStr(DIPlus1, Digits), " DIMinus1: ", DoubleToStr(DIMinus1, Digits), " Main0: ",DoubleToStr(Main0, Digits), " Rsi: ",DoubleToStr(Rsi, Digits) );
  
  if(Minute() % 15 ==0 && Seconds() ==0)
       {
         if( OrderMagicNumber() == MagicNumber2      
            && OrderSymbol() == Symbol()          
            && ( OrderType() == OP_BUY           
            ||   OrderType() == OP_SELL ) )   
           {if( DIPlus0 > DIMinus0)
               {if ( ! OrderClose( OrderTicket(), OrderLots(), OrderClosePrice(), 3 ) )
                   Print("Order Close failed, order number: ", OrderTicket(), " Error: ", GetLastError() ); 
               }
            } 
         if( OrderMagicNumber() == MagicNumber1      
            && OrderSymbol() == Symbol()          
            && ( OrderType() == OP_BUY           
            ||   OrderType() == OP_SELL ) )   
          { if( DIPlus0 < DIMinus0)
               {  if ( ! OrderClose( OrderTicket(), OrderLots(), OrderClosePrice(), 3 ) )               
                  Print("Order Close failed, order number: ", OrderTicket(), " Error: ", GetLastError() ); 
               }
          } 
        }          
    }
 return(0);
 }
This is my whole code. The MetaEditor notice all ok.
 
toi10005doi:
This is my whole code. The MetaEditor notice all ok.

This is the last help I am giving you . . .  you need to read the Book and learn the basics . . .

Why are these variables strings ?

   string DIPlus1;
   string DIPlus0;
 
   string DIMinus1;
   string DIMinus0;
   
   string Main1;
   string Main0;
   
   string MACD_main;
   string MACD_signal;
   string Rsi;
   
   string err = 25;
   string x = 70;
   string xx = 30;
 
toi10005doi:

@Raptor:

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

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

In this post they were not strings . . .

 

   double DIPlus1;
   double DIPlus0;
 
   double DIMinus1;
   double DIMinus0;
   
   double Main1;
   double Main0;
   
   double MACD_main;
   double MACD_signal;
   double Rsi;