Questions from Beginners MQL5 MT5 MetaTrader 5 - page 839

 
Vladimir Karputov:

Looking for where the close command comes from.

The condition for closing is exactly the same as the condition for opening a counter position, what is wrong with this command, to close, as in Forex?

 
lil_lil:

The condition to close is exactly the same as the condition to open a counter position, what is wrong with this command, to close, as in Forex?

"Condition" is a set of letters, nothing more. And a trade command is a function of the MQL5 language. So you need to look at the MQL5 code for closing a position.

 

Can you please advise whether it is possible to close position in MT4/MT5 terminal at a specified time instead of by TP or SL?

Thank you!

 
Monya_mf:

Can you please advise whether it is possible to close position in MT4/MT5 terminal at a specified time instead of by TP or SL?

Thank you!

There is.

 

I apologise for the incomplete question. The brevity of the answer - appreciated!

Artem, isn't it difficult to explain the implementation?

Preferably not in one word. :)

 
Vladimir Karputov:

"Condition" is a set of letters, nothing more. And a trade command is a function of the MQL5 language. So you need to look at the MQL5 code for closing a position.

Thank you, it really wasn't all right.

 
Monya_mf:

Can you please advise whether it is possible to close position in MT4/MT5 terminal at a specified time instead of by TP or SL?

Thank you!

Primitive variant

int CloseHour =23;
//
if (Hour()==CloseHour)
{
//ЗДЕСЬ ФУНКЦИЯ ЗАКРЫТИЯ ПОЗИЦИИ
}
 
lil_lil:

Primitive version

The Hour() function is absent in mql5 as a hostile class. (Not to be confused with OOP classes).

But in general it is very similar.
 

Yeah!

THANK YOU!

The last time I wrote a program in that dreaded ForTran language was.... Well, it's been a while!

So where did you say to learn how to write in MQL4/5? Or is it two different skills?

I'll go - I'll sit down for textbooks..... :)

 
Monya_mf:

Yeah!

THANK YOU!

The last time I wrote a program in that dreaded ForTran language was.... Well, it's been a while!

So where did you say to learn how to write in MQL4/5? Or is it two different skills?

I'll go - I'll sit down for textbooks..... :)

You're writing in the "... MQL5...". It means you need to learn MQL5.