Questions from Beginners MQL4 MT4 MetaTrader 4 - page 229
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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
}