Followed the MT4 example "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);
}
I did as you said, but for some reason after closing the Expert Advisor closes a couple of trades, despite the fact that I have a one hour slip after the CloseAll() function.
inputint Second = 10;
datetime LastTime = 0;
voidOnTick()
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Thank you, is there another solution? After that the EA opens and immediately closes the position.
you need to fix the time on condition
and do not refresh it until the position is closed
then subtract from the current time the time you have memorised
, when the given seconds have passed, close the positions.
I did so
double op = CalculateProfit();
int time_waiting=0;
if (op >= Profit)
time_waiting = TimeLocal() + 10;
if (TimeLocal() < time_waiting)
{
CloseAll();
}
but it gives me an error
possible loss of data due to type conversion
is not an error, but a warning: data may be lost when converting from one type to another:
datetime time_waiting;That is, I don't want the EA to close as soon as I see 2 quid, but a bit more.
And what, always after 10 seconds the profit is bigger?)
If you don't mind, please help me fix it...
Accepting full responsibility for the fact that
ushort
The unsigned shorttype is the ushort type, which also has a size of 2 bytes. The minimum value is 0, the maximum value is 65,535.
int
The integer int type has a size of 4 bytes (32 bits). The minimum value is -2 147 483 648, the maximum value is 2 147 483 647.
I did as you said, but for some reason after closing the Expert Advisor closes a couple of trades, despite the fact that I have a one hour slip after the CloseAll() function.
double op = CalculateProfit();
if (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
}