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

 
Tretyakov Rostyslav #:
This is also possible

But first you have to select the last order via if(OrderSelect()-right?

 
законопослушный гражданин #:

But first you have to select the last order via if(OrderSelect()-right?

yes
 

Can you tell me if there are any ready-made solutions for FIFO closing? I found only for MT5.

For MT4 Open Time pending is equal to its activation time or setting time?

 
leonerd #:

Can you tell me if there are any ready-made solutions for FIFO closing? I found only for MT5.

For MT4 Open Time pending is equal to its activation or installation time?

It is not pending after activation.

What is FIFO?

 
Tretyakov Rostyslav #:

Once activated, it is no longer pending.

What is FIFO?

FIFO = Fist Input Fist Output - First In First Out Exit in the same order as entering = Queue

FILO = Fist Input Last Output - First In Last Out Exit in reverse order = Stack

 
a007 #:

FIFO = Fist Input Fist Output - First In First Out Exit in the same order as entering = Queue

FILO = Fist Input Last Output - First In Last Out Exit in reverse order = Stack

Haven't even heard of it...
 
Tretyakov Rostyslav #:
// Параметры советника
input string  sParametersEA = "";     // Параметры советника
input double  Lot           = 0.01;   // Количество лотов
input double  Lotcontrol    = 0.08;   // -----  
input int     StopLoss      = 30;     // Стоп (SL)
input int     TakeProfit    = 30;     // Тейк (TP)
input int     HourPause     = 1;      // Пауза в часах
input int     Slippage      = 3;      // Проскальзование (в пунктах)
input int     Magic         = 1;      // Индентификатор советника
input double  K_Martin1     = 0.01;   // Множитель мартин 1
input double  K_Martin2     = 1.9;    // Множитель мартин 2
input double  K_Martin3     = 1.4;    // Множитель мартин 3
input int     OrdersClose   = 3;      // Ограничение лотности мартин1
input int     OrdersClose2  = 5;      // Ограничение лотности мартин2
input int     DigitsLot     = 2;      // Точность лотности
// Параметры индикатора
input string  sParametersMA = "";     // Параметры индикатора
input int     PeriodMA      = 14;     // Период мувинга
input int     MovingShift   = 1;      // Сдвиг мувинга
// Глобальные переменные
datetime Start=0,newbar;
double dMA;
double MaxMartinLot;
double MaxMartinLot2;
//+-----------------------------------------------------------------------------------------------+
int OnInit()
  {
Start          = TimeCurrent();
MaxMartinLot   = Lot*MathPow(1.4,OrdersClose);
MaxMartinLot2  = Lot*MathPow(K_Martin2,OrdersClose2);
int Y          = 15;
DrawLABEL("nextlot",1,5,Y,clrLime,""); 
Y += 20;
DrawLABEL("currentlot",1,5,Y,clrLime,"");
Y += 30;
return(INIT_SUCCEEDED);
  }
//+-----------------------------------------------------------------------------------------------+
void OnDeinit(const int reason)
  {

  }
//+-----------------------------------------------------------------------------------------------+
void OnTick()
  {
// Получим значение индикатора
   dMA = iMA(Symbol(), 0,PeriodMA, MovingShift, MODE_SMA, PRICE_CLOSE, 0); // MODE_SMA - простое усреднение , значение 0. PRICE_CLOSE- цена закрытия, значение 0.
// выключаем торговлю      
      if (OrderLots()>=Lotcontrol)
     {
      Start=TimeCurrent()+(HourPause*60*60);
     }
// Если нет открытых ордеров, то входим в условие
      if((CountOrders()==0)&& Start<=TimeCurrent())
     {
// Если появился сигнал на покупку, то откроем ордер на покупку
      if(bSignalBuy() == true)
         vOrderOpenBuy();

// Если появился сигнал на продажу, то откроем ордер на продажу
      if(bSignalSell() == true)
         vOrderOpenSell();
     }
// Пишем какой лот текущий и какой следующий
      DrawLABEL("nextlot",1,5,0,Color1(),StringConcatenate("CURRENT LOT: ",DoubleToStr(LOT(),2)));
      DrawLABEL("currentlot",1,5,0,Color2(),StringConcatenate("NEXT LOT: ",DoubleToStr(LOT(),2))); 
 
  }

seems to have been assembled, but it only works once in the tester

If I make one more test, it does not open any deal

When I do the first test, the interval is set, but if the lot is reset to the starting lot, it does not open any more trades.

where did i go wrong?

 
законопослушный гражданин #:

seems to have been assembled, but it only works once in the tester

If I make one more test, it does not open any deal

When I do the first test, the interval is set, but if the lot is reset to the starting lot, it does not open any more trades.

Where did I make a mistake?

Press f1 more often before clicking on functions and reading:

The order must be preselected using the OrderSelect() function.

This is to the OrderLots() function;

Sorry drunk.

Happy New Year!

 
законопослушный гражданин #:

seems to have been assembled, but it only works once in the tester

If I make one more test, it does not open any deal

When I do the first test, the interval is set, but if the lot is reset to the starting lot, it does not open any more trades.

where did i go wrong?

Presented by

Try this function:

//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 19.02.2008                                                     |
//|  Описание : Возвращает сумму лотов открытых позиций                        |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    sy - наименование инструмента   (""   - любой символ,                   |
//|                                     NULL - текущий символ)                 |
//|    op - операция                   (-1   - любая позиция)                  |
//|    mn - MagicNumber                (-1   - любой магик)                    |
//+----------------------------------------------------------------------------+
double GetAmountLotFromOpenPos(string sy="",int op=-1,int mn=-1)
  {
   double l=0;
   int    i,k=OrdersTotal();

   if(sy=="0") sy=Symbol();
   for(i=0; i<k; i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==sy || sy=="")
           {
            if(OrderType()==OP_BUY || OrderType()==OP_SELL)
              {
               if(op<0 || OrderType()==op)
                 {
                  if(mn<0 || OrderMagicNumber()==mn)
                    {
                     l+=OrderLots();
                    }
                 }
              }
           }
        }
     }
   return(l);
  }
 
Alekseu Fedotov #:

Gift

Try this feature:

Thank you!) Happy Holidays)

Reason: