[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 44

 
yar4i писал(а) >>

Please advise how to cure the error that occurs during EA optimization: "There were 1 passes done during optimization, 1 results have been discarded as insignificant".

Uncheck "Skip useless results" in the tab "Optimization results".

 

To Integer

Is that something for the comrade to remember forever? :-)

 

To Integer

Nothing even showed up in my optimization results :(

I used the simple Expert Advisor from this article My first "grail"

 
yar4i >> :

To Integer

Nothing even showed up in my optimization results :(

I used a simple EA from this article My first "grail"

Does a simple run make deals?

 

Hi all!

Guru, please advise - how can I select the last closed order using the OrderSelect() or OrderHistoryTotal() function?

 

Help please!!!!!!!!

When compiling the Expert Advisor I get error 'MagicNumber' - variable not defined C:\Program Files\MetaTrader - Alpari\experts\expertCCI_RSI.mq4 (40, 27).

I've tried everything, it does not work at all.......

//+------------------------------------------------------------------+
//|                                                expertCCI_RSI.mq4 |
//|                      Copyright © 2009, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

//---- input parameters
extern int       pCCI=14;
extern int       pRSI=14;
extern double    Lots=0.1;
extern int       MagicNamber=50001;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
  
bool CheckOrders(int Type)
{
 bool Result= True;
 for(int i=0; i<OrdersTotal(); i++)
  if(OrderSelect( i, SELECT_BY_POS))
   if(OrderMagicNumber()== MagicNumber && OrderSymbol() == Symbol())
      if(OrderType()== Type)
        {
         if( Type==OP_BUY)
           if(!OrderClose(OrderTicket(),OrderLots(),Bid,0))
             Result= False;
         if( Type==OP_SELL)
           if(!OrderClose(OrderTicket(),OrderLots(),Ask,0))
             Result= False;
         } 
        else Result= False;
 return( Result); 
}
  
  
  
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
    double cci_0=iCCI(NULL,0, pCCI,1,0);
    double cci_1=iCCI(NULL,0, pCCI,1,1);
    double rsi_0=iRSI(NULL,0, pRSI,1,0);
    double rsi_1=iRSI(NULL,0, pRSI,1,1);
    
    if(( cci_0 < cci_1 && cci_0 > 100) && ( rsi_0 < rsi_1 && rsi_0 > 70))
     if( CheckOrders(OP_SELL))
      {
       if(!OrderSend(Symbol(), OP_BUY, Lots, Ask, 3, 0, 0, NULL, MagicNumber))
         Print("Не открыт ордер Buy. Ошибка №", GetLastError()); 
       }
       
    if(( cci_0 > cci_1 && cci_0 < -100) && ( rsi_0 > rsi_1 && rsi_0 < 30))
     if( CheckOrders(OP_BUY))
      {
       if(!OrderSend(Symbol(), OP_SELL, Lots, Bid, 3, 0, 0, NULL, MagicNumber))
         Print("Не открыт ордер Sell. Ошибка №", GetLastError()); 
       }

//----
   return(0);
  }
//+------------------------------------------------------------------+
 
extern int       MagicNa mber=50001;

 
xruss писал(а) >>

Hi all!

Guru, please advise - how can I select the last closed order with OrderSelect() or OrderHistoryTotal()?

// ищем самый последний закрытый ордер
for( i=OrdersHistoryTotal(); i>=0; i--){
  if(OrderSelect( i, SELECT_BY_POS, MODE_HISTORY)){
    if(OrderSymbol()==Symbol()){
      if(OrderMagicNumber()== MagicNumber){
        if(OrderCloseTime()!=0){
          if(OrderCloseTime()> time){
            time=OrderCloseTime();
            tikcet=OrderTicket();
            profit=OrderProfit();
          }
        }
      }
    }
  }
}
 

To xrust:

))

If I don't use a magic number, what should I write instead?

 
granit77 >> :

Does it make trades in a simple run?

No trades were made, there was a problem with setting stops, because error 130 is showing up.

I searched and finally found out that stop was set to 100, I set it to 1000 - everything is ok, but optimization is still not working :(

Reason: