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

 
Vladimir Karputov:

ENUM_TRADE_REQUEST_ACTIONS

Identifier

Description

TRADE_ACTION_DEAL

Place a trade order for an immediate execution with the specified parameters (market order)

TRADE_ACTION_PENDING

Place a trade order for the execution under specified conditions (pending order)

Example of the TRADE_ACTION_PENDING trade operation for placing a pending order:

#property description "Example of placing pending orders"
#property script_show_inputs
#define  EXPERT_MAGIC 123456                             // MagicNumber of the expert
input ENUM_ORDER_TYPE orderType=ORDER_TYPE_BUY_LIMIT;   // order type
//+------------------------------------------------------------------+
//| Placing pending orders                                           |
//+------------------------------------------------------------------+
void OnStart()
  {
//--- declare and initialize the trade request and result of trade request
   MqlTradeRequest request={0};
   MqlTradeResult  result={0};
//--- parameters to place a pending order
   request.action   =TRADE_ACTION_PENDING;                             // type of trade operation
   request.symbol   =Symbol();                                         // symbol
   request.volume   =0.1;                                              // volume of 0.1 lot
   request.deviation=2;                                                // allowed deviation from the price
   request.magic    =EXPERT_MAGIC;                                     // MagicNumber of the order
   int offset = 50;                                                    // offset from the current price to place the order, in points
   double price;                                                       // order triggering price
   double point=SymbolInfoDouble(_Symbol,SYMBOL_POINT);                // value of point
   int digits=SymbolInfoInteger(_Symbol,SYMBOL_DIGITS);                // number of decimal places (precision)
   //--- checking the type of operation
   if(orderType==ORDER_TYPE_BUY_LIMIT)
     {
      request.type     =ORDER_TYPE_BUY_LIMIT;                          // order type
      price=SymbolInfoDouble(Symbol(),SYMBOL_ASK)-offset*point;        // price for opening 
      request.price    =NormalizeDouble(price,digits);                 // normalized opening price 
     }
   else if(orderType==ORDER_TYPE_SELL_LIMIT)
     {
      request.type     =ORDER_TYPE_SELL_LIMIT;                          // order type
      price=SymbolInfoDouble(Symbol(),SYMBOL_ASK)+offset*point;         // price for opening 
      request.price    =NormalizeDouble(price,digits);                  // normalized opening price 
     }
   else if(orderType==ORDER_TYPE_BUY_STOP)
     {
      request.type =ORDER_TYPE_BUY_STOP;                                // order type
      price        =SymbolInfoDouble(Symbol(),SYMBOL_ASK)+offset*point; // price for opening 
      request.price=NormalizeDouble(price,digits);                      // normalized opening price 
     }
   else if(orderType==ORDER_TYPE_SELL_STOP)
     {
      request.type     =ORDER_TYPE_SELL_STOP;                           // order type
      price=SymbolInfoDouble(Symbol(),SYMBOL_ASK)-offset*point;         // price for opening 
      request.price    =NormalizeDouble(price,digits);                  // normalized opening price 
     }
   else Alert("This example is only for placing pending orders");   // if not pending order is selected
//--- send the request
   if(!OrderSend(request,result))
      PrintFormat("OrderSend error %d",GetLastError());                 // if unable to send the request, output the error code
//--- information about the operation
   PrintFormat("retcode=%u  deal=%I64u  order=%I64u",result.retcode,result.deal,result.order);
  }
//+------------------------------------------------------------------+
 
Vladimir Karputov:

ENUM_TRADE_REQUEST_ACTIONS

Identifier

Description

TRADE_ACTION_DEAL

Place a trade order for an immediate execution with the specified parameters (market order)

TRADE_ACTION_PENDING

Place a trade order for the execution under specified conditions (pending order)

Thank you!

 
Vladimir Karputov:

Example of the TRADE_ACTION_PENDING trade operation for placing a pending order:

Vladimir, can't you write it in Russian?
 
Artyom Trishkin:
Vladimir, can't you write it in Russian?

You can't. Because I quoted the full reference. Otherwise, it's a long shot: everyone has a 'ticket' and some have 'tickets'. That's why the functions, help and quotes from the help are in English.

 
Vladimir Karputov:

You can't. Because I quoted in full from the reference. Otherwise, it's a long shot: everyone has a "ticket" and some have "tickets". Therefore, the functions, the reference and the quotes in the reference are in English.

And they have "tickets" just because they start translating with google :)
In the Russian official help, there are "tickets".
In forest-da-drow just from free translations.
 

Hello all! I think the question is primarily for the pros (as it turns out). It has been a week with one question about the code.

For example - we know that the M5 candle contains 5 candles M1 (for example, 00:00, 00:01, 00:02, 00:03 and 00:04). Further we will consider only this conjunction - i.e. we run the indicator on M1 and want to see the indicator readings from M5.

I.e. to correctly display data of the middle TF on the lower one, I should loop through all 5 bars of the lower TF as they appear. I.e. the first bar appears 00:00, then 00:01 etc. up to 00:04 and after that the next one appears. It means the cycle should be from 0 to 4 - this is the maximum, while gaps in history are not considered. The problem is that I get the cycle from 0 to 5, and I do not have enough logic to make it up to 4! Believe me, I've been struggling with this for a week now and I'm really asking for your help. Below is a very truncated code where the loop goes to 5 instead of 4. I want it to 4!!!!!

#property copyright ""
#property link      ""
#property version   ""
#property indicator_chart_window

//+----------------------------------------------+
//| Входные параметры индикатора                 |
//+----------------------------------------------+
input ENUM_TIMEFRAMES TF=PERIOD_M5;
int LastCountBar;
datetime tt;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,    // количество истории в барах на текущем тике
                const int prev_calculated,// количество истории в барах на предыдущем тике
                const datetime &time[],
                const double &open[],
                const double& high[],     // ценовой массив максимумов цены для расчёта индикатора
                const double& low[],      // ценовой массив минимумов цены  для расчёта индикатора
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
   datetime IndTime[1];
//--- объявления локальных переменных
   int limit,bar;
//--- индексация элементов в массивах как в таймсериях
   ArraySetAsSeries(time,true);
//--- расчёт стартового номера first для цикла пересчёта баров
   if(prev_calculated>rates_total || prev_calculated<=0) // проверка на первый старт расчёта индикатора
     {
      limit=100; // стартовый номер для расчёта всех баров
      LastCountBar=limit;
     }
   else
      limit=LastCountBar+rates_total-prev_calculated; // стартовый номер для расчёта новых баров

//--- основной цикл расчёта индикатора
   for(bar=limit; bar>=0; bar--)
     {
      //--- копируем вновь появившиеся данные в массив IndTime
      if(CopyTime(Symbol(),TF,time[bar],1,IndTime)<=0)
         return(0);
         
      if(time[bar]>=IndTime[0] && time[bar+1]<IndTime[0])
        {
         LastCountBar=bar;
         //--- Далее проводим вычисления индикатора МТФ ...............
         Print(bar," ",IndTime[0]);
         //---
        }
     }
   return(rates_total);
  }
//+------------------------------------------------------------------+
 

How do I add a list view editing window?

https://www.mql5.com/en/docs/standardlibrary/controls/clistview

I have the library above. I want to add an edit box with a label inside this list. Can you tell me how I can do this? I've tried, but it doesn't work.

Documentation on MQL5: Standard Library / Panels and Dialogs / CListView
Documentation on MQL5: Standard Library / Panels and Dialogs / CListView
  • www.mql5.com
//|                                             ControlsListView.mq5 | //|                        Copyright 2017, MetaQuotes Software Corp. | //|                                             https://www.mql5.com | //| defines                                                          |  INDENT_LEFT                         (11)      ...
 
Artyom Trishkin:
And they have "tickets" just because they start translating with google :)
In the Russian official reference "tickety-boo".
Into the woods-da-drova just from free translations.
OK, I confess: caught me. Answered quickly and didn't switch the help language 😎
 
The question is this. Can I open 2 (or more) charts at the touch of a button so that they are positioned vertically, equally occupying the entire monitor?
 
Vladimir Karputov:
OK, I confess: caught me. Answered quickly and didn't switch the help language 😎

Copy that ;)

Reason: