Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 414

 
The aim is to open a single order

We create a function where we loop through the open orders and if 0, we open them.

Variant 2 :
Condition ordersdtotal ==0

This gives us, as a minimum, endless order opening or opening on every tick

Why?
 
Alekseu Fedotov:

For starters:

variables, variable visibility

how are they declared, where?

I think the code is very clear
 
Mickey Moose:
The target is to open one order

We create a function where we loop through the open orders and if 0, we open them.

Variant 2 :
Condition ordersdtotal ==0

This gives us, as a minimum, endless order opening or opening on every tick

Why?
What is unclear in the code? I will explain if anything
 
ZZuretc:
What is unclear, I will explain if anything
It is unclear why I should use a custom counting function when there is an out-of-the-box order total
 
Mickey Moose:
It is unclear why I should use a custom counting function if there is a ready-made order total

Because the standard one returns the total number of orders and positions in the account regardless of the symbol, magician and type.

 

Hi all! Could you please tell me how to set the condition of price crossing a horizontal line? And how to make this function with maximum accuracy (that would react on every tick)?

Thank you in advance))

 
Mickey Moose:
The target is to open one order.
We create a function where we loop through the open orders and if 0, we open them.
Variant 2 :
Condition ordersdtotal ==0
This gives us, as a minimum, endless order opening or opening on every tick
Why?

With every tick the terminal receives the latest quote from the server and also the information about the orders. When terminal sends OrderSend() command to server, server needs some time to process this command and open the order. Until then, it will send information about absence of an order with every tick (let's call it empty). The OrdersTotal() function will return zero, and the robot will send a new OrderSend().

When the server opens the order, the empty ticks will end. Function OrdersTotal() will return a positive value, the robot will calm down. If the quotes change frequently, the ticks will come often, and there will be a lot of empty ticks. The robot will send many OrderSend(). The server will open many orders.

The conclusion is that we should pause after OrderSend().

 
STARIJ:

With every tick the terminal receives from the server the latest quote as well as information about orders. When the terminal sends OrderSend() command to the server, the server needs some time to process the command and open the order. Until then, it will send information about absence of an order with every tick (let's call it empty). The OrdersTotal() function will return zero, and the robot will send a new OrderSend().

When the server opens the order, the empty ticks will end. Function OrdersTotal() will return a positive value, the robot will calm down. If the quotes change frequently, the ticks will come often, and there will be a lot of empty ticks. The robot will send many OrderSend(). The server will open a lot of orders.

Conclusion - we should pause after OrderSend().

After OrderSend(), if there is a positive response, there is a ticket, and, accordingly, a position opening/order placing should be requested from the trading environment once again, instead of waiting indefinitely.

 

What about a function that takes and modifies a non-magic?

But why don't other functions place multiple orders, but only SellLimit?

 
ZZuretc:
What about a function that takes and modifies a non-magic?

The order magik cannot be modified.

Reason: