[ARCHIVO]Cualquier pregunta de novato, para no saturar el foro. Profesionales, no lo dejéis pasar. No puedo ir a ningún sitio sin ti - 5. - página 227

 

Estimados compañeros de profesión, necesito su ayuda (pli-is). Quiero hacer una función en mi EA que muestre una notificación en la esquina posterior de la pantalla sobre la tendencia actual en diferentes marcos de tiempo y la próxima reversión. Sin embargo, nunca he trabajado con la funciónComment y, por tanto, no puedo entender en qué me he equivocado. De todos modos, el código de abajo sólo muestra el mensaje "Tendencia W = Bajada", pero quiero que muestre la información para todos los demás TFs también.

¡void UPDN ()
{
if(LinearRegression(Symbol( ), LR_TFr_1, 0, Diver_Per_H1, 0) < 0) Comment("Tendencia H1 = Alcista");
if(Diverg(LR_TFr_1,0,Diver_Per_H1)<0) Comment("...!¡Pivote en H1 = Bajada");
if(LinearRegression(Symbol( ), LR_TFr_2, 0, Diver_Per_H4, 0) < 0) Comment("Tendencia H4 = Subida");
if(Diverg(LR_TFr_2,0,Diver_Per_H4)<0) Comment("...!Pivote en H4 = Bajada");
if(LinearRegression(Symbol( ), LR_TFr_3, 0, Diver_Per_D1, 0) < 0) Comment(" Tendencia D1 = Subida");
if(Diverg(LR_TFr_3,0,Diver_Per_D1)<0) Comment("..!Pivote en D1 = Bajada");
if(LinearRegression(Symbol( ), LR_TFr_4, 0, Diver_Per_W, 0) < 0) Comment("Tendencia W = Subida");
if(Diverg(LR_TFr_4,0,Diver_Per_W)<0) Comment("...!Pivote a W = Bajada");

if(LinearRegression(Symbol( ), LR_TFr_1, 0, Diver_Per_H1, 0) > 0) Comment("Tendencia H1 = Bajada");
if(Diverg(LR_TFr_1,0,Diver_Per_H1)>0) Comment("...!Pivote en H1 = Alcista");
if(LinearRegression(Symbol( ), LR_TFr_2, 0, Diver_Per_H4, 0) > 0) Comment("Tendencia H4 = Bajista");
if(Diverg(LR_TFr_2,0,Diver_Per_H4)>0) Comment("...!¡Pivote en H4 = Arriba");
if(LinearRegression(Symbol( ), LR_TFr_3, 0, Diver_Per_D1, 0) > 0) Comment("Tendencia D1 = Abajo");
if(Diverg(LR_TFr_3,0,Diver_Per_D1)>0) Comment("...!Pivote en D1 = Alcista");
if(LinearRegression(Symbol( ), LR_TFr_4, 0, Diver_Per_W, 0) > 0) Comment("Tendencia W = Bajista");
if(Diverg(LR_TFr_4,0,Diver_Per_W)>0) Comment("....W = Up");
return(0);
}

 
Optim:

Estimados colegas-profesionales, necesito su ayuda (pli-is). Quiero hacer una función en mi EA que muestre una notificación en la esquina posterior de la pantalla sobre la tendencia actual en diferentes marcos de tiempo y la próxima reversión. Sin embargo, nunca he trabajado con la función Comment y, por tanto, no puedo entender en qué me he equivocado. De todos modos, el código de abajo sólo muestra el mensaje "Tendencia W = Bajada" pero quiero que me informe de otros TFs.

void UPDN ()
{
if(LinearRegression(Symbol( ), LR_TFr_1, 0, Diverg_Per_H1, 0) < 0) Comment("Tendencia H1 = Alcista")
if(Diverg(LR_TFr_1,0,Diver_Per_H1)<0) Comment("...!Gira en H1 = Abajo");
if(LinearRegression(Symbol( ), LR_TFr_2, 0, Diverg_Per_H4, 0) < 0) Comment("Tendencia H4 = Alcista")
if(Diverg(LR_TFr_2,0,Diver_Per_H4)<0) Comment("...¡Inversión de tendencia H4 = Down")
if(LinearRegression(Symbol( ), LR_TFr_3, 0, Diver_Per_D1, 0) < 0) Comment("Tendencia D1 = Alcista")
if(Diverg(LR_TFr_3,0,Diver_Per_D1)<0) Comment("...!Pivot on D1 = Down");
if(LinearRegression(Symbol( ), LR_TFr_4, 0, Diver_Per_W, 0) < 0) Comment("Trend W = Up");
if(Diverg(LR_TFr_4,0,Diver_Per_W)<0) Comment(";)

if(LinearRegression(Symbol( ), LR_TFr_1, 0, Diverg_Per_H1, 0) > 0) Comment("Tendencia H1 = Abajo")
if(Diverg(LR_TFr_1,0,Diver_Per_H1)>0) Comment("...¡Inversión de la tendencia H1 = Alcista");
if(LinearRegression(Symbol( ), LR_TFr_2, 0, Diver_Per_H4, 0) > 0) Comment("Tendencia H4 = Baja")
if(Diverg(LR_TFr_2,0,Diver_Per_H4)>0) Comment("...¡Inversión de la tendencia H4 = Alcista");
if(LinearRegression(Symbol( ), LR_TFr_3, 0, Diver_Per_D1, 0) > 0) Comment("Tendencia D1 = Bajada")
if(Diverg(LR_TFr_3,0,Diver_Per_D1)>0) Comment("...!Pivot on D1 = Up");
if(LinearRegression(Symbol( ), LR_TFr_4, 0, Diver_Per_W, 0) > 0) Comment("Tendencia W = Abajo");
if(Diverg(LR_TFr_4,0,Diver_Per_W)>0) Comment("...!Diverg to W = Up")
return(0);
}


voidComentario(...)
La función emite un comentario definido por el usuario en la esquina superior izquierda del gráfico. Los parámetros pueden ser de cualquier tipo. El número de parámetros no puede superar los 64.

Las matrices no se pueden pasar a Comment(). Las matrices deben imprimirse elemento por elemento.

Los datos de tipo doble se emiten con 4 dígitos decimales después del punto. Para imprimir números con mayor precisión, utilice la funciónDoubleToStr().
Los tipos bool, datetime y color se imprimirán como números.
Para obtener datos de fecha y hora en forma de cadena, utilice la funciónTimeToStr().

Para dividir la salida en varias líneas, puede utilizar el carácter de avance de línea "\n" o "\r\n".
Véase tambiénAlert() yPrint().
Parámetros:
...-Cualquier valor, separado por comas.
Ejemplo:
 double free=AccountFreeMargin(); Comment("El margen libre de la cuenta es ",DoubleToStr(free,2),"\n", "La hora actual es ",TimeToStr(TimeCurrent());
 
Al menos lee la documentación antes de hacer preguntas. La mitad de las respuestas ya están ahí
 

Gracias, lo tengo. Necesito introducir las variables según los resultados de las funciones LinearRegression y Diverg para cada TF y luego emitirlas con un comentario, puede ser en varias líneas.

 
Optim:

Gracias, lo tengo. Necesito introducir las variables según los resultados de las funciones LinearRegression y Diverg para cada TF y luego emitirlas con un comentario, puede ser en varias líneas.


Sólo hay una limitación en cuanto a la longitud de la línea. Puede utilizar la función de Alexander Pak. Si no lo encuentras, lo buscaré yo mismo
 

Estimados señores.

Tengo una pregunta sobre cómo pasar un array por referencia.

El esquema del algoritmo es el siguiente:

Pasamos un array por referencia de una biblioteca a otra.

Lo copiamos allí utilizando la función incorporada:

ArrayCopy.

A continuación, se utiliza el array pasado por referencia

en el primer módulo.

Pero por alguna razón, se produce un error, y no siempre.

Es decir, a veces el array se copia y otras veces no.

¿Cuál es la razón?

La entrada del registro es la siguiente:

21:07:12 openHistory CADCHF,H1:

2 rangos de arrays para la función ArrayCopy (0 y 4)

Conexión del módulo

Copiar

 
Roger:
Eso es porque has copiado mal mi ejemplo. Fíjate bien dónde está la i y dónde la k.

Corregido el código según el tuyo.
Al hacer la prueba, cuatro órdenes se cerraron en el orden en que fueron establecidas en el primer tick, la quinta se cerró en el siguiente tick. Probablemente algo más está mal aquí ya que lo he probado muchas veces.
Pego el código del programa y los registros del probador.
Sinceramente. Shurkin

Код программы.
//+------------------------------------------------------------------+
//|                                                     Poligon1.mq4 |
//|                                            21 февраля 2013 года. |
//|Тестирование оператора цикла for.                                 |
//+------------------------------------------------------------------+
#property copyright "21 февраля 2013 года."
#property link      ""
//+------------------------------------------------------------------+
//|Объявленные переменные                                            |
//+------------------------------------------------------------------+
int Mn=357;//Magic number
int i;//Показатель счётчика итераций
double PriTP;//TP серии
int Tick;//Счётчик тиков
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----Установка серии ордеров
OrderSend(Symbol(),OP_BUY,0.5,Ask,0,NormalizeDouble(Bid-35*Point,Digits),
NormalizeDouble(Ask+35*Point,Digits),NULL,Mn,0,CLR_NONE);//OP_BUY
OrderSend(Symbol(),OP_BUY,1,Ask,0,NormalizeDouble(Bid-25*Point,Digits),
NormalizeDouble(Ask+25*Point,Digits),NULL,Mn,0,CLR_NONE);//OP_BUY
OrderSend(Symbol(),OP_BUY,1.5,Ask,0,NormalizeDouble(Bid-15*Point,Digits),
NormalizeDouble(Ask+15*Point,Digits),NULL,Mn,0,CLR_NONE);//OP_BUY
OrderSend(Symbol(),OP_BUY,2.5,Ask,0,NormalizeDouble(Bid-15*Point,Digits),
NormalizeDouble(Ask+15*Point,Digits),NULL,Mn,0,CLR_NONE);//OP_BUY
OrderSend(Symbol(),OP_BUY,3.5,Ask,0,NormalizeDouble(Bid-15*Point,Digits),
NormalizeDouble(Ask+15*Point,Digits),NULL,Mn,0,CLR_NONE);//OP_BUY
OrderSend(Symbol(),OP_BUYLIMIT,1,NormalizeDouble(Ask-15*Point,Digits),0,
NormalizeDouble(Bid-40*Point,Digits),NormalizeDouble(Ask+25*Point,Digits),
NULL,Mn,0,CLR_NONE);//OP_BUYLIMIT
OrderSend(Symbol(),OP_SELLSTOP,3,NormalizeDouble(Ask-30*Point,Digits),0,
NormalizeDouble(Bid+15*Point,Digits),NormalizeDouble(Ask-75*Point,Digits),
NULL,Mn,0,CLR_NONE);//OP_SELLSTOP
//----
   PriTP=Bid;//PriTP
   Print("Кс0:"," OrdersTotal=",OrdersTotal());//Сообщение
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
   Tick++;//Tick
//   Print("Кс0:"," Tick=",Tick);//Сообщение
//----
//   for(i=0;i<OrdersTotal();i++)//Инициализация цикла
//   for(i=OrdersTotal()-1; i>=0; i--)//
   for(i=0, int k=0; i<OrdersTotal();i++,k++)//
   {
   Print("Кс1:"," Tick=",Tick," i=",i," k=",k);//Сообщение
   if(OrderSelect(k,SELECT_BY_POS,MODE_TRADES)==true)//Выбор ордера k
    {
   if(OrderSymbol()==Symbol())//Символ
     {
   if(OrderMagicNumber()==Mn)//Идентификационное число
      {
   if(OrderType()==OP_BUY && OrderTakeProfit()>PriTP)//Тип операции текущего выбранного ордера
       {
   OrderClose(OrderTicket(),OrderLots(),Bid,0,CLR_NONE);//Закрытие позиции
   k--;//?
       }//Закрыто if(OrderType()==OP_BUY && OrderTakeProfit()>PriTP)
      }//Закрыто if(OrderMagicNumber()==Mn)
     }//Закрыто if(OrderSymbol()==Symbol()
    }//Закрыто if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
   }//Закрыто for(i=0, int k=0; i<OrdersTotal();i++,k++)
/*   
   for(i=0, int k=0; i<OrdersTotal();i++,k++)//
   {
   Print("Кс1:"," Tick=",Tick," i=",i," k=",k);//Сообщение
   if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)//Выбор ордера i
    {
   if(OrderSymbol()==Symbol())//Символ
     {
   if(OrderMagicNumber()==Mn)//Идентификационное число
      {
   if(OrderType()==OP_BUY && OrderTakeProfit()>PriTP)//Тип операции текущего выбранного ордера
       {
   OrderClose(OrderTicket(),OrderLots(),Bid,0,CLR_NONE);//Закрытие позиции
   k--;//Зачем сначала прибавлять и тут же убавлять ???
       }//Закрыто if(OrderType()==OP_BUY && OrderTakeProfit()>PriTP)
      }//Закрыто if(OrderMagicNumber()==Mn)
     }//Закрыто if(OrderSymbol()==Symbol()
    }//Закрыто if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
   }//Закрыто for(i=0;i<OrdersTotal();i++)
*/   
//----
   return(0);
  }
//+------------------------------------------------------------------+
Записи в журнале тестера.
2013.03.18 13:58:21     2013.02.11 12:15  Poligon1 EURUSD,M15: Êñ1: Tick=4 i=1 k=1
2013.03.18 13:58:21     2013.02.11 12:15  Poligon1 EURUSD,M15: Êñ1: Tick=4 i=0 k=0
2013.03.18 13:57:57     2013.02.11 12:15  Poligon1 EURUSD,M15: Êñ1: Tick=3 i=1 k=1
2013.03.18 13:57:57     2013.02.11 12:15  Poligon1 EURUSD,M15: Êñ1: Tick=3 i=0 k=0
2013.03.18 13:57:33     2013.02.11 12:15  Poligon1 EURUSD,M15: Êñ1: Tick=2 i=1 k=0
2013.03.18 13:57:33     2013.02.11 12:15  Poligon1 EURUSD,M15: close #5 buy 3.50 EURUSD at 1.3397 sl: 1.3380 tp: 1.3412 at price 1.3394
2013.03.18 13:57:33     2013.02.11 12:15  Poligon1 EURUSD,M15: Êñ1: Tick=2 i=0 k=0
2013.03.18 13:57:09     2013.02.11 12:15  Poligon1 EURUSD,M15: close #4 buy 2.50 EURUSD at 1.3397 sl: 1.3380 tp: 1.3412 at price 1.3395
2013.03.18 13:57:09     2013.02.11 12:15  Poligon1 EURUSD,M15: Êñ1: Tick=1 i=3 k=0
2013.03.18 13:57:09     2013.02.11 12:15  Poligon1 EURUSD,M15: close #3 buy 1.50 EURUSD at 1.3397 sl: 1.3380 tp: 1.3412 at price 1.3395
2013.03.18 13:57:09     2013.02.11 12:15  Poligon1 EURUSD,M15: Êñ1: Tick=1 i=2 k=0
2013.03.18 13:57:09     2013.02.11 12:15  Poligon1 EURUSD,M15: close #2 buy 1.00 EURUSD at 1.3397 sl: 1.3370 tp: 1.3422 at price 1.3395
2013.03.18 13:57:09     2013.02.11 12:15  Poligon1 EURUSD,M15: Êñ1: Tick=1 i=1 k=0
2013.03.18 13:57:09     2013.02.11 12:15  Poligon1 EURUSD,M15: close #1 buy 0.50 EURUSD at 1.3397 sl: 1.3360 tp: 1.3432 at price 1.3395
2013.03.18 13:57:09     2013.02.11 12:15  Poligon1 EURUSD,M15: Êñ1: Tick=1 i=0 k=0
2013.03.18 13:57:09     2013.02.11 12:15  Poligon1 EURUSD,M15: Êñ0: OrdersTotal=7
2013.03.18 13:57:09     2013.02.11 12:15  Poligon1 EURUSD,M15: open #7 sell stop 3.00 EURUSD at 1.3367 sl: 1.3410 tp: 1.3322 ok
2013.03.18 13:57:09     2013.02.11 12:15  Poligon1 EURUSD,M15: open #6 buy limit 1.00 EURUSD at 1.3382 sl: 1.3355 tp: 1.3422 ok
2013.03.18 13:57:09     2013.02.11 12:15  Poligon1 EURUSD,M15: open #5 buy 3.50 EURUSD at 1.3397 sl: 1.3380 tp: 1.3412 ok
2013.03.18 13:57:09     2013.02.11 12:15  Poligon1 EURUSD,M15: open #4 buy 2.50 EURUSD at 1.3397 sl: 1.3380 tp: 1.3412 ok
2013.03.18 13:57:09     2013.02.11 12:15  Poligon1 EURUSD,M15: open #3 buy 1.50 EURUSD at 1.3397 sl: 1.3380 tp: 1.3412 ok
2013.03.18 13:57:09     2013.02.11 12:15  Poligon1 EURUSD,M15: open #2 buy 1.00 EURUSD at 1.3397 sl: 1.3370 tp: 1.3422 ok
2013.03.18 13:57:09     2013.02.11 12:15  Poligon1 EURUSD,M15: open #1 buy 0.50 EURUSD at 1.3397 sl: 1.3360 tp: 1.3432 ok
2013.03.18 13:57:09     Poligon1 test started
2013.03.18 13:57:02     Poligon1 EURUSD,M15: loaded successfully
 
Cuál es el mejor lugar para declarar un tipo de variable (int, double, etc.) en términos de reducir el consumo de recursos de la ejecución del programa. Por ejemplo, int i puede declararse globalmente o en int start() ... for (int i=OrdersTotal()-1; i>=0; i--) ... Tengo la sensación de que declararlo en cada tic es más costoso que declararlo una vez a nivel global, justo después de los parámetros externos. ¿O la diferencia en la intensidad de recursos es la misma?
 
Zhunko:
Tienes que hacer un bucle en la salida. Trabaja dentro del bucle. Allí se puede hacer de todo.

Esto es un poco diferente. cuando la conexión se pierde, el registro dice "Ping failed". significa que hay fi rmas, pero no están documentadas por alguna razón.
¿Cuánto aumenta la carga de la CPU y de la memoria con los bucles?

 
Dimka-novitsek:

¡Buenas noches! Disculpen, me gustaría volver a un problema no resuelto.

'Comprar' - tipos incompatibles D:\TeleTRADE\\Nexperts/experts/clean.mq4 (102, 53)

'Vender' - tipos incompatibles D:\TeleTRADE\\Nexperts\clearlist.mq4 (102, 79)


if (!Pishem&&PozyProstavleny){SaveArray(FileBuy, Buy); SaveArray(FileSell, Sell); Pishem=1;}

Esta línea no compila.
Razón de la queja: