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

 
Vitaly Muzichenko:

Here's

void OnTick()
{
  Comment( cLot(100)," | ",AccountFreeMarginCheck(_Symbol,OP_BUY,cLot(100)) );
}
Good luck to you. I'm getting an error.
 
Movlat Baghiyev:
Good luck to you. I'm getting an error.
Then let's go backwards. Show me your code. I use the same formula to calculate the lot, everything works.
 

And so, a more or less working version of the previous EA is ready

Here's the gist of it.

for example, you have 50 orders

at the command "close all", maximum 15 of them are closed; all the rest ones have timeouts and requotes

The rest require repeated passes and during sharp movements the number of passes increases considerably.

Is it possible to put this on my account?

As far as I know such appeals to the server chef is not welcome, but I could be wrong.

 
trader781:

And so, a more or less working version of the previous EA is ready

Here's the gist of it.

for example, you have 50 orders

at the command "close all", maximum 15 of them are closed; all the rest ones have timeouts and requotes

The rest require repeated passes and during sharp movements the number of passes increases considerably.

Is it possible to put this on my account?

As far as I know such appeals to the server chef is not welcome, but I could be wrong.

In order not to psycho chef should not stupidly repeat, and to analyze the errors and make a competent decision, to try again or skip.

Alternatively, if the cycle is built from 0 to ... then skipping is inevitable. Use an inverse loop

for(int i = OrdersTotal(); i >= 0; --i)
 
Alexey Viktorov:

To prevent the chef from freaking out, you should not stupidly repeat, but analyse the mistakes and make an intelligent decision whether to try again or skip it.

Alternatively, if the cycle is built from 0 to ... then skipping is inevitable. Use an inverse loop

for(int i = OrdersTotal(); i >= 0; --i)
OrdersTotal()-1
 
Artyom Trishkin:
OrdersTotal()-1
Alexey Viktorov:

To prevent the chef from freaking out, you should not stupidly repeat, but analyse the mistakes and make an intelligent decision whether to try again or skip it.

Alternatively, if the cycle is built from 0 to ... then skipping is inevitable. Use the reverse loop

for(int i = OrdersTotal(); i >= 0; --i)

here is a piece of log during the current processing, a part of it is modified, and, regardless of the command, not all orders are triggered, if there are more than 20 orders, this is repeated for all at each command, and only the tester

2017.01.05 18:31:44.919 2016.12.14 23:03:00 Tester: stop loss #716 at 1.05321 (1.05297 / 1.05347)

2017.01.05 18:31:44.919 2016.12.14 23:03:00 Tester: stop loss #715 at 1.05321 (1.05297 / 1.05347)

2017.01.05 18:31:44.919 2016.12.14 23:03:00 Tester: stop loss #714 at 1.05321 (1.05297 / 1.05347)

2017.01.05 18:31:44.919 2016.12.14 23:03:00 Tester: stop loss #713 at 1.05321 (1.05297 / 1.05347)

2017.01.05 18:31:44.919 2016.12.14 23:03:00 Tester: stop loss #712 at 1.05321 (1.05297 / 1.05347)

2017.01.05 18:31:44.919 2016.12.14 23:03:00 Tester: stop loss #711 at 1.05321 (1.05297 / 1.05347)

2017.01.05 18:31:44.919 2016.12.14 23:01:00 Moving tral-martin EURUSD,M1: OrderClose error 138

2017.01.05 18:31:44.919 2016.12.14 23:01:00 Moving tral-martin EURUSD,M1: OrderClose error 138

2017.01.05 18:31:44.919 2016.12.14 23:01:00 Moving tral-martin EURUSD,M1: OrderClose error 138

2017.01.05 18:31:44.919 2016.12.14 23:01:00 Moving tral-martin EURUSD,M1: OrderClose error 138

2017.01.05 18:31:44.919 2016.12.14 23:01:00 Moving tral-martin EURUSD,M1: OrderClose error 138

2017.01.05 18:31:44.919 2016.12.14 23:01:00 Moving tral-martin EURUSD,M1: modify #711 sell 0.01 EURUSD at 1.05862 sl: 1.05321 tp: 0.00000 ok

2017.01.05 18:31:44.919 2016.12.14 23:01:00 Moving tral-martin EURUSD,M1: modify #712 sell 0.02 EURUSD at 1.05682 sl: 1.05321 tp: 0.00000 ok

2017.01.05 18:31:44.919 2016.12.14 23:01:00 Moving tral-martin EURUSD,M1: modify #713 sell 0.04 EURUSD at 1.05388 sl: 1.05321 tp: 0.00000 ok

2017.01.05 18:31:44.919 2016.12.14 23:01:00 Moving tral-martin EURUSD,M1: modify #714 sell 0.08 EURUSD at 1.05229 sl: 1.05321 tp: 0.00000 ok

2017.01.05 18:31:44.919 2016.12.14 23:01:00 Moving tral-martin EURUSD,M1: modify #715 sell 0.16 EURUSD at 1.05077 sl: 1.05321 tp: 0.00000 ok

2017.01.05 18:31:44.919 2016.12.14 23:01:00 Moving tral-martin EURUSD,M1: modify #716 sell 0.32 EURUSD at 1.05232 sl: 1.05321 tp: 0.00000 ok

2017.01.05 18:31:44.919 2016.12.14 23:01:00 Moving tral-martin EURUSD,M1: open #716 sell 0.32 EURUSD at 1.05232 ok

2017.01.05 18:31:44.918 2016.12.14 22:52:00 Moving tral-martin EURUSD,M1: OrderClose error 138

2017.01.05 18:31:44.918 2016.12.14 22:52:00 Moving tral-martin EURUSD,M1: OrderClose error 138

2017.01.05 18:31:44.918 2016.12.14 22:52:00 Moving tral-martin EURUSD,M1: OrderClose error 138

2017.01.05 18:31:44.918 2016.12.14 22:52:00 Moving tral-martin EURUSD,M1: OrderClose error 138

2017.01.05 18:31:44.918 2016.12.14 22:52:00 Moving tral-martin EURUSD,M1: OrderModify error 4051

2017.01.05 18:31:44.918 2016.12.14 22:52:00 Moving tral-martin EURUSD,M1: invalid stoploss for OrderModify function

2017.01.05 18:31:44.918 2016.12.14 22:52:00 Moving tral-martin EURUSD,M1: modify #715 sell 0.16 EURUSD at 1.05077 sl: 200.00000 tp: 0.00000 ok

2017.01.05 18:31:44.918 2016.12.14 22:52:00 Moving tral-martin EURUSD,M1: open #715 sell 0.16 EURUSD at 1.05077 ok

2017.01.05 18:31:44.918 2016.12.14 22:44:00 Moving tral-martin EURUSD,M1: OrderClose error 138

2017.01.05 18:31:44.918 2016.12.14 22:44:00 Moving tral-martin EURUSD,M1: OrderClose error 138

2017.01.05 18:31:44.918 2016.12.14 22:44:00 Moving tral-martin EURUSD,M1: OrderClose error 138

2017.01.05 18:31:44.917 2016.12.14 22:44:00 Moving tral-martin EURUSD,M1: OrderModify error 4051

2017.01.05 18:31:44.917 2016.12.14 22:44:00 Moving tral-martin EURUSD,M1: invalid stoploss for OrderModify function

2017.01.05 18:31:44.917 2016.12.14 22:44:00 Moving tral-martin EURUSD,M1: modify #714 sell 0.08 EURUSD at 1.05229 sl: 200.00000 tp: 0.00000 ok

2017.01.05 18:31:44.917 2016.12.14 22:44:00 Moving tral-martin EURUSD,M1: open #714 sell 0.08 EURUSD at 1.05229 ok

2017.01.05 18:31:44.916 2016.12.14 22:09:00 Moving tral-martin EURUSD,M1: OrderClose error 138

2017.01.05 18:31:44.916 2016.12.14 22:09:00 Moving tral-martin EURUSD,M1: OrderClose error 138

2017.01.05 18:31:44.916 2016.12.14 22:09:00 Moving tral-martin EURUSD,M1: OrderModify error 4051

 
Artyom Trishkin:
OrdersTotal()-1

Nope. That's right. Artyom, read about prefix and postfix increment/decrement functions.

In my version, the start value is first decreased by 1 and then the cycle starts.

 
Alexey Viktorov:

Nope. That's right. Artyom read about prefix and postfix increment/decrement functions.

In my version, the start value is first decreased by 1 and then the cycle starts.

Didn't pay attention to decrement - I'm on my mobile...
 

trader781:   вот кусок журнала при текущей обработке, часть кроется часть модифицируется, причем вне зависимости от команды сработают не все ордера, если ордеров больше 20, это повторяется для всех при каждой команде, а ведь только тестер

Again with zero slippage (138)?

And the stoplosses are not calculated correctly, according to the logbook.
 
Vitalie Postolache:

Again with zero slippage (138)?

50 is everywhere

the fact that with a great number of orders all of them are not simultaneously closed or modified

Stop Losses - the hell with them, I'll figure them all out when I close them all at once

for now it is like this

https://www.mql5.com/ru/charts/6368852/eurusd-m1-metaquotes-software-corp

График EURUSD, M1, 2017.01.05 17:10 UTC, MetaQuotes Software Corp., MetaTrader 4, Demo
График EURUSD, M1, 2017.01.05 17:10 UTC, MetaQuotes Software Corp., MetaTrader 4, Demo
  • www.mql5.com
Символ: EURUSD. Период графика: M1. Брокер: MetaQuotes Software Corp.. Торговая платформа: MetaTrader 4. Режим торговли: Demo. Дата: 2017.01.05 17:10 UTC.
Reason: