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

 
Artyom Trishkin:
Build a virtual line, not a graphical object, instead of a trend line. Respectively, and get the value not through ObjectGetValueByShift("1",bar_seek), but by straight line equation.
thanks! -I'll try it)
 
Nikolay Gaylis:
Thank you! I'll give it a try.)
You're welcome...
 
Nikolay Gaylis:
Thank you! I will try it)

I wrote an article on mql4.com a long time ago. It contains a detailed description of working with virtual trend lines and searching for the right price value on the right bar of these virtual lines.

There is an indicator based on this article in kodobase. In it I have already reworked the code for the new mql4.

 
Artyom Trishkin:
That must have been the idea. However, this check will not only take into account pending orders but also all operations on a trading account - deposits, withdrawals, bonuses, etc.
Nikolay Gaylis:

This condition allows the board to only workwith stacked orders, was that the intention?

    if(OrderSymbol() ==Symbol() &&OrderType()<2)
          continue;
Properties of orders

Type of operation for the OrderSend() function. Can be any of the following values:

Constant
Value
Description
OP_BUY
0
Buy
OP_SELL
1
Sell
OP_BUYLIMIT
2
Pending BUY LIMIT order
OP_SELLLIMIT
3
Pending SELL LIMIT order
OP_BUYSTOP
4
Pending BUY STOP order
OP_SELLSTOP
5
Pending SELL STOP order


The calculation is that the pending orders will not be taken at all until they are converted into market orders only for the current symbol. After the last market order (if there are many of them) for the current symbol is processed, the EA is removed from the chart (now it is removed immediately after the first order triggering and it takes into account the fact that if there is 1 order for the current symbol and another for another one).

Why does this happen and where should I place a returnee order, so that when the next order is closed it sends a function directly to the conditions after count++ and starts playsound only after the last order has triggered. Finally, I put Orderselect() to determine the last one (if the order is closed and we can't select the order we have nothing to do on this chart)

 
trader781:
Properties of orders

...


The pending orders will not be taken into account at all until they are converted into market orders only for a current symbol. After the last market order (if there are many of them) for the current symbol is processed, the Expert Advisor deletes itself from the chart (it is deleted immediately after the first order triggering and pays attention to the fact that if there is 1 order for the current symbol and another for another one, it takes it into consideration).

why this happens and where to put a returnee, so that when the next order is closed, it sends a function directly to the conditions after count++ and only after the last order has triggered, it starts playsound. Finally, I put Orderselect() to determine the last one (if the order is closed and we can't select the order we have nothing to do on this chart)

if(OrderSymbol() ==Symbol() &&OrderType()<2)
          continue;

This code skips all market positions in the loop.

What follows is unknown to me but if we go on to process other order types - those 2 and higher, such processing will take into account all types of pending orders and orders of type 6 - actions on the account.

Where is the code with the whole cycle?

 
Artyom Trishkin:
if(OrderSymbol() ==Symbol() &&OrderType()<2)
          continue;


Where is the code with the whole cycle?

Post 236

this section should only pass the market ones for the current instrument

 
trader781:

Post 236

this section should only pass market ones on the current instrument

This loop you have is stupidly empty at all. It makes no sense at all - it just slows down if you have a large number of orders in your account.

And tidy up your code - it is just unreadable rubbish, not code.

And why do you need double curly braces in OnTick()? What is the sacred meaning of this?

 
Artyom Trishkin:

And get your code in order - it's just unreadable junk, not code.

Don't get me wrong. If I could do it the way you want, I wouldn't be sitting here. That's why I'm asking for help in solving the current task.

 
trader781:
Artyom Trishkin:

And get your code in order - it's just unreadable junk, not code.

Don't get me wrong. If I could do it the way you want, I wouldn't be sitting here. That's why I'm asking you to help me to solve the current task.

Perhaps you are able to remove empty lines from code? Does it require any special skill?

Actually, there is the key combination Ctrl+"," - a styler. Although bad, but still. And then you can delete empty lines from the code so as not to let people look at the "tripe". It's the simplest culture of communication.

But after you clean up your code it will become more readable for you, not to mention other people who will also need to understand your logic. All the shortcomings will be seen there.

 
Artyom Trishkin:

You probably know how to remove empty lines from code, don't you? Does this require any special skill?

Actually, there is a keyboard shortcut Ctrl+"," - a styler. Although bad, but still. And then you can delete empty lines from the code so as not to let people look at the "tripe". It's the simplest culture of communication.

But after you clean up your code it will become more readable for you, not to mention other people who will also need to understand your logic. And all your shortcomings will be seen there.

After you clean up your code, it will become more readable for you, not to mention other people who need to understand your logic too. That's where all the bugs will be seen.

OK, is that better?
Files: