[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 951

 
Stepan241:
I have slightly modified your intikator in terms of the presentation of the information. Take a closer look. There are mixed signals in it.

Post deleted. One has already been banned for a month.
 
001:

That's exactly what I was describing this logic, with a ticker, so with a ticker, I don't understand how to implement it better in the code. I can't think of anything other than an array. Thanks to those who responded.
Carefully read previous posts. I've already written that it's easier to open an opposite pose with another magik. Then the check for position loss will skip an already open opposite position and there will be no re-openings.
 
Vinin:

Post deleted. One has already been banned for a month.
I have modified this indicator only for one purpose, to see the signals in more detail. If there are divergent ones, they are always shown with red line on the NORMAL indicator. I am not saying it is bad or glitchy, it is great. I am not saying it is bad or glitchy, it's great... Just if you want a beginner to understand why the signals are missing, you better watch it and not just read it.
 
Stepan241:
I have modified this indicator with one purpose - to see the signals in more detail. If there are differently directed signals, they are always shown with a red line on the NORMAL indicator. I am not saying it is bad or glitchy, it is great. I am not saying it is bad or glitchy, it's great... Just if you want a beginner to understand why the signals are missing, you better watch it and not just read it.
You should "watch" in private, not dump broken indicators on official website forum ...
 
artmedia70:

You need to adjust the digits for the yen if you are working with it and the order symbol contains JPY. Do not worry - this function will do everything for you. And it should be placed, as well as any other functions outside the body of the EA. And you should call it from the EA as follows:



if (isCloseLastPosByStop(Symbol(), OP_BUY, Magic)) // Если последняя закрытая позиция Buy на текущем графике с магиком Magic была закрыта по стопу, то ...
   {
      // .......... тут код, который выполнится при данном условии
   }
//--------------------------------------------------------------------------------------------------------------------------
if (isCloseLastPosByStop(USDJPY, OP_SELL, Magic)) // Если последняя закрытая позиция Sell с символом USDJPY с магиком Magic была закрыта по стопу, то ...
   {
      // .......... тут код, который выполнится при данном условии
   }
//--------------------------------------------------------------------------------------------------------------------------
if (isCloseLastPosByStop()) // Если любая последняя закрытая позиция с любым символом и любым магиком была закрыта по стопу, то ...
   {
      // .......... тут код, который выполнится при данном условии
   }
артем,я выбрал третье условие, и вбил самый простейший код "Alert" и что,
у меня в истории были и убытки и прибыли, функция срабатывала в любом случае и при прибыли и при убытке 

 

How do I get the profit/loss of the last ten orders from the whole history?

 
DhP:

How do I get the profit/loss of the last ten orders out of the entire history?


take a calculator, do the math))))

.

.

.

.

.

I was recently shown the code for the last closed order, see if you can get it to work.

bool isCloseLastPosByStop(string sy="", int op=-1, int mn=-1) {// Объявление функции. Передаваемые параметры: sy = символ, op - тип, mn - магик
  datetime t;                                                  // Переменная содержит время закрытия ордера
  double   ocp, osl;                                           // ocp - цена закрытия позиции, osl - цена СтопЛосс закрытой позиции
  int      dg, i, j=-1, k=OrdersHistoryTotal();                // k содержит общее количество ордеров в истории

  if (sy=="0") sy=Symbol();                                 // Если в ф-цию передан sy равный 0 или NULL, то использовать символ графика
  for (i=0; i<k; i++) {                                     // Цикл по массиву закрытых ордеров
    if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) {      // Если выбран ордер из массива закрытых ордеров, ...
      if (OrderSymbol()==sy || sy=="") {                    // ... если его символ совпадает с нашим, ...
        if (OrderType()==OP_BUY || OrderType()==OP_SELL) {  // ... если его тип Бай или Селл, ...
          if (op<0 || OrderType()==op) {                // ... если тип ордера равен или -1 (имеется ввиду любой) или равен переданному в ф-цию, ...
            if (mn<0 || OrderMagicNumber()==mn) {       // ... если его магик или любой (-1) или равен переданному в ф-цию (магику советника), ...
              if (t<OrderCloseTime()) {    // ... если переменная t содержит время закрытия меньше, чем время закрытия выбранного ордера, то ...
                t=OrderCloseTime();        // ... то присвоим переменной t время закрытия выбранного ордера (этот ордер закрыт позже предыдущего)
                j=i;                                        // Запишем в переменную j индекс найденного ордера с максимальным временем закрытия
              }
            }
          }
        }
      }
    }
  }                                                       // По окончании цикла в переменной j находится индекс последнего закрытого ордера
  if (OrderSelect(j, SELECT_BY_POS, MODE_HISTORY)) {      // Выберем его по индексу
    dg=MarketInfo(sy, MODE_DIGITS);                       // Количество цифр после десятичного точки в цене инструмента, заданного переменной sy
    if (dg==0) if (StringFind(OrderSymbol(), "JPY")<0) dg=4; else dg=2; // Честно... точно не скажу, но вижу, что корректировка под йену
    ocp=NormalizeDouble(OrderClosePrice(), dg);           // Нормализуем цену закрытия ордера для дальнейшего сравнения с ценой СтопЛосс
    osl=NormalizeDouble(OrderStopLoss(), dg);             // Нормализуем цену СтопЛосс ордера для сравнения с ценой закрытия
    if (ocp==osl) return(True);                           // Если эти цены равны, значит поза закрыта по стопу, возвращаем значение "Истина"
  }
  return(False);                                          // Возвращаем "Ложь"
}
 
Is there a script or advisor that buys several orders and sells all orders at + profit ... tell me who knows please
 

Dear forum users. Who can tell me how to correctly write the condition "for a market buy order to open below the opening price of the previous market buy order?

 
fanat:

Dear forum users. Who can tell me how to correctly write the condition "for a market buy order to open below the opening price of the previous market buy order?

A couple of pages ago I posted a procedure that searches the history for the last trade with the specified symbol and returns its profit. Using this code as a base you can return not the profit of the last deal, but for example the opening or closing price of the last deal..... or any other data.
Reason: