Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 885

 
rapid_minus:

Well, I can handle English without any help, but mql4 is not so good. Explain how to check success - not success, what function or what else? It's not a warning, it's my searching for the function check without understanding the essence of it.


It's not good at all. Vladimir, you quoted a phrase containing an unambiguous and crystal clear answer to your question; and immediately you repeated this question reproaching the answerer:

" ... OrderClose() function returns true if executed successfully or false if unsuccessful, that's what you need to check...whether the function was executed successfully... "

Isn't it time to start thinking about it?

 
tara:

Bzzzzz... Well you just make me learn mql4.

I did not set myself such a goal. My task was purely local - to write a working EA by my own strategy, studying the language only within the minimum required scope. After reading a lot of posts in various forum threads, I got more confident in the reality of this task, because I've seen many traders writing EAs in mql, while remaining illiterate even in Russian.

But I see that in this thread the experts do not want to help, but want to force me to learn the language. Not as proclaimed: "any question...", but: "don't ask stupid questions". Even to poke your nose at a chapter of a textbook or reference or an example where that question is solved is unworthy of Great Teachers.

I think you're a little mistaken - newcomers do not come here to admire you and applaud your knowledge.

Teenagers don't need to be karate fighters to protect themselves from bullies, they just need to know a thing or two.

ZS: Actually, I get the impression that you yourself to answer the question you need to look in a textbook, but do not want to ...

And God forbid I should reproach anyone with anything here. I'm only stating my opinion. And thank you for wasting your time on me.

 

I had to dig into the documentation myself to understand the incomprehensible...

The documentation still has the old example.

In general: if a function returns some value, then this value must be assigned to a variable of the corresponding type and the value of this variable must be checked.

It goes like this:

bool res;

res = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 40);
if(!res) Print("нихрена ордер не заерылся. Ошибка ", GetLastError());
 
AlexeyVik:

I had to dig into the documentation myself to understand the incomprehensible...

The documentation still has the old example.

In general: if a function returns some value, then this value must be assigned to a variable of appropriate type and the value of this variable must be checked.

It goes like this:

Check back more often. There will be less questions. Better knowledge will be there.
 
AlexeyVik:

I had to dig into the documentation myself to understand the incomprehensible...

The documentation still has the old example.

In general: if a function returns some value, then this value must be assigned to a variable of the corresponding type and the value of this variable must be checked.

It looks like this:

bool res;

res = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 40);
if(!res) Print("нихрена ордер не заерылся. Ошибка ", GetLastError());

Why would there be an extra variable? The direct check works fine:

if(!OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 40)) Print("нихрена ордер не заерылся. Ошибка ", GetLastError());
A variable should be created when you want to see the value of a function from different points in the program, so that you don't have to call it several times.
 
evillive:

Why would there be an extra variable? The direct check works just fine:

The variable must be created when the value of a function must be seen from different points in the programme so that it does not have to be called several times.

Oh, my God! Such a debate, and I'm required to "think to the point"...

I have fixed the errors, compilation gives 0 error messages, 0 warnings, but there is another problem (or rather two): when I have the first opportunity to open an order they open non-stop, until the funds run out, and then, when closing conditions come, they all close and no new orders open, although closed orders eventually give profits.

 
rapid_minus:

Oh, my God! Such a debate, and I'm required to "get to the bottom of it"...

I fixed the errors, the compilation gives 0 error messages and 0 warnings, but there is another problem (or rather two): when I have the first opportunity to open an order they open non-stop until I run out of money, and then, when the order closes, they all close and no new orders open, although closed orders eventually give a profit.

There are several ways to limit the number of orders:

1) by quantity - count the number of orders already opened and compare with the number set by the user, if the number of open orders has already been set, then no more orders should be opened;

2) by time - consider the time that has passed since the last order was opened, if the time passed is less than the specified, do not trade

3) by the distance in pips from the opening price of the previous order to the current market price (or calculated price for pending orders); if the distance is less, do not trade.

Usually different combinations of these limitations are used.

 
evillive:

There are several ways to limit the number of orders:

1) by quantity - count the number of already opened orders and compare with the one set by the user, if opened as much as set, do not open more;

2) by time - consider the time that has passed since the last order was opened, if the time passed is less than the specified, do not trade

3) by the distance in pips from the opening price of the previous order to the current market price (or calculated price for pending orders); if the distance is less, do not trade.

Usually different combinations of these limitations are used.

Thank you, I will try setting the number 1
 

What to...

...all are closed and no new orders are opened...
The conditions should be checked for the possibility of a new trading session at least once for each new bar (at the opening), or at all on each tick, depending on the conditions of the strategy.
 
evillive:

Why would there be an extra variable? The direct check works fine:

A variable should be created when you want to see the value of a function from different points in the program, so that you don't have to call it several times.
The variable is intended to make it easier to understand for a newcomer. Is it clear now what it is for?
Reason: