Questions from Beginners MQL5 MT5 MetaTrader 5 - page 164

 

Gentlemen, please tell me what to write in the last two lines when modifying a pending order if its lifetime is set. (e.g. 6 hours - ).

request.type_time = ORDER_TIME_SPECIFIED; // the order will be valid until the expiry date
request.expiration = TimeCurrent()+6*3600;// last known server time + count*hours

If the lifetime doesn't change, can we not write anything at all when modifying? By default it will die by itself.

And if you need to change its lifetime?

Modify Pending Order

Trade request to modify pending order price levels. 7 fields are required:

-action

-order

-price

-sl

-tp

-type_time

-expiration

These are the two lines in the Handbook that I can't get into:

type_time

Type of order at expiration time. Value can be one of the values ENUM_ORDER_TYPE_TIME

expiration

Expirationtime of the pending order (for orders of the ORDER_TIME_SPECIFIEDtype )

Please write how they should look in the expert, when modifying, I will understand. Thank you in advance.

You can omit these two lines altogether.

You can write one, for example: request.type_time = ORDER_TIME_DAY; in this case the order will be deleted after 1 day,

other options: https://www.mql5.com/ru/docs/constants/tradingconstants/orderproperties#enum_order_type_time

Stringrequest.expiration = TimeCurrent()+6*3600;//last known server time + number of hours*hours

you specify the expiry time of the order.

https://www.mql5.com/ru/articles/481

Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров
Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров
  • www.mql5.com
Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров - Документация по MQL5
 

Help for a newbie, please.

I have installed Alpari MT5, the optimization is working as it should be, i.e. all the charts are drawing and reports are being generated, and the history is fine. After I have installed MT5 on the same PC with Insta, I have downloaded some test history there and now I have no charts and optimization results both in Insta and Alpari. After I have dismounted everything and only Alpari has been installed, optimization works perfectly again. However, after installing Insta on another computer in the local network, optimization results are again lost.

Same EA in all cases, log is flooded with best resalt messages, only local agents are being used.

Does anybody use two or more mt5 at the same time on one computer or on the local network, or maybe have faced such a problem?




 
Crucian:

These two lines may not be written at all.

You can write one, for example: request.type_time = ORDER_TIME_DAY; in this case the order will be deleted after 1 day,

I see. That's what I thought, when modifying.


request.type_time =ORDER_TIME_DAY - I think it is the same as -

input int t = 24;

request.expiration = TimeCurrent()+t*3600;

 
rosomah:

I see. That's what I thought, when modifying.


request.type_time =ORDER_TIME_DAY - I guess it is the same as -

input int t = 24;

request.expiration = TimeCurrent()+t*3600;

I gave you the linkhttps://www.mql5.com/ru/docs/constants/tradingconstants/orderproperties#enum_order_type_time that 4 variants can be used forrequest.type_time :


ORDER_TIME_GTC
The order will be in the queue until the

ORDER_TIME_DAY
Order will only be active during the current trading day

ORDER_TIME_SPECIFIED
Order will be valid until the expiry date

ORDER_TIME_SPECIFIED_DAY
The order will be in effect until 00:00 on the specified date. If that time does not fall on a trading session, the expiration will be at the nearest trading time.

And gave you the link to https://www.mql5.com/ru/articles/481 , which gives the code of the trade request when modifying an order using the ready-made CTrade class https://www.mql5.com/ru/docs/standardlibrary/tradeclasses/ctrade.

The code is this:

//--- тикет ордера указан только для примера, его нужно получить
   ulong ticket=1234556;
//--- символ также указан для примера, его нужно получить
   string symbol="EURUSD";
//--- количество знаков после запятой
   int    digits=(int)SymbolInfoInteger(symbol,SYMBOL_DIGITS);
//--- значение пункта
   double point=SymbolInfoDouble(symbol,SYMBOL_POINT);
//--- получим цену покупки
   double price=SymbolInfoDouble(symbol,SYMBOL_ASK);
//--- вычислим и нормализуем уровни SL и TP
//--- на самом деле они должны вычисляться в зависимости от типа ордера
   double SL=NormalizeDouble(price-1000*point,digits);
   double TP=NormalizeDouble(price+1000*point,digits);
   //--- зададим срок действия одни сутки
   datetime expiration=TimeTradeServer()+PeriodSeconds(PERIOD_D1); //!!!  
//--- все готово, делаем попытку модифицировать ордер 
   if(!trade.OrderModify(ticket,price,SL,TP,ORDER_TIME_GTC,expiration)) //!!!
     {
      //--- сообщим о неудаче
      Print("Метод OrderModify() потерпел неудачу. Код возврата=",trade.ResultRetcode(),
            ". Описание кода: ",trade.ResultRetcodeDescription());
     }
   else
     {
      Print("Метод OrderModify() выполнен успешно. Код возврата=",trade.ResultRetcode(),
            " (",trade.ResultRetcodeDescription(),")");
     }

Read about time in MQL5 here:https://www.mql5.com/ru/articles/599 .

Use search and read articles and documentation.


Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров
Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров
  • www.mql5.com
Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров - Документация по MQL5
 

Hello all!

Please don't throw stones, but I couldn't find any...

no positions open on the EA... It says this

2013.12.23 03:00:01 Core 1 2013.12.20 23:30:00 failed instant buy 1.00 EURUSD at 1.36720 sl: 1.06720 tp: 1.46720 [Invalid request]

и

2013.12.23 03:00:01 Core 1 2013.12.20 23:30:00 Alert: Request to place Buy order failed - error code:4756

What could it be?

mrequest.action = TRADE_ACTION_DEAL; // immediate execution

mrequest.price = NormalizeDouble(latest_price.ask,_Digits); // latest ask price

mrequest.sl = NormalizeDouble(latest_price.ask - STP*_Point,_Digits); // Stop Loss

mrequest.tp = NormalizeDouble(latest_price.ask + TKP*_Point,_Digits); // Take Profit

mrequest.symbol = _Symbol; // symbol

mrequest.volume = Lot; // number of lots to trade

mrequest.magic = EA_Magic; // Magic Number

mrequest.type = ORDER_TYPE_BUY; // buy order

mrequest.type_filling = ORDER_FILLING_FOK; // order type - all or nothing

mrequest.deviation=100; // slippage from the current price

//----send order

OrderSend(mrequest,mresult);

Документация по MQL5: Стандартные константы, перечисления и структуры / Состояние окружения / Информация об инструменте
Документация по MQL5: Стандартные константы, перечисления и структуры / Состояние окружения / Информация об инструменте
  • www.mql5.com
Стандартные константы, перечисления и структуры / Состояние окружения / Информация об инструменте - Документация по MQL5
 
Armen:

Armen, please. paste the code into the code frame. Ctrl+"5". Better yet, press the SRC button in the editor, paste into the box and press [ok].

It's not clear. :(

 
MetaDriver:

Armen, please. paste the code into the code frame. Ctrl+"5". Better yet, press the SRC button in the editor, paste into the box and press [ok].

It's not clear. :(

sorry, I'll redo it now...
 

Hello all!

Please don't throw stones, but I couldn't find any...

no positions open on the EA... It gives this

2013.12.23 03:00:01 Core 1 2013.12.20 23:30:00 failed instant buy 1.00 EURUSD at 1.36720 sl: 1.06720 tp: 1.46720 [Invalid request]

и

2013.12.23 03:00:01 Core 1 2013.12.20 23:30:00 Alert: Request to place Buy order failed - error code:4756

What could it be?

         mrequest.action = TRADE_ACTION_DEAL;                                  // немедленное исполнение

         mrequest.price = NormalizeDouble(latest_price.bid,_Digits);           // последняя цена Bid

         mrequest.sl = NormalizeDouble(latest_price.bid + STP*_Point,_Digits); // Stop Loss

         mrequest.tp = NormalizeDouble(latest_price.bid - TKP*_Point,_Digits); // Take Profit

         mrequest.symbol = _Symbol;                                            // символ

         mrequest.volume = Lot;                                                // количество лотов для торговли

         mrequest.magic = EA_Magic;                                            // Magic Number

         mrequest.type = ORDER_TYPE_SELL;                                       // ордер на продажу

         mrequest.type_filling = ORDER_FILLING_FOK;                            // тип исполнения ордера - все или ничего

         mrequest.deviation=100;                                               // проскальзывание от текущей цены

         //--- отсылаем ордер

         OrderSend(mrequest,mresult);

 
Armen:

Hi all!

Please don't throw stones, but I couldn't find any...

no positions open on the EA... it gives this...

Better send an order to open a position/order as described in Trading operations in MQL5 - it's easy.
 
paladin800:
The problem is that I need to redo (a bit) the ready-made owl.
The problem is, I need to modify (a bit) the ready-made owls... :(
Reason: