[¡AVISO CERRADO!] Cualquier pregunta de novato, para no saturar el foro. Profesionales, no pasen. No puedo ir a ningún sitio sin ti. - página 286

 

Hola. ¿Me pueden decir si hay un EA que marque los puntos de entrada y salida en el gráfico, como en el probador de estrategias?

 

Y manualmente, ¿qué hay de malo en ello? Lleve las operaciones del historial de la cuenta con el ratón al gráfico y se indicarán allí.

O utilice el script - http://www.kimiv.ru/index.php?option=com_remository&Itemid=13&func=fileinfo&id=32

 
TheXpert >> :

ShellExecute, comando "open", por ejemplo


Gracias
 
rid >> :

Debe colocarse en el exterior. No dentro de ninguna función, sino como una función separada e independiente.

Puedes ir así:


No estoy seguro de que el EA funcione en estas condiciones. Porque la primera posición no podrá abrir...

La función isCloseLastPosByTake() debe ser eliminada de una condición de compra o venta.

Entonces funciona.

el código de un EA con correcciones según la recomendación de rid sólo el inicio

//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
    // Узнаем уровень стопов и спрэд
    int Spread = MarketInfo(Symbol(), MODE_SPREAD);
    int StopLevel = MarketInfo(Symbol(), MODE_STOPLEVEL);

    // Рассчитываем значения средних на 0-ом и 1-ом барах
    double MAF_0 = iMA(NULL, 0, MAFP, 0, 1, 1, 0);
    double MAF_1 = iMA(NULL, 0, MAFP, 0, 1, 1, 1);
    double MAS_0 = iMA(NULL, 0, MASP, 0, 1, 1, 0);
    double MAS_1 = iMA(NULL, 0, MASP, 0, 1, 1, 1);
    
   // открытие позиции Buy покупка
    if( MAF_1 < MAS_1 && MAF_0 > MAS_0)                         {
    if( isCloseLastPosByTake( NULL, OP_SELL, MagicNumber) ==true) {
     if( CheckOrders(OP_SELL))                                      {
       if( StopLoss <= StopLevel+ Spread)
         double SL = 0;        else         SL = Ask - StopLoss*Point;
       if( TakeProfit <= StopLevel- Spread)
         double TP = 0;        else         TP = Ask + TakeProfit*Point;
       if(!OrderSend(Symbol(), OP_BUY, Lots, Ask, 5, SL, TP, NULL, MagicNumber))
         Print("Не открыт ордер Buy. Ошибка №", GetLastError()); 
                }
               }
              }
//-------------------Конец покупки -----------------------
    
  //  ----- Открытие позиции Sell продажа------------  
    if( MAF_1 > MAS_1 && MAF_0 < MAS_0)                         {
    if( CheckOrders(OP_BUY))                                     {
      if( StopLoss <= StopLevel+ Spread)
         SL = 0;        else         SL = Bid + StopLoss*Point;
       if( TakeProfit <= StopLevel- Spread)
         TP = 0;        else         TP = Bid - TakeProfit*Point;
       if(!OrderSend(Symbol(), OP_SELL, Lots, Bid, 5, SL, TP, NULL, MagicNumber))
         Print("Не открыт ордер Sell. Ошибка №", GetLastError()); 
                 }
                }
               }
      //---конец блока продажи ------------------------------
     
//----
   return(0);
  }//+----------КОНЕЦ ФУНКЦИИ СТАРТ -------------------+

//ЖЖЖЖЖЖЖ Другие вызываемые пользовательские функции ЖЖЖЖЖЖ
//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 19.05.2008                                                     |
//|  Описание : Возвращает флаг закрытия           |
//|  последней позиции по тейку.                                    |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    sy - наименование инструмента   (""   - любой символ,                   |
//|                                     NULL - текущий символ)                 |
//|    op - операция                   (-1   - любая позиция)                  |
//|    mn - MagicNumber                (-1   - любой магик)                    |
//+----------------------------------------------------------------------------+
bool isCloseLastPosByTake(string sy="", int op=-1, int mn=-1) {
  datetime t;
  double   ocp, otp;
  int      dg, i, j=-1, k=OrdersHistoryTotal();

  if ( sy=="0") sy=Symbol();
  for ( i=0; i< k; i++) {
    if (OrderSelect( i, SELECT_BY_POS, MODE_HISTORY)) {
      if (OrderSymbol()== sy || sy=="") {
        if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
          if ( op<0 || OrderType()== op) {
            if ( mn<0 || OrderMagicNumber()== mn) {
              if ( t<OrderCloseTime()) {
                t=OrderCloseTime();
                j= i;
              }} }}}}}

  if (OrderSelect( j, SELECT_BY_POS, MODE_HISTORY)) {
    dg=MarketInfo( sy, MODE_DIGITS);
    if ( dg==0) if (StringFind(OrderSymbol(), "JPY")<0) dg=4; else dg=2;
    ocp=NormalizeDouble(OrderClosePrice(), dg);
    otp=NormalizeDouble(OrderTakeProfit(), dg);
    if ( ocp== otp) return( True);
  }
  return( False);
}
 

Me dio un error al compilarlo.

2;73;C:\Program Files\MetaTrader - Alpari\experts\SimpleMA22333.mq4;103:3;'}' - unbalanced parentheses

este lugar está marcado * ayuda a la gente buena.....

   return(0);
 * }//+----------КОНЕЦ ФУНКЦИИ СТАРТ -------------------+
 
igrok2008 писал(а) >>

Me dio un error al compilarlo.

este lugar está marcado * ayuda a la gente buena.....

El número de llaves es diferente en la función de inicio

//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start() {
    // Узнаем уровень стопов и спрэд
    int Spread = MarketInfo(Symbol(), MODE_SPREAD);
    int StopLevel = MarketInfo(Symbol(), MODE_STOPLEVEL);

    // Рассчитываем значения средних на 0-ом и 1-ом барах
    double MAF_0 = iMA(NULL, 0, MAFP, 0, 1, 1, 0);
    double MAF_1 = iMA(NULL, 0, MAFP, 0, 1, 1, 1);
    double MAS_0 = iMA(NULL, 0, MASP, 0, 1, 1, 0);
    double MAS_1 = iMA(NULL, 0, MASP, 0, 1, 1, 1);
    
   // открытие позиции Buy покупка
    if( MAF_1 < MAS_1 && MAF_0 > MAS_0)                         {
        if( isCloseLastPosByTake( NULL, OP_SELL, MagicNumber) ==true) {
            if( CheckOrders(OP_SELL))                                      {
                if( StopLoss <= StopLevel+ Spread)   double SL = 0;        else         SL = Ask - StopLoss*Point;
                if( TakeProfit <= StopLevel- Spread) double TP = 0;        else         TP = Ask + TakeProfit*Point;
                if(!OrderSend(Symbol(), OP_BUY, Lots, Ask, 5, SL, TP, NULL, MagicNumber))
                    Print("Не открыт ордер Buy. Ошибка №", GetLastError()); 
            }
        }
    }
    //-------------------Конец покупки -----------------------
    
    //  ----- Открытие позиции Sell продажа------------  
    if( MAF_1 > MAS_1 && MAF_0 < MAS_0)                         {
        if( isCloseLastPosByTake( NULL, OP_BUY, MagicNumber) ==true) {
            if( CheckOrders(OP_BUY))                                     {
               if( StopLoss <= StopLevel+ Spread)             SL = 0;        else         SL = Bid + StopLoss*Point;
               if( TakeProfit <= StopLevel- Spread)           TP = 0;        else         TP = Bid - TakeProfit*Point;
               if(!OrderSend(Symbol(), OP_SELL, Lots, Bid, 5, SL, TP, NULL, MagicNumber))
                   Print("Не открыт ордер Sell. Ошибка №", GetLastError()); 
            }
        }
    }
    //---конец блока продажи ------------------------------
    
    return(0);
}//+----------КОНЕЦ ФУНКЦИИ СТАРТ -------------------+
Algo así debe haber sucedido. No entró en la lógica
 
igrok2008 >> :

aquí está el código de Expert Advisor con correcciones por recomendación de rid


Quite el corchete extra de la caja de ventas. Te dije que el número de paréntesis de apertura debe ser igual al número de paréntesis de cierre. Y tienes dos soportes abiertos y tres cerrados.

Y, por supuesto, habrá un error de compilación.

 
rid >> :

Quite el corchete extra de la caja de ventas. Te dije que el número de paréntesis de apertura debe ser igual al número de paréntesis de cierre. ¡Pero tienes dos soportes abiertos y tres cerrados!

Y, por supuesto, habrá un error de compilación.

Y el paréntesis inicial es lo que ????


aaaaaaahhhh, lo tengo, es {.........-!!!!!!!!!!!!!!} :-)))))))

Voy a probar......... En todo caso, no juzgue, voy a tratar de hacer preguntas.

 
igrok2008 писал(а) >>

Y los paréntesis de apertura son lo que????

¡¡¡¡¡¡¡¡¡¡¡¡¡¡aaaaaaaaaaaa y es {.........-!!!!!!!!!!!!!! :-)))))))

Estaré probando......... En todo caso, no me culpes, haré preguntas.

Pensé que había hecho una revisión.

 

Ese arreglo no funcionará. No podrá abrir la primera operación. ¡Porque la condición para abrir la primera operación en su variante es cerrar cualquier operación anterior en la toma o en el stop!

Es decir, un círculo vicioso.