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

 
makssub #:
Afternoon. I use this code to close all orders. But I noticed if there are a lot of them, not all are closed. What can I add to close all of them, even if not the first time. If possible, please give us an example.

https://www.mql5.com/ru/docs/common/sleep

   if(AccountInfoDouble(ACCOUNT_EQUITY)<=TargetLoss || AccountInfoDouble(ACCOUNT_EQUITY)>=TargetProfit)
     {
      AllClose();
      Sleep(1000);
      AllClose();
      ExpertRemove();
     }
//---
Документация по MQL5: Общие функции / Sleep
Документация по MQL5: Общие функции / Sleep
  • www.mql5.com
Sleep - Общие функции - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 

Last question )

Whoever ported their EA from mql platform to windows or linux. Let me explain, once a long time ago wrote scripts for the mu online, that the game itself pumped the hero, while you sleep. So the question is who transferred the adviser, outside the platform? Kind of trades a person, not a robot.

Sorry if i did not explain it correctly )

 
makssub #:

Last question )

Whoever ported their EA from mql platform to windows or linux. Let me explain, once a long time ago wrote scripts for the mu online, that the game itself pumped the hero, while you sleep. So the question is, maybe who transferred the adviser, outside the platform? Kind of trades a person, not a robot.

If that was not explained correctly, sorry )

on a Windows server (VDS or VPS) is placed MetaTrader, in it the Expert Advisor is running. That is all: The soldier sleeps, the service goes :-)

The trading platform is algorithmic and designed for robot's active participation, if not entirely by a robot.

Although, clickers (software that "clicks" in the buttons emulating a human) someone uses. And freelancers are periodically requested and there are those for sale on the Internet.

 

hello!

Can someone meet an EA or a piece of code (to include in the code of the owl), to change the SL TP for the next order?

Say the order was opened with 0.01 SL= 30 TP=100

the next order opened with 0.02SL= 30 TP=95

etc.

What function should I use to describe this?

This is how mySL TP is currently being assigned:

//+-----------------------------------------------------------------------------------------------+
//|                                                                    Функция модификации ордера |
//+-----------------------------------------------------------------------------------------------+
void vOrderModify(int iOTi)
  {
   int    iOTy = -1;    // Тип ордера
   double dOOP = 0;     // Цена открытия ордера
   double dOSL = 0;     // Стоп Лосс
   int    iMag = 0;     // Идентификатор советника
   double dSL  = 0;     // Уровень убытка
   double dTP  = 0;     // Уровень прибыли

// Выберем по тикету открытый ордер, получим некоторые значения
   if(OrderSelect(iOTi, SELECT_BY_TICKET, MODE_TRADES))
     {
      iOTy = OrderType();
      dOOP = OrderOpenPrice();
      dOSL = OrderStopLoss();
      iMag = OrderMagicNumber();
     }

// Если ордер открыл данный советник, то входим в условие
   if(OrderSymbol() == Symbol() && OrderMagicNumber() == iMag)
     {
// Если Стоп Лосс текущего ордера равен нулю, то модифицируем ордер
      if(dOSL == 0)
        {
         if(iOTy == OP_BUY)
           {
            dSL = NormalizeDouble(dOOP - StopLoss * Point, Digits);
            dTP = NormalizeDouble(dOOP + TakeProfit * Point, Digits);

            bool bOM = OrderModify(iOTi, dOOP, dSL, dTP, 0, clrNONE);
           }

         if(iOTy == OP_SELL)
           {
            dSL = NormalizeDouble(dOOP + StopLoss * Point, Digits);
            dTP = NormalizeDouble(dOOP - TakeProfit * Point, Digits);

            bool bOM = OrderModify(iOTi, dOOP, dSL, dTP, 0, clrNONE);
           }
        }
     }
  }
 

Gentlemen professionals, please advise, I can't think of anything (I've just started to learn programming).

Here is a part of an Expert Advisor, it doesn't matter which one. In OnInit() function there are two return operators.

I can't get the numbers -1 and 0 in brackets, where do they come from and where does the aborted program return?

//| Expert initialization function |

//+------------------------------------------------------------------+
int OnInit()
{
*******************************************
if(********* || *********)
{
Alert("***************",******(),"!!");
return(-1);
}


**** = *******;
*** = *********;
if(_******** || _********)
{
************;
************;
}
return(0);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
 
vladeimirami #:

I can't get the numbers -1 and 0 in brackets, where do they come from and where does the aborted program return to?

https://www.mql5.com/ru/docs/event_handlers/oninit

Read on. Zero is a success and the program will continue running. The other numbers are the end of the job.

Документация по MQL5: Обработка событий / OnInit
Документация по MQL5: Обработка событий / OnInit
  • www.mql5.com
OnInit - Обработка событий - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Aleksei Stepanenko #:

https://www.mql5.com/ru/docs/event_handlers/oninit

Read on. Zero is a success and the programme continues. The other numbers are the end of the job.

Shit. Got it. Didn't read theENUM_INIT_RETCODE enumeration carefully. Thanks. Anyway when initialization fails we exit with any number other than zero. At least it moved from the dead point. Thank you!
Документация по MQL5: Основы языка / Функции / Функции обработки событий
Документация по MQL5: Основы языка / Функции / Функции обработки событий
  • www.mql5.com
Функции обработки событий - Функции - Основы языка - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 

The task of checking symbol charts for missing bars

I cannot find a solution to this problem

I need to write the script according to the following principle: Print(date), Print(date), Print(date) if there is a bar gap

For example, the script should be 48 bars on M30 chart andPrint(date) if there is a gap of 47 bars.

How to write it? A cross-platform solution is desirable.

P.S. This should be done on all available history.

 

Vitaly, how do you estimate the bar pass? 48 bars a day? Sometimes work stops at 11 p.m., sometimes it starts at 2. If you look at the ruble, there is no trading there at night.

If it is strictly 24 hours 5 days a week, then we will try each bar in order with check of the sequence. But then there will be signals about missed bars, which should not exist.

 
Vitaly Muzichenko Print(date), Print(date) if there is a bar gap

For example, the script should be 48 bars on M30 chart andPrint(date) if there is a gap of 47 bars.

How to write it? A cross-platform solution is desirable.

P.S. This should be done on all available history.

There is a similar task - to make a timeframe with missed bars. That is, for example, to have exactly 1440 minutes in a day. It doesn't matter if some of them are empty.

nothing quick, neat and beautiful came up with :-( Only to form an array at the beginning of day, count elapsed minutes from 0:00 and fill in this way.

And the fact of missing minutes can be checked by comparing iBars(current_time,0:01 of current day) and (current_time_beginning of day)/PERIOD_SECONDS...

Reason: