Cos'è order_id? - pagina 4

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

Questo è qui. Come vedete, nessun ordine di chiusura


 

Non vedo l'output di questa linea di codice. . stai eseguendo la versione corretta del tuo EA?

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

Sì. Uso MetaEditor dal mio software MT4.

Questo è tutto il mio codice. Avete qualche consiglio da darmi?

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);
 }
   
 

Credo che tu abbia bisogno di un ! in questa linea . . .

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

Devi sistemare questa linea, non ha senso... cosa dovrebbe fare?

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

Devi sistemare questa linea, non ha senso... cosa dovrebbe fare?

2012.11.01 19:16:00 2012.09.27 23:45 New USDCAD,M15: numero doppio non valido come parametro 1 per la funzione DoubleToStr
Potete dirmi cos'è questo errore?
 
toi10005doi:
2012.11.01 19:16:00 2012.09.27 23:45 New USDCAD,M15: numero doppio non valido come parametro 1 per la funzione DoubleToStr
Potete dirmi cos'è questo errore?
Il primo parametro che stai passando alla funzione DoubleToStr() non è valido . . . hai guardato la documentazione della funzione DoubleToSrt()? mostra la linea di codice che genera l'errore.
 
RaptorUK:
Il primo parametro che stai passando alla funzione DoubleToStr() non è valido . . . hai guardato la documentazione della funzione DoubleToSrt()? mostra la linea di codice che genera l'errore.

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);
 }
Questo è tutto il mio codice. Il MetaEditor nota tutto ok.
 
toi10005doi:
Questo è tutto il mio codice. Il MetaEditor nota tutto ok.

Questo è l'ultimo aiuto che vi do. . . devi leggere il libro e imparare le basi . . .

Perché queste variabili sono stringhe?

   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:

Sì, ma ho capito male perché ho appena iniziato a scrivere EA. Sr per il disturbo.

Non capisco perché il mio ordine si chiude istantaneamente dopo che è partito.

In questo post non erano stringhe . . .

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