Siguiendo el ejemplo de MT4 "STRINGS: ASCII CHARACTERS TABLE AND USE"
//+------------------------------------------------------------------+//| StringLowerCase |//+------------------------------------------------------------------+string StringLowerCase(string str)
{
string s = str;
int lenght = StringLen(str) - 1, symbol;
while(lenght >= 0)
{
symbol = StringGetChar(s, lenght);
if((symbol > 64 && symbol < 91) || (symbol > 191 && symbol < 224))
s = StringSetChar(s, lenght, symbol + 32);// тут possible loss of data due to type conversionelseif(symbol > -65 && symbol < -32)
s = StringSetChar(s, lenght, symbol + 288);// тут possible loss of data due to type conversion
lenght--;
}
return(s);
}
//+------------------------------------------------------------------+//| StringUpperCase |//+------------------------------------------------------------------+string StringUpperCase(string str)
{
string s = str;
int lenght = StringLen(str) - 1, symbol;
while(lenght >= 0)
{
symbol = StringGetChar(s, lenght);
if((symbol > 96 && symbol < 123) || (symbol > 223 && symbol < 256))
s = StringSetChar(s, lenght, symbol - 32);// тут possible loss of data due to type conversionelseif(symbol > -33 && symbol < 0)
s = StringSetChar(s, lenght, symbol + 224);// тут possible loss of data due to type conversion
lenght--;
}
return(s);
}
Si no te importa, por favor ayúdame a arreglarlo...
Hice lo que me dijiste, pero por alguna razón después de cerrar el Asesor Experto cierra un par de operaciones, a pesar de que tengo un deslizamiento de una hora después de la función CloseAll().
inputint Second = 10;
datetime LastTime = 0;
voidOnTick()
Gracias, ¿hay otra solución? Después, el EA abre y cierra inmediatamente la posición.
hay que fijar la hora en la condición
y no se actualiza hasta que se cierra la posición
a continuación, reste a la hora actual el tiempo que ha memorizado
cuando hayan pasado los segundos indicados, cierre las posiciones
Lo hice
double op = CalculateProfit();
int time_waiting=0;
if (op >= Profit)
time_waiting = TimeLocal() + 10;
if (TimeLocal() < time_waiting)
{
CloseAll();
}
pero me da un error
posible pérdida de datos debido a la conversión de tipos
no es un error, sino una advertencia: los datos pueden perderse al convertir de un tipo a otro:
datetime time_waiting;Es decir, no quiero que el EA se cierre en cuanto vea 2 libras, sino un poco más.
¿Y qué, siempre después de 10 segundos el beneficio es mayor?)
Si no te importa, por favor ayúdame a arreglarlo...
Aceptar la plena responsabilidad por el hecho de que
ushort
El tipo unsigned short es el tipo ushort, que también tiene un tamaño de 2 bytes. El valor mínimo es 0, el valor máximo es 65.535.
int
El tipo entero int tiene un tamaño de 4 bytes (32 bits). El valor mínimo es -2 147 483 648, el valor máximo es 2 147 483 647.
Hice lo que me dijiste, pero por alguna razón después de cerrar el Asesor Experto cierra un par de operaciones, a pesar de que tengo un deslizamiento de una hora después de la función CloseAll().
double op = CalculateProfit();
si (op >= Profit && LastTime == 0)
LastTime = TimeCurrent ();
if(LastTime > 0 && TimeCurrent () - LastTime >= Second)
{
CloseAll();
LastTime = 0;
SendNotification("Trade is over");
Sleep(60*60000);// 60.000 = 1 min
}