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

 
Taras Slobodyanik #:

er, didn't you ask about the modification error and its criticality?
...and its explanation

Taras asked

Please tell me if i have orders with TakeProfit and i am modifying them to calculate new TakeProfit.

&& tp!=OrderTakeProfit()

If I can say "and takeprofit does not equal takeprofit of the selected order".

Then we should write a new function to modify orders that have already been taken, but one of the check conditions should be

if(OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderType() == otype && tp!=OrderTakeProfit() )

Can you give me a hint?

 
EVGENII SHELIPOV #:

Taras asked

If i have an order with a takeprofit i am modifying it to calculate a new takeprofit, how should i add this to it?

If I can say "and takeprofit does not equal takeprofit of the selected order".

Then we should write a new function to modify orders that have already been taken, but one of the check conditions should be

Please tell me which way I am thinking.

Right - that way.


I have no errors in my tester. Tell me on which pair what date?

 
EVGENII SHELIPOV #:

Tell me if I'm thinking in the right direction.

Not quite that way... As a rule, the TP is changed if the new TP brings more profit than the old one. And this condition

tp!=OrderTakeProfit()

can be met either upwards or downwards...

So we have to condition it > or < depending on the type of order.

 
Roman Kutemov #:
It's not there

Everyone has


 
MakarFX #:

Right - that way.


I don't have a single error in my tester. Tell me on which pair what date?

Pound/Dollar but that's not the point, probably better to load this set file and as soon as a couple of orders are closed look at the log

Files:
1111.set  3 kb
 
EVGENII SHELIPOV #:

Taras asked

I have orders with TakeProfit and i am modifying them to calculate new TakeProfit, how do i attach this

I already added it to your code line (in previous message).

The explanation is the same - the error occurs if you modify an order which already has the same TP.
When modifying an order, at least one parameter (TP, SL, Price) must be different.

In other words, "tp!=OrderTakeProfit()" means that there is no need to modify the order if it already has the same TP.

 
MakarFX #:

Everyone has


Mine is not on the C drive for some reason, but I found it through Open Data Directory in the terminal.
 
Roman Kutemov #:
Mine is not on the C drive for some reason, but I found it via Open data directory in the terminal.
Naturally in the data directory, I just have the directory on the C drive
 
EVGENII SHELIPOV # :

Pound / dollar but that's not the point, it's probably better to download this set file and as soon as a couple of orders are closed, look at the log

Many mistakes were due to inattention

now there are no errors

 2021.09 . 26 20 : 21 : 37.087 2021.08 . 30 08 : 06 : 05    111 GBPUSD,M5: Максимальный и минимальный ордера на покупку успешно закрыты!
2021.09 . 26 20 : 21 : 37.087 2021.08 . 30 08 : 06 : 05    111 GBPUSD,M5: close # 16 buy 0.14 GBPUSD at 1.37709 tp: 1.37720 at price 1.37712
2021.09 . 26 20 : 21 : 37.087 2021.08 . 30 08 : 06 : 05    111 GBPUSD,M5: close # 15 buy 0.12 GBPUSD at 1.37730 tp: 1.37720 at price 1.37712
2021.09 . 26 20 : 21 : 37.087 2021.08 . 30 08 : 06 : 05    111 GBPUSD,M5: Максимальный и минимальный ордера на покупку успешно закрыты!
2021.09 . 26 20 : 21 : 37.087 2021.08 . 30 08 : 06 : 05    111 GBPUSD,M5: close # 17 buy 0.17 GBPUSD at 1.37689 tp: 1.37720 at price 1.37712
2021.09 . 26 20 : 21 : 37.087 2021.08 . 30 08 : 06 : 05    111 GBPUSD,M5: close # 14 buy 0.10 GBPUSD at 1.37751 tp: 1.37720 at price 1.37712
2021.09 . 26 20 : 21 : 17.837 2021.08 . 30 07 : 04 : 30    111 GBPUSD,M5: Ордера успешно модифицированы!
2021.09 . 26 20 : 21 : 17.837 2021.08 . 30 07 : 04 : 30    111 GBPUSD,M5: modify # 14 buy 0.10 GBPUSD at 1.37751 sl: 0.00000 tp: 1.37720 ok
2021.09 . 26 20 : 21 : 17.837 2021.08 . 30 07 : 04 : 30    111 GBPUSD,M5: Ордера успешно модифицированы!
2021.09 . 26 20 : 21 : 17.837 2021.08 . 30 07 : 04 : 30    111 GBPUSD,M5: modify # 15 buy 0.12 GBPUSD at 1.37730 sl: 0.00000 tp: 1.37720 ok
2021.09 . 26 20 : 21 : 17.837 2021.08 . 30 07 : 04 : 30    111 GBPUSD,M5: Ордера успешно модифицированы!
2021.09 . 26 20 : 21 : 17.837 2021.08 . 30 07 : 04 : 30    111 GBPUSD,M5: modify # 16 buy 0.14 GBPUSD at 1.37709 sl: 0.00000 tp: 1.37720 ok
2021.09 . 26 20 : 21 : 17.837 2021.08 . 30 07 : 04 : 30    111 GBPUSD,M5: Ордера успешно модифицированы!
2021.09 . 26 20 : 21 : 17.837 2021.08 . 30 07 : 04 : 30    111 GBPUSD,M5: modify # 17 buy 0.17 GBPUSD at 1.37689 sl: 0.00000 tp: 1.37720 ok
2021.09 . 26 20 : 21 : 17.837 2021.08 . 30 07 : 04 : 30    111 GBPUSD,M5: open # 17 buy 0.17 GBPUSD at 1.37689 ok
2021.09 . 26 20 : 21 : 16.247 2021.08 . 30 07 : 00 : 30    111 GBPUSD,M5: Ордера успешно модифицированы!
2021.09 . 26 20 : 21 : 16.247 2021.08 . 30 07 : 00 : 30    111 GBPUSD,M5: modify # 14 buy 0.10 GBPUSD at 1.37751 sl: 0.00000 tp: 1.37733 ok
2021.09 . 26 20 : 21 : 16.247 2021.08 . 30 07 : 00 : 30    111 GBPUSD,M5: Ордера успешно модифицированы!
2021.09 . 26 20 : 21 : 16.247 2021.08 . 30 07 : 00 : 30    111 GBPUSD,M5: modify # 15 buy 0.12 GBPUSD at 1.37730 sl: 0.00000 tp: 1.37733 ok
2021.09 . 26 20 : 21 : 16.247 2021.08 . 30 07 : 00 : 30    111 GBPUSD,M5: Ордера успешно модифицированы!
2021.09 . 26 20 : 21 : 16.247 2021.08 . 30 07 : 00 : 30    111 GBPUSD,M5: modify # 16 buy 0.14 GBPUSD at 1.37709 sl: 0.00000 tp: 1.37733 ok
2021.09 . 26 20 : 21 : 16.247 2021.08 . 30 07 : 00 : 30    111 GBPUSD,M5: open # 16 buy 0.14 GBPUSD at 1.37709 ok
2021.09 . 26 20 : 21 : 14.015 2021.08 . 30 06 : 53 : 36    111 GBPUSD,M5: Ордера успешно модифицированы!
2021.09 . 26 20 : 21 : 14.015 2021.08 . 30 06 : 53 : 36    111 GBPUSD,M5: modify # 14 buy 0.10 GBPUSD at 1.37751 sl: 0.00000 tp: 1.37745 ok
2021.09 . 26 20 : 21 : 14.015 2021.08 . 30 06 : 53 : 36    111 GBPUSD,M5: Ордера успешно модифицированы!
2021.09 . 26 20 : 21 : 14.015 2021.08 . 30 06 : 53 : 36    111 GBPUSD,M5: modify # 15 buy 0.12 GBPUSD at 1.37730 sl: 0.00000 tp: 1.37745 ok
2021.09 . 26 20 : 21 : 14.015 2021.08 . 30 06 : 53 : 36    111 GBPUSD,M5: open # 15 buy 0.12 GBPUSD at 1.37730 ok
2021.09 . 26 20 : 21 : 00.130 2021.08 . 30 06 : 16 : 10    111 GBPUSD,M5: open # 14 buy 0.10 GBPUSD at 1.37751 tp: 1.37771 ok
2021.09 . 26 20 : 21 : 00.130 2021.08 . 30 06 : 16 : 10   Tester: take profit # 13 at 1.37715 ( 1.37715 / 1.37751 )
2021.09 . 26 20 : 21 : 00.130 2021.08 . 30 06 : 16 : 10   Tester: take profit # 12 at 1.37715 ( 1.37715 / 1.37751 )
2021.09 . 26 20 : 20 : 54.618 2021.08 . 30 06 : 00 : 36    111 GBPUSD,M5: Ордера успешно модифицированы!
2021.09 . 26 20 : 20 : 54.618 2021.08 . 30 06 : 00 : 36    111 GBPUSD,M5: modify # 12 buy 0.10 GBPUSD at 1.37726 sl: 0.00000 tp: 1.37715 ok
2021.09 . 26 20 : 20 : 54.618 2021.08 . 30 06 : 00 : 36    111 GBPUSD,M5: Ордера успешно модифицированы!
2021.09 . 26 20 : 20 : 54.618 2021.08 . 30 06 : 00 : 36    111 GBPUSD,M5: modify # 13 buy 0.12 GBPUSD at 1.37696 sl: 0.00000 tp: 1.37715 ok
2021.09 . 26 20 : 20 : 54.618 2021.08 . 30 06 : 00 : 36    111 GBPUSD,M5: open # 13 buy 0.12 GBPUSD at 1.37696 ok
2021.09 . 26 20 : 20 : 39.209 2021.08 . 30 05 : 18 : 18    111 GBPUSD,M5: open # 12 buy 0.10 GBPUSD at 1.37726 tp: 1.37746 ok
2021.09 . 26 20 : 20 : 39.209 2021.08 . 30 05 : 18 : 18   Tester: take profit # 11 at 1.37690 ( 1.37690 / 1.37726 )
2021.09 . 26 20 : 20 : 39.209 2021.08 . 30 05 : 18 : 18   Tester: take profit # 10 at 1.37690 ( 1.37690 / 1.37726 )
2021.09 . 26 20 : 20 : 39.209 2021.08 . 30 05 : 18 : 18   Tester: take profit # 9 at 1.37690 ( 1.37690 / 1.37726 )
2021.09 . 26 20 : 20 : 24.724 2021.08 . 30 04 : 40 : 49    111 GBPUSD,M5: Ордера успешно модифицированы!
2021.09 . 26 20 : 20 : 24.724 2021.08 . 30 04 : 40 : 49    111 GBPUSD,M5: modify # 9 buy 0.10 GBPUSD at 1.37730 sl: 0.00000 tp: 1.37690 ok
2021.09 . 26 20 : 20 : 24.724 2021.08 . 30 04 : 40 : 49    111 GBPUSD,M5: Ордера успешно модифицированы!
2021.09 . 26 20 : 20 : 24.724 2021.08 . 30 04 : 40 : 49    111 GBPUSD,M5: modify # 10 buy 0.12 GBPUSD at 1.37685 sl: 0.00000 tp: 1.37690 ok
2021.09 . 26 20 : 20 : 24.724 2021.08 . 30 04 : 40 : 49    111 GBPUSD,M5: Ордера успешно модифицированы!
2021.09 . 26 20 : 20 : 24.724 2021.08 . 30 04 : 40 : 49    111 GBPUSD,M5: modify # 11 buy 0.14 GBPUSD at 1.37652 sl: 0.00000 tp: 1.37690 ok
2021.09 . 26 20 : 20 : 24.724 2021.08 . 30 04 : 40 : 49    111 GBPUSD,M5: open # 11 buy 0.14 GBPUSD at 1.37652 ok
2021.09 . 26 20 : 20 : 24.257 2021.08 . 30 04 : 39 : 30    111 GBPUSD,M5: Ордера успешно модифицированы!
2021.09 . 26 20 : 20 : 24.257 2021.08 . 30 04 : 39 : 30    111 GBPUSD,M5: modify # 9 buy 0.10 GBPUSD at 1.37730 sl: 0.00000 tp: 1.37710 ok
2021.09 . 26 20 : 20 : 24.257 2021.08 . 30 04 : 39 : 30    111 GBPUSD,M5: Ордера успешно модифицированы!
2021.09 . 26 20 : 20 : 24.257 2021.08 . 30 04 : 39 : 30    111 GBPUSD,M5: modify # 10 buy 0.12 GBPUSD at 1.37685 sl: 0.00000 tp: 1.37710 ok
2021.09 . 26 20 : 20 : 24.257 2021.08 . 30 04 : 39 : 30    111 GBPUSD,M5: open # 10 buy 0.12 GBPUSD at 1.37685 ok
2021.09 . 26 20 : 20 : 22.388 2021.08 . 30 04 : 35 : 00    111 GBPUSD,M5: open # 9 buy 0.10 GBPUSD at 1.37730 tp: 1.37750 ok
2021.09 . 26 20 : 20 : 20.331 2021.08 . 30 04 : 30 : 51   Tester: take profit # 8 at 1.37696 ( 1.37696 / 1.37732 )
2021.09 . 26 20 : 20 : 15.093 2021.08 . 30 04 : 17 : 40    111 GBPUSD,M5: open # 8 buy 0.09 GBPUSD at 1.37676 tp: 1.37696 ok
2021.09 . 26 20 : 20 : 15.093 2021.08 . 30 04 : 17 : 40   Tester: take profit # 7 at 1.37640 ( 1.37640 / 1.37676 )
2021.09 . 26 20 : 20 : 15.093 2021.08 . 30 04 : 17 : 40   Tester: take profit # 6 at 1.37640 ( 1.37640 / 1.37676 )
2021.09 . 26 20 : 20 : 15.093 2021.08 . 30 04 : 17 : 40   Tester: take profit # 5 at 1.37640 ( 1.37640 / 1.37676 )
2021.09 . 26 20 : 20 : 10.273 2021.08 . 30 04 : 06 : 15    111 GBPUSD,M5: Ордера успешно модифицированы!
2021.09 . 26 20 : 20 : 10.273 2021.08 . 30 04 : 06 : 15    111 GBPUSD,M5: modify # 5 buy 0.09 GBPUSD at 1.37666 sl: 0.00000 tp: 1.37640 ok
2021.09 . 26 20 : 20 : 10.273 2021.08 . 30 04 : 06 : 15    111 GBPUSD,M5: Ордера успешно модифицированы!
2021.09 . 26 20 : 20 : 10.273 2021.08 . 30 04 : 06 : 15    111 GBPUSD,M5: modify # 6 buy 0.11 GBPUSD at 1.37639 sl: 0.00000 tp: 1.37640 ok
2021.09 . 26 20 : 20 : 10.273 2021.08 . 30 04 : 06 : 15    111 GBPUSD,M5: Ордера успешно модифицированы!
2021.09 . 26 20 : 20 : 10.273 2021.08 . 30 04 : 06 : 15    111 GBPUSD,M5: modify # 7 buy 0.13 GBPUSD at 1.37611 sl: 0.00000 tp: 1.37640 ok
2021.09 . 26 20 : 20 : 10.273 2021.08 . 30 04 : 06 : 15    111 GBPUSD,M5: open # 7 buy 0.13 GBPUSD at 1.37611 ok
2021.09 . 26 20 : 20 : 09.103 2021.08 . 30 04 : 03 : 18    111 GBPUSD,M5: Ордера успешно модифицированы!
2021.09 . 26 20 : 20 : 09.103 2021.08 . 30 04 : 03 : 18    111 GBPUSD,M5: modify # 5 buy 0.09 GBPUSD at 1.37666 sl: 0.00000 tp: 1.37656 ok
2021.09 . 26 20 : 20 : 09.103 2021.08 . 30 04 : 03 : 18    111 GBPUSD,M5: Ордера успешно модифицированы!
2021.09 . 26 20 : 20 : 09.103 2021.08 . 30 04 : 03 : 18    111 GBPUSD,M5: modify # 6 buy 0.11 GBPUSD at 1.37639 sl: 0.00000 tp: 1.37656 ok
2021.09 . 26 20 : 20 : 09.103 2021.08 . 30 04 : 03 : 18    111 GBPUSD,M5: open # 6 buy 0.11 GBPUSD at 1.37639 ok
2021.09 . 26 20 : 20 : 00.895 2021.08 . 30 03 : 45 : 18    111 GBPUSD,M5: open # 5 buy 0.09 GBPUSD at 1.37666 tp: 1.37686 ok
2021.09 . 26 20 : 19 : 53.991 2021.08 . 30 03 : 25 : 10    111 GBPUSD,M5: Максимальный и минимальный ордера на покупку успешно закрыты!
2021.09 . 26 20 : 19 : 53.991 2021.08 . 30 03 : 25 : 10    111 GBPUSD,M5: close # 3 buy 0.14 GBPUSD at 1.37624 tp: 1.37637 at price 1.37628
2021.09 . 26 20 : 19 : 53.991 2021.08 . 30 03 : 25 : 10    111 GBPUSD,M5: close # 2 buy 0.12 GBPUSD at 1.37650 tp: 1.37637 at price 1.37628
2021.09 . 26 20 : 19 : 53.991 2021.08 . 30 03 : 25 : 10    111 GBPUSD,M5: Максимальный и минимальный ордера на покупку успешно закрыты!
2021.09 . 26 20 : 19 : 53.991 2021.08 . 30 03 : 25 : 10    111 GBPUSD,M5: close # 4 buy 0.17 GBPUSD at 1.37602 tp: 1.37637 at price 1.37628
2021.09 . 26 20 : 19 : 53.991 2021.08 . 30 03 : 25 : 10    111 GBPUSD,M5: close # 1 buy 0.10 GBPUSD at 1.37672 tp: 1.37637 at price 1.37628
2021.09 . 26 20 : 19 : 46.828 2021.08 . 30 03 : 08 : 51    111 GBPUSD,M5: Ордера успешно модифицированы!
2021.09 . 26 20 : 19 : 46.828 2021.08 . 30 03 : 08 : 51    111 GBPUSD,M5: modify # 1 buy 0.10 GBPUSD at 1.37672 sl: 0.00000 tp: 1.37637 ok
2021.09 . 26 20 : 19 : 46.828 2021.08 . 30 03 : 08 : 51    111 GBPUSD,M5: Ордера успешно модифицированы!
2021.09 . 26 20 : 19 : 46.828 2021.08 . 30 03 : 08 : 51    111 GBPUSD,M5: modify # 2 buy 0.12 GBPUSD at 1.37650 sl: 0.00000 tp: 1.37637 ok
2021.09 . 26 20 : 19 : 46.828 2021.08 . 30 03 : 08 : 51    111 GBPUSD,M5: Ордера успешно модифицированы!
2021.09 . 26 20 : 19 : 46.828 2021.08 . 30 03 : 08 : 51    111 GBPUSD,M5: modify # 3 buy 0.14 GBPUSD at 1.37624 sl: 0.00000 tp: 1.37637 ok
2021.09 . 26 20 : 19 : 46.828 2021.08 . 30 03 : 08 : 51    111 GBPUSD,M5: Ордера успешно модифицированы!
2021.09 . 26 20 : 19 : 46.828 2021.08 . 30 03 : 08 : 51    111 GBPUSD,M5: modify # 4 buy 0.17 GBPUSD at 1.37602 sl: 0.00000 tp: 1.37637 ok
2021.09 . 26 20 : 19 : 46.828 2021.08 . 30 03 : 08 : 51    111 GBPUSD,M5: open # 4 buy 0.17 GBPUSD at 1.37602 ok
2021.09 . 26 20 : 19 : 44.589 2021.08 . 30 03 : 04 : 00    111 GBPUSD,M5: Ордера успешно модифицированы!
2021.09 . 26 20 : 19 : 44.589 2021.08 . 30 03 : 04 : 00    111 GBPUSD,M5: modify # 1 buy 0.10 GBPUSD at 1.37672 sl: 0.00000 tp: 1.37651 ok
2021.09 . 26 20 : 19 : 44.589 2021.08 . 30 03 : 04 : 00    111 GBPUSD,M5: Ордера успешно модифицированы!
2021.09 . 26 20 : 19 : 44.589 2021.08 . 30 03 : 04 : 00    111 GBPUSD,M5: modify # 2 buy 0.12 GBPUSD at 1.37650 sl: 0.00000 tp: 1.37651 ok
2021.09 . 26 20 : 19 : 44.589 2021.08 . 30 03 : 04 : 00    111 GBPUSD,M5: Ордера успешно модифицированы!
2021.09 . 26 20 : 19 : 44.589 2021.08 . 30 03 : 04 : 00    111 GBPUSD,M5: modify # 3 buy 0.14 GBPUSD at 1.37624 sl: 0.00000 tp: 1.37651 ok
2021.09 . 26 20 : 19 : 44.589 2021.08 . 30 03 : 04 : 00    111 GBPUSD,M5: open # 3 buy 0.14 GBPUSD at 1.37624 ok
2021.09 . 26 20 : 19 : 38.679 2021.08 . 30 02 : 48 : 40    111 GBPUSD,M5: Ордера успешно модифицированы!
2021.09 . 26 20 : 19 : 38.679 2021.08 . 30 02 : 48 : 40    111 GBPUSD,M5: modify # 1 buy 0.10 GBPUSD at 1.37672 sl: 0.00000 tp: 1.37665 ok
2021.09 . 26 20 : 19 : 38.679 2021.08 . 30 02 : 48 : 40    111 GBPUSD,M5: Ордера успешно модифицированы!
2021.09 . 26 20 : 19 : 38.679 2021.08 . 30 02 : 48 : 40    111 GBPUSD,M5: modify # 2 buy 0.12 GBPUSD at 1.37650 sl: 0.00000 tp: 1.37665 ok
2021.09 . 26 20 : 19 : 38.679 2021.08 . 30 02 : 48 : 40    111 GBPUSD,M5: open # 2 buy 0.12 GBPUSD at 1.37650 ok
2021.09 . 26 20 : 19 : 21.319 2021.08 . 30 02 : 00 : 00    111 GBPUSD,M5: open # 1 buy 0.10 GBPUSD at 1.37672 tp: 1.37692 ok
Files:
111.mq4  47 kb
 

Does not count iATR and iVolumes

Print("iATR=",iATR(Symbol(),PERIOD_M5,1), " iVolumes=", iVolumes(Symbol(),PERIOD_M5,1));

It gives out 10 and 10 all the time. Please tell me what to do.