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

 

If, for example, 10 years the profit on a trading account was 500% (figures are notional) -
how to calculate the average annual profit, also taking into account that all profits are reinvested?
Thank you!

 
frixer:
Hello everyone, Happy New Year. I can't find any way to place an order only once, if the condition is fulfilled after which the order is placed, then if there is an order for the second time it will not be placed. I would like to give you an example.

The example from the textbook is your case.
 
atztek:

If, for example, 10 years the profit on a trading account was 500% (figures are notional) -
how to calculate the average annual profit, also taking into account that all profits are reinvested?
Thank you!

The square root of 6, then subtract 1 and multiply by 100. You get 19.62% per year.
 
Move down
 
Roman.:

The example from the tutorial is your case.

I read it but it does not work with my algorithm and i still have orders on every tick.

//+------------------------------------------------------------------+
//|                                                     trade v1.mq4 |
//|                                           |
//|                                                 frixer@yandex.ru |
//+------------------------------------------------------------------+

//--- input parameters
//extern int       Время;
//extern int       Input;
//extern int       SL;
//extern int       TP;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
   int bars = 9; // количество баров
   int gmt = 16; // время входа
   double input = 0.0010; // вход на рынок
   double sl = 100; // уровень SL от высоты коробки в %
   double tp = 100;
   int lot=1;
   int topOrder,bottomOrder;
   if (Hour()==gmt) // проверяем свечу
      {
         double Shift_high = iHighest(NULL,PERIOD_H1,MODE_HIGH,bars,0); //поиск бара с максимальной ценой из bars начиная с 0-го бара
         double Shift_low  = iLowest (NULL,PERIOD_H1,MODE_LOW ,bars,0); //поиск бара с минимальной  ценой из bars начиная с 0-го бара
         double Price_high = iHigh   (NULL,PERIOD_H1,Shift_high); // присвоение переменной максимального значение цены
         double Price_low  = iLow    (NULL,PERIOD_H1,Shift_low);  // присвоение переменной минимального значение цены
         double Hinput = Price_high + input; // вверхняя граница входа
         double Linput = Price_low - input;  // нижняя граница входа
         double height_box = Price_high - Price_low; // высота коробки bars
         double volumeSL = height_box / 100 * sl; // уровень SL зависит от %
        
         
               topOrder=OrderSend(Symbol(),OP_BUYSTOP,lot,Hinput,3,Price_high-(height_box/100*sl),Price_high+(height_box/100*tp),"BUY",16384,0,Green);
                     if (topOrder<0)
                        {
                           Print("Верхний ордер ошибка #", GetLastError());
                           return(0);
                        }
      }
//----
   return(0);  
//----
   return(0);
  }
//+------------------------------------------------------------------+

I have tried it this way (my friend has advised me) but it does not work.

         int Orerov=0;
         int Orderov_all = OrdersTotal();                                              // всего ордеров в терминале
            for (int n = 0;n<Orderov_all;n++)                                             // начало цикла перебора ордеров
            {
            if(OrderSelect(n,SELECT_BY_POS)==TRUE)                                  // выбран первый в списке ордер
            if(Comm == OrderComment())                                                // условие совпадения комментария
               {
                Tip= OrderType();                                                    // тип      
                Cena=NormalizeDouble(OrderOpenPrice(),4);                           // цена      
                Ticket= OrderTicket();                                               // тикет     
                Stop=NormalizeDouble(OrderStopLoss(),4);                            // стоп-лосс
                LOT=NormalizeDouble(OrderLots(),1);                                 // размер лота
                Orderov=1;                                                          //
               }
             }
 
frixer:
Hello everyone, Happy New Year. I can not make an order be placed only once, if the condition is fulfilled after which the order is placed, I need it then, if there is an order for the second time it will not be placed. If you can give an example.

if (OrdersTotal() > 0) {
   return(0);
}
// Если установлен хоть один ордер, то никакой код после этого комментария уже не выполнится
 
Reshetov:
The root of the tenth power of 6, then subtract 1 and multiply by 100. We get 19.62% per year.

Thank you!

 
Reshetov:

Thank you...
 

Anyway, here's the question,

I have a multi-period indicator.

In order to optimize the calculations, I use the following loop



// TimeFrames[i] массив с периодами

for (i=0; i<NumTimeFrames; i++)

{
if (total_bars[i] != iBars(instrument, TimeFrames[i]) )
{

// тут вычисления индиктора

total_bars[i] = iBars(instrument, TimeFrames[i]);
}

}



The main problem is that iBars does not load prices of periods other than the current one...

all MQL tricks like IndicatorCounted and RefreshRates

only work for the current period, i.e. iBars takes from the history and the history is only loaded by changing the period on the chart. What to do? Does MQL have some tool for loading bars of other periods (different from the current one) in the background?


p.s. hope I'm not rambling ((
 
palladin:

The main problem is that iBars does not load prices for a period other than the current...

Your main problem is that iBars loads not prices, but the number of known bars for a given period. And, as I have just checked, it does it quite correctly both in the tester and on the chart.
Reason: