Questions from Beginners MQL5 MT5 MetaTrader 5 - page 898

 
Sile Si:

Okay, that's what I do.

Then I compare the transaction id with the position ticker, and I think I've selected the transaction,

but it returns the price of the position. Why?

Question for the back of my mind: do you use

PositionGetDouble(POSITION_PRICE_OPEN)

Do you get the price of the trade? Or is it still the price of the position?

 
Alexey Kozitsyn:

Question for your enquiries: with the help of

Do you get the transaction price? Or is it still the price of the position?

Well, if I have preselected a trade, then it is the price of the trade. I could not find the opening price in the documentation.

 
Sile Si:

Well, if I pre-selected a trade, then that's the price of the trade. I couldn't find the opening price of the deal in the documentation.

How do you select the trade? What function?

After all, there is no trivial way to determine the opening price of a trade (not a position) in MT5. In particular cases it is possible (when a deal by parameters coincides with a position), but there is no universal way.

 
Ihor Herasko:

How do you select the transaction? What function?

After all, there is no trivial way of determining the opening price of a trade (not a position) in MT5. In particular cases, it is possible (when the deal's parameters coincide with the position), but there is no universal way.

Choosing a deal by id

DEAL_POSITION_ID

Identifier of the position, in the opening, modification or closing of which this deal was involved. Each position has a unique identifier, which is assigned to all deals made on the symbol during the position's lifetime.

long

 
Sile Si:

Selected deal by id

DEAL_POSITION_ID

Identifier of the position, in opening, modification or closing of which this deal was involved. Each position has a unique identifier, which is assigned to all deals made on the instrument during the position lifetime.

long


In the tester, the average price is considered correct. On the real account it shows someone else's price in the comment.

On accounts like Netting, the position and trade are different concepts. You have just shown us the position selection.

 
How do I find the maximum for N bars in mql5? Similar to iHighest
 
lil_lil:
How in mql5 to find the maximum for N bars? Similar to iHighest

What's wrong with iHighest?

 
lil_lil:
In mql5 how to find the maximum value of N bars? Similar to iHighest

CopyHigh into an array andArrayMaximum into this array.

This will be the maximal value, unlike iHighest which returns the index of the bar with the maximal value.

Документация по MQL5: Доступ к таймсериям и индикаторам / CopyHigh
Документация по MQL5: Доступ к таймсериям и индикаторам / CopyHigh
  • www.mql5.com
Функция получает в массив high_array исторические данные максимальных цен баров для указанной пары символ-период в указанном количестве. Необходимо отметить, что отсчет элементов от стартовой позиции ведется от настоящего к прошлому, то есть стартовая позиция, равная 0, означает текущий бар. При копировании заранее неизвестного количества...
 
lil_lil:
How do I find the maximum for N bars in mql5? Similar to iHighest
//+------------------------------------------------------------------+
//| Возвращает индекс максимального значения таймсерии High          |
//+------------------------------------------------------------------+
int Highest(const int count,const int start)
  {
   double array[];
   ArraySetAsSeries(array,true);
   return(CopyHigh(Symbol(),PERIOD_CURRENT,start,count,array)==count ? ArrayMaximum(array)+start : WRONG_VALUE);
  }
//+------------------------------------------------------------------+
//| Возвращает индекс минимального значения таймсерии Low            |
//+------------------------------------------------------------------+
int Lowest(const int count,const int start)
  {
   double array[];
   ArraySetAsSeries(array,true);
   return(CopyLow(Symbol(),PERIOD_CURRENT,start,count,array)==count ? ArrayMinimum(array)+start : WRONG_VALUE);
   return WRONG_VALUE;
  }
//+------------------------------------------------------------------+
 
Thank you.