Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1446

 
Evgeny Dyuka #:
I will make a minimal test Expert Advisor that will update the record in the database every second. Run it on 10 pairs and everything will be clear. I'll post it here.

Interesting. I'll be waiting...

 
Alexey Viktorov #:

Interesting. I'll be waiting...

Here's an expert. It creates a base (if it doesn't already exist) and writes the current time into it once a second.
There is no Print() in the code.
I ran it on 10 pairs and it got errors:

CS      2       11:44:36.561    Test_DB (EURUSD,M10)    database error, database is locked
CS      2       11:55:27.018    Test_DB (BTCUSD,M10)    database error, database is locked
CS      2       11:55:28.026    Test_DB (BTCUSD,M10)    database error, database is locked
CS      2       11:55:49.177    Test_DB (TRXUSD,M10)    database error, database is locked
CS      2       11:55:51.183    Test_DB (EURUSD,M10)    database error, database is locked
CS      2       11:55:53.182    Test_DB (TRXUSD,M10)    database error, database is locked

To get an error you have to close and restart MT5 then all EAs start working synchronously.

It would be good:
1. To understand how to get rid of this error.
2. To invent a template mechanism that would queue in case the base is unavailable.

I solved point 2 by adding Sleep() with random time, but it looks like a crutch.

UPDATE: Ireuploaded the file, the first one had an error.

Files:
Test_DB_1.mq5  3 kb
 
Evgeny Dyuka #:

Here is an expert. It creates a base (if it doesn't already exist) and writes the current time into it once a second.
There is no Print() in the code.
I ran it on 10 pairs, errors occurred:

In order to get an error you should close and restart MT5 then all the Expert Advisors start working synchronously.

It would be good:
1. To understand how to get rid of this error.
2. To invent a template mechanism that would queue in case of unavailability of the base.

I solved point 2 by adding Sleep() with random time, but it looks like a crutch.

UPDATE: Ireuploaded the file, the first one had an error.

Alas, my knowledge is not enough. Only enough to realise that an error is being printed

      DatabaseExecute(db, sql);

There is no possibility to check availability before creating a query.

The database opens, but it is not possible to create a query.

 
No orders open on the server, no stops and takes, algo modes are enabled and the setup command passes, but the logs are silent CTrade class. In the tester works on real trading silence. What to check?
 
mwwm CTrade class. In the tester works on real trading silence. What to check?

terminal log

 
Vladimir Deryagin #:

terminal log

I guessed I switched on the logs, can't calculate the lot. I don't understand why it doesn't want to calculate on real?

void OpenBuy(const int index,double sl,double tp)
  {
   sl=m_symbol.NormalizePrice(sl);
   tp=m_symbol.NormalizePrice(tp);
   double long_lot=0.0;
   if(InpLotOrRisk==risk)
     {
      long_lot=m_money.CheckOpenLong(m_symbol.Ask(),sl);
      if(InpPrintLog)
         Print(__FILE__," ",__FUNCTION__,", OK: ","sl=",DoubleToString(sl,m_symbol.Digits()),
               ", CheckOpenLong: ",DoubleToString(long_lot,2),
               ", Balance: ",    DoubleToString(m_account.Balance(),2),
               ", Equity: ",     DoubleToString(m_account.Equity(),2),
               ", FreeMargin: ", DoubleToString(m_account.FreeMargin(),2));
      if(long_lot==0.0)
        {
         ArrayRemove(SPosition,index,1);
         if(InpPrintLog)
            Print(__FILE__," ",__FUNCTION__,", ERROR: ","CMoneyFixedMargin.CheckOpenLong returned the value of 0.0");
         return;
        }
     }
 
mwwm #:

I guessed I switched on the logs, it can't calculate the lot. I don't understand why it doesn't want to calculate on real?

There are no logs, so there can be many times more guesses.

As an option, when trading crosses, if in the market overview is not selected pair with the currency of the deposit, will not trade.

For example, we trade EURJPY, deposit currency USD, in the market overview must be present EURUSD and USDJPY.

 
Aleksandr Slavskii #:

There are no logs, so there could be many times more guesses.

As an option, when trading crosses, if the pair with the deposit currency is not selected in the market overview, will not trade.

For example, we trade EURJPY, deposit currency USD, in the market overview must be present EURUSD and USDJPY.

Account in USD pro cent, trading XAUUSD

 

Hi all. I can't draw one arrow on the first bar using buffers in MQL5.

In MQL4, I do the following:

Declare a global variable double XX[];

write in init:

SetIndexBuffer(0,XX);

SetIndexStyle(0,DRAW_ARROW);

SetIndexArrow(0,108);

In Oncalculate I write:

XX[1]=High[1]; I get a drawn arrow over candlestick 1. and that's it

I do the same in MQL5:

Declare a global variable double XX[];

write in init:

SetIndexBuffer(0,XX,INDICATOR_DATA);

PlotIndexSetInteger(0,PLOT_ARROW,108);

In Oncalculate I write:

XX[1]=high[1]; - it does not draw

XX[1]=iHigh(Symbol(),PERIOD_CURRENT,1); - also does not draw.

Of course, even in the header it is specified:

#property indicator_buffers 1

#property indicator_plots 1

#property indicator_type1 DRAW_ARROW

#property indicator_color1 clrGreen

#property indicator_width1 1

What am I doing wrong, please tell me !!!!

 
Vyacheslav Pronenko #:

XX[1]=high[1]; - not drawing

What am I doing wrong, please tell me !!!!

How about this:

XX[rates_total-1]=high[rates_total-1];

or like this:

ArraySetAsSeries(XX,true);
ArraySetAsSeries(high,true);
XX[1]=high[1];
Reason: