[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 581

 
Vovo4ka:

Why is the profit taken, not the one that should be..... when the lot is closed, but when the profit should be 30pp in profit is written in a completely different way....


What is this nonsense: "essentially calculate the difference between opening an order and closing it) and summarise?????? ...

And on what volumes? Don't you need to know? The price of a point will be different...

Profit is not calculated in points, but in currency, depending on the volume of traded positions.

 
Vovo4ka:

For some reason the profit is taken, not the one that should be..... when the lot is closed, inversely when the profit should be 30pp in profit it is written completely different....


The profit of the order is not in points, but in the deposit currency.

 

Correct - here the total loss (loss) is calculated from the history of closed LOCAL orders at a loss.

This is a little different for you, but the principle is the same.

//---------------------расчет по истории ордеров номера очередной итерации----------------------------------------------- 
  Iteration = 0; // зануляем инерации перед их учетом в цикле по истории
  Sum_Loss = 0;  // суммарный убыток по этим итерациям
  datetime 
  Time_at_History_Current = 0,
  Time_at_History_Previos = 0;      
  if(OrdersHistoryTotal() != 0)
   {
    for(int counter = OrdersHistoryTotal()-1; counter >= 0; counter--)
      {
       OrderSelect(counter, SELECT_BY_POS, MODE_HISTORY);
       if(OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
         {
          if(OrderType() == OP_BUY || OrderType() == OP_SELL)
            {
             if(OrderProfit() < 0) // если убыток по выбранному ордеру, то считаем суммарный и записываем время закрытия ордера
                                   // для последующего его анализа при подсчете количества итераций
                {
                 double lastLoss = OrderProfit();
                 Sum_Loss=Sum_Loss+lastLoss;  // считаем общий убыток по закрытым подряд убыточным ордерам
                 Time_at_History_Current = OrderCloseTime();
                } 
             
             //Print(" Time_at_History_Current_в цикле = ", TimeToStr(Time_at_History_Current, TIME_DATE|TIME_SECONDS));
             //Print(" Time_at_History_Previos_в цикле = ", TimeToStr(Time_at_History_Previos, TIME_DATE|TIME_SECONDS));
             
             if(Time_at_History_Current != Time_at_History_Previos) // если они не равны, то считаем итерации и делаем их равными
               {
                Time_at_History_Previos = Time_at_History_Current ;
                Iteration++;              
                //Print("Iteration at History в условии сравнения  = ",  Iteration);
               }   
             else // они равны, то проверяем, дополнительно, наличие профита по выбранному следующему ордеру и выходим из цикла
               {
                if(OrderProfit() >= 0) 
                  break;
               }
            }
         }
      }
   }
 
PapaYozh:


The profit of the order is not in pips, but in the currency of deposit.


i need it in pips, the lot is fixed at 1.... but the profit or loss does not correspond to the real one..... and i want to calculate the number of pips in profit and drawdown easier and sum it up and get the result=)
 
Roman.:

Correct - here the total loss (loss) is calculated from the history of closed LOCAL orders at a loss.

This is a little different for you, but the principle is the same.


Thank you, I'll deal with it now=)
 
Vovo4ka:

I need it in pips, the lot is fixed at 1.... but the profit or loss does not correspond to the real one..... and I want to calculate the number of pips in profit and drawdown easier and sum it up and get the result=)


Once again:

The profit of the order is not in pips, but in the currency of the deposit.

 
Vovo4ka:

I need it in points, the lot is constant 1.... but for some reason the profit or loss does not correspond to the real one.....to me I want to calculate the number of points of profit and drawdown easier to sum up and get the result =)

Well, if the lot is constant, divide the tester profit by the point. You will get the profit in pips.
 

Kim's latest published function GetPotentialLossInCurrency (https://forum.mql4.com/ru/11287/page107) only counts open orders:

if (OrderType()==OP_BUY) {
                pl+=(OrderOpenPrice()-OrderStopLoss())/po*OrderLots()*tv;
              }
if (OrderType()==OP_SELL) {
                pl+=(OrderStopLoss()-OrderOpenPrice())/po*OrderLots()*tv;
              }
I tried to extend it a bit to include pending orders (by simply adding other types):
if (OrderType()==OP_BUY || OrderType()==OP_BUYLIMIT || OrderType()==OP_BUYSTOP) {
                     pl+=(OrderOpenPrice()-OrderStopLoss())/po*OrderLots()*tv;
                     }
if (OrderType()==OP_SELL || OrderType()==OP_SELLLIMIT || OrderType()==OP_SELLSTOP) {
                     pl+=(OrderStopLoss()-OrderOpenPrice())/po*OrderLots()*tv;
                  }
but pending orders are not considered. Are they counted differently? The documentation doesn't say anything about this....
 
artmedia70:
Display all flags on the chart with Comment` and you will see why the trade opens.

put it in, now the trades don't open at all.
Files:
1_1.mq4  21 kb
 
Ivn:

I put it in, now it doesn't make any sdeks at all.

Why would you do that? Output all the flags in one Comment at once.

Here:

int start()
  {
//----


 RefreshRates();                        // Обновление данных
 Symb=Symbol();
 int cnt, ticket, total;
 int ABuy=0;                               // флаг на покупку /продажу   
 int ASell=0;   
 
   Comment(".....Вот сюда и пишите вывод всех флагов......");

 if (NewBar() == true)
{        
     x=x0; //передаем данные 
    x1=x01;
    x2=x02;
Reason: