Questions from Beginners MQL5 MT5 MetaTrader 5 - page 118

 
Top2n:

I zeroed out via ZeroMemory(mrequest);

I don't really understand the order execution modes, alpari broker, i think everything is standard. Damn, it's not working, I just don't want to do it. I looked at the order sl and tp, it showed the current price + sl. I do not know what is the norm!

Even in this form on the server MQ errors in the tester does not occur:

input int    StopLoss   =499;   // Stop Loss
input int    TakeProfit =999;   // Take Profit
input int    EA_Magic   =12345; // Magic Number советника
input double Lot        =0.1;   // Количество лотов для торговли
//---
MqlTick         latest_price;        // Будет использоваться для текущих котировок
MqlTradeRequest mrequest;            // Будет использоваться для отсылки торговых запросов
MqlTradeResult  mresult;             // Будет использоваться для получения результатов выполнения торговых запросов
//---
int STP = StopLoss;
int TKP = TakeProfit;
//+------------------------------------------------------------------+
//| ИНИЦИАЛИЗАЦИЯ                                                    |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- Для работы с брокерами, использующими 5-ти значные котировки,
//    умножаем на 10 значения SL и TP
   STP = StopLoss;
   TKP = TakeProfit;
   if(_Digits==5 || _Digits==3)
     {
      STP = STP*10;
      TKP = TKP*10;
     }
   return(0);
  }
//+------------------------------------------------------------------+
//| ДЕИНИЦИАЛИЗАЦИЯ                                                  |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {

  }
//+------------------------------------------------------------------+
//| СОБЫТИЕ ТИК ТЕКУЩЕГО СИМВОЛА                                     |
//+------------------------------------------------------------------+
void OnTick()
  {
   SymbolInfoTick(Symbol(),latest_price); // Получаем текущие цены
//---
   mrequest.action = TRADE_ACTION_DEAL;                                  // немедленное исполнение
   mrequest.price = NormalizeDouble(latest_price.ask,_Digits);           // последняя цена ask
   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;                                            // символ
   mrequest.volume = Lot;                                                // количество лотов для торговли
   mrequest.magic = EA_Magic;                                            // Magic Number
   mrequest.type = ORDER_TYPE_BUY;                                       // ордер на покупку
   mrequest.type_filling = ORDER_FILLING_FOK;                            // тип исполнения ордера - все или ничего
   mrequest.deviation=100;                                               // проскальзывание от текущей цены
//--- отсылаем ордер
   OrderSend(mrequest,mresult);
  }

//---

If it turns out that the matter is in the execution modes, then approximately so should be done:

// В режиме Instant Execution позицию можно открыть
// сразу с установленными уровнями Stop Loss и Take Profit
   if(smb.trade_exec==SYMBOL_TRADE_EXECUTION_INSTANT)
     {
      // Если позиция не открылась, вывести сообщение об этом
      if(!trd.PositionOpen(_Symbol,type_ord,lot,oprice,sl,tp,comment))
        { Print("Ошибка при открытии позиции: ",GetLastError()," - ",ErrorDesc(GetLastError())); }
     }
//---
// В режиме Market Execution сначала нужно открыть позицию и
// только после этого можно установить уровни Stop Loss и Take Profit
   if(smb.trade_exec==SYMBOL_TRADE_EXECUTION_MARKET)
     {
      // Если позиции нет, то сначала откроем позицию
      // а затем установим Stop Loss и Take Profit
      if(!pos.exist)
        {
         // Если позиция не открылась, вывести сообщение об этом
         if(!trd.PositionOpen(_Symbol,type_ord,lot,oprice,0,0,comment))
           { Print("Ошибка при открытии позиции: ",GetLastError()," - ",ErrorDesc(GetLastError())); }
         else
           {// Если позиция открылась, то сначала выберем её и...
            if((pos.exist=PositionSelect(_Symbol))) // ...если позиция есть, то...
              {
               // ...установим Stop Loss и Take Profit
               if(!trd.PositionModify(_Symbol,sl,tp))
                 { Print("Ошибка при модификации позиции: ",GetLastError()," - ",ErrorDesc(GetLastError())); }
              }
           }
        }
      else
        {// Если позиция есть, то увеличим её объём и
         // оставим Stop Loss и Take Profit на их прежнем уровне
         // Если позиция не открылась, вывести сообщение об этом
         if(!trd.PositionOpen(_Symbol,type_ord,lot,oprice,sl,tp,comment))
           { Print("Ошибка при открытии позиции: ",GetLastError()," - ",ErrorDesc(GetLastError())); }
        }
     }
 
how to write it shorter
iClose(Symbol(),1440,1)
in MQL5?
 
zfs:
how to write it shorter in MQL5?
https://www.mql5.com/ru/articles/81
Переход с MQL4 на MQL5
Переход с MQL4 на MQL5
  • 2010.05.11
  • Sergey Pavlov
  • www.mql5.com
Данная статья, построенная в форме справочника по функциям MQL4, призвана помочь переходу с MQL4 на MQL5. Для каждой функции языка MQL4 приведено описание и представлен способ ее реализации на MQL5, что позволит вам значительно ускорить перевод своих программ с MQL4 на MQL5. Для удобства функции разбиты на группы, как в документации по MQL4.
 

Can you please tell me where is the economic calendar in MT5? I can't find it in mine (there is news that comes non-stop every 1 to 5 minutes exactly, all different).

Thanks.

http://www.profi-forex.org/journal/number17/page8.html#prettyPhoto

Основные отличия МТ5 от МТ4
Основные отличия МТ5 от МТ4
  • 2012.08.06
  • Биржевой лидер
  • www.profi-forex.org
Первое, что следует отметить и принять как должное, это отсутствие локов - встречных позиций. Пожалуй, это основное, что вызывает у части трейдеров недоумение и, возможно, разочарование, в то время как для тех, кто торгует без локов, это изменение вполне закономерно и логично. Если мы обратимся к другим профессиональным платформам, то увидим...
 
mzk_3om6u:

Can you please tell me where is the economic calendar in MT5? I can't find it in mine (there is news that comes non-stop every 1 to 5 minutes exactly, all different).

Thanks.

http://www.profi-forex.org/journal/number17/page8.html#prettyPhoto

The news that comes in is the mail tab.

The calendar is also there.

You can only see them if you connect to a real mt5 account

 

mzk_3om6u: 

Can you please tell me where is the economic calendar in MT5? I can't find it in mine (there is news that comes non-stop every 1 to 5 minutes exactly, all different).

Thanks.

From the Terminal Help(F1):

This tab may be missing if the economic calendar is disabled on the trade server.

>>> Calendar

 
mzk_3om6u:

Can you please tell me where is the economic calendar in MT5...?


A broker may not provide a calendar, accordingly, a particular broker may not have one. It seems like this.

 

Good afternoon.

Where can I ask a question in relation to schedule changes.

An example of this.I have already checked the schedule for manual control by the company on several occasions and it is often confirmed.

Write a link to this question! Thank you.

 
Serega_444:

Good afternoon.

Where can I ask a question in relation to schedule changes.

An example of this.I have already checked the schedule for manual control by the company on several occasions and it is often confirmed.

Please send me a link to this question.

Please decipher. What do you mean? History, trades, charting...?

To start with, in any case - to the technical support of the company. With proof (screenshots, logs).

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

Greetings.

Can you tell me if it is possible in principle to write a script to transfer candlestick chart data to an Excel file?

Reason: