¡¡¡El EA que escribí hace tres meses no puede pasar las pruebas de estrategia ahora, pero solía funcionar bien hace dos o tres meses!!! - página 3

 

Foro sobre trading, sistemas automatizados de trading y prueba de estrategias de trading


angevoyageur, 2014.02.11 17:59

Hola,

Por favor, utiliza el botón SRC cuando publiques el código. Gracias.


Esta vez te lo he editado.


 
jitanic:

hola

enviar la orden funciona en la cuenta demo pero en la cuenta real no funciona(2014.11.30 18:21:00.062 55 (اخابر,D1) BuyA: error 4756, retcode = 10006)


¿Por qué estás usando esa notación, es difícil de entender :

   request.action=5;
   request.type=6;
   request.type_filling=2;

usando eso en su lugar :

   request.action=TRADE_ACTION_PENDING;
   request.type=ORDER_TYPE_BUY_STOP_LIMIT;
   request.type_filling=ORDER_FILLING_RETURN;  

Por cierto, en cualquier caso me funciona.


 

Lo siento.

por favor revise este script y deme mi error:

#property description "Expert Advisor for sending trade requests "
" using OrderSendAsync() function.\r\n"
#property description "Handling trading events using"
" OnTrade() and OnTradeTransaction() handler functions is displayed\r\n"
#property description "Expert Advisor parameters allow setting Magic Number"
" (unique ID) "
#property description "and the mode of displaying messages in Experts log. All details are displayed by default.\r\n"
input int  MagicNumber=1234567;      // Expert Advisor ID
input bool DescriptionModeFull=true; // Detailed output mode
input double  Price=2652;
input double  Volume=1000;
input double  stoplimit=2681;
input double  sl=1000;
input double  tp=2681;
//+------------------------------------------------------------------+
int OnInit()
  {
//--- check if autotrading is allowed
   if(!TerminalInfoInteger(TERMINAL_TRADE_ALLOWED))
     {
      Alert("Autotrading in the terminal is disabled, Expert Advisor will be removed.");
      ExpertRemove();
      //--     return(-1);
     }
   CreateBuySellButtons();
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   ObjectDelete(0,"Buy");
   ObjectDelete(0,"Sell");
   ObjectDelete(0,"HALL");
  }
//+------------------------------------------------------------------+
void OnTradeTransaction(const MqlTradeTransaction &trans,
                        const MqlTradeRequest &request,
                        const MqlTradeResult &result)
  {

  }
//+------------------------------------------------------------------+
void OnTrade()
  {

  }
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
//--- handling CHARTEVENT_CLICK event ("Clicking the chart")
   if(id==CHARTEVENT_OBJECT_CLICK)
     {
      //--- if "Buy" button is pressed, then buy
      if(sparam=="Buy")
        {
         BuyA(Volume);
         //--- unpress the button
         ObjectSetInteger(0,"Buy",OBJPROP_STATE,false);
        }
      //--- if "Sell" button is pressed, then sell
      if(sparam=="Sell")
        {
         SellA(Volume);
         //--- unpress the button
         ObjectSetInteger(0,"Sell",OBJPROP_STATE,false);
        }
      ChartRedraw();
     }
  }
//+------------------------------------------------------------------+
void CreateBuySellButtons()
  {
   ObjectCreate(0,"Buy",OBJ_BUTTON,0,0,0); // create "Buy" button
   ObjectSetInteger(0,"Buy",OBJPROP_CORNER,CORNER_RIGHT_UPPER);
   ObjectSetInteger(0,"Buy",OBJPROP_XDISTANCE,100);
   ObjectSetInteger(0,"Buy",OBJPROP_YDISTANCE,50);
   ObjectSetInteger(0,"Buy",OBJPROP_XSIZE,70);
   ObjectSetInteger(0,"Buy",OBJPROP_YSIZE,30);
   ObjectSetString(0,"Buy",OBJPROP_TEXT,"Buy");
   ObjectSetInteger(0,"Buy",OBJPROP_COLOR,clrRed);
   ObjectCreate(0,"Sell",OBJ_BUTTON,0,0,0); // create "Sell" button
   ObjectSetInteger(0,"Sell",OBJPROP_CORNER,CORNER_RIGHT_UPPER);
   ObjectSetInteger(0,"Sell",OBJPROP_XDISTANCE,100);
   ObjectSetInteger(0,"Sell",OBJPROP_YDISTANCE,100);
   ObjectSetInteger(0,"Sell",OBJPROP_XSIZE,70);
   ObjectSetInteger(0,"Sell",OBJPROP_YSIZE,30);
   ObjectSetString(0,"Sell",OBJPROP_TEXT,"Sell");
   ObjectSetInteger(0,"Sell",OBJPROP_COLOR,clrBlue);
   ObjectCreate(0,"HALL",OBJ_LABEL,0,0,0); // create LABEL
   ObjectSetInteger(0,"HALL",OBJPROP_CORNER,CORNER_RIGHT_UPPER);
   ObjectSetInteger(0,"HALL",OBJPROP_XDISTANCE,100);
   ObjectSetInteger(0,"HALL",OBJPROP_YDISTANCE,150);
   ObjectSetInteger(0,"HALL",OBJPROP_XSIZE,70);
   ObjectSetInteger(0,"HALL",OBJPROP_YSIZE,30);
   ObjectSetString(0,"HALL",OBJPROP_TEXT,_Symbol);
   ObjectSetInteger(0,"HALL",OBJPROP_COLOR,clrBlue);
   ChartRedraw();
  }
//+------------------------------------------------------------------+
void BuyA(double volume)
  {
//--- prepare the request
   MqlTradeRequest request;
   MqlTradeResult  result;
   MqlTradeCheckResult check;
   ZeroMemory(request);
   ZeroMemory(result);
   ZeroMemory(check);
   request.action=TRADE_ACTION_PENDING;
   request.symbol=_Symbol;
   request.volume=1000.00;
  request.price=2652.000;
   request.stoplimit=2652.000;
   request.sl=0;
   request.tp=0;
request.type=ORDER_TYPE_BUY_STOP_LIMIT;
request.type_filling=ORDER_FILLING_RETURN; 
   request.type_time=0;
   request.expiration=0;
  request.magic=0;
request.comment="";
   if(!OrderSend(request,result))
     {
      Print(__FUNCTION__,": error ",GetLastError(),", retcode = ",result.retcode);
     }
//---
  }
//+------------------------------------------------------------------+
void SellA(double volume)
  {
//--- prepare the request
   MqlTradeRequest request;
   request.action=TRADE_ACTION_DEAL;
   request.symbol=_Symbol;
   request.magic=0;
   request.volume=Volume;
   request.type=ORDER_TYPE_SELL;
   request.price=SymbolInfoDouble(request.symbol,SYMBOL_BID);
   request.deviation=10;
   request.comment="Sell using OrderSendAsync()";
   MqlTradeResult  result;
   if(!OrderSendAsync(request,result))
     {
      Print(__FUNCTION__,": error ",GetLastError(),", retcode = ",result.retcode);
     }
  }
//+------------------------------------------------------------------+
 
jitanic:

Lo siento.

por favor revise este script y deme mi error:

Funciona para mí. He utilizado TadbirTrader-Server para probarlo.
 
angevoyageur:
A mi me funciona. He utilizado TadbirTrader-Server para probarlo.
¿¡Tienes una cuenta real o lo compruebas en una cuenta demo?!
Documentation on MQL5: Standard Constants, Enumerations and Structures / Environment State / Account Properties
Documentation on MQL5: Standard Constants, Enumerations and Structures / Environment State / Account Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Environment State / Account Properties - Reference on algorithmic/automated trading language for MetaTrader 5
 
jitanic:
¿¡tiene usted cuenta real o lo comprueba en la cuenta demo?!

Sólo cuenta demo.

P.D: Perdón por no haber dicho que también funciona en la cuenta demo para ti.

¿Qué valor se devuelve en su cuenta real por :

   printf("expiration=%i",SymbolInfoInteger(_Symbol,SYMBOL_EXPIRATION_MODE));
   printf("filling=%i",SymbolInfoInteger(_Symbol,SYMBOL_FILLING_MODE));
 

a mi me funciona en la demo,

¿puede estar restringido desde el servidor?

 
jitanic:

a mi me funciona en la demo,

¿puede estar restringido desde el servidor?

Obviamente, hay algo que restringe la colocación de esta orden pendiente. Probablemente algunos ajustes diferentes para este símbolo en la cuenta real (ver mi post anterior).

Error 10006: solicitud rechazada no es un mensaje muy útil. ¿Cuántas veces ha intentado colocar esta orden?

El precio actual de compra/venta/último en la cuenta demo es 2638/2652/2640, ¿es el mismo en la cuenta real?

 
angevoyageur:

Obviamente hay algo que te restringe a colocar esta orden pendiente. Probablemente algunos ajustes diferentes para este símbolo en la cuenta real (ver mi post anterior).

Error 10006 : solicitud rechazada no es un mensaje muy útil. ¿Cuántas veces ha intentado colocar esta orden?

El precio actual de compra/venta/último en la cuenta demo es 2638/2652/2640, ¿es el mismo en la cuenta real?

hola gracias por la respuesta

Adjunto imagen de las propiedades del símbolo

si no ayuda, me dijo: ¿dónde insertar la orden de impresión en mi código?

Archivos adjuntos:
Untitled.png  47 kb
 
jitanic:

hola gracias por la respuesta

Adjunto imagen de las propiedades del símbolo

si no ayuda, me dice: ¿dónde insertar la orden de impresión en mi código?

No puedo ver por qué no funciona.

¿Puedes probar de nuevo, ahora? ¿Sigue sin funcionar?