FORTS: To help beginners - page 13

 
prostotrader:

So?

There's no such thing as an empty glass. But there's no trade there either, so I assume there may be zeros, I haven't checked it myself.

But I have to check for zero bid and ask on usual symbols, the same RTS and Si, because they occasionally fly through, although the glass is not empty.

 
fxsaber:

An empty glass at 18:51:09 today?

It's clearing.

 
JRandomTrader:

There's no such thing as an empty glass. But there's no trade there either, so I guess there may be zeros, I haven't checked it myself.

But I have to check for zero bid and ask on usual symbols, such as RTS and Si, because they occasionally fly through, although the glass is not empty.

Where do you get such "know-it-alls"?

Code (futures RTS-3.21, Openreach real):

//+------------------------------------------------------------------+
//|                                                   Ticks_zero.mq5 |
//|                                      Copyright 2021 prostotrader |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021 prostotrader"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_separate_window

#property indicator_plots   1
#property indicator_buffers 1

datetime start_time, end_time;
datetime time_array[];
int time_cnt;
MqlTick ticks[];

input datetime StTime = D'2019.03.15 19:05:00';    // Начало расчета фьючерса

enum IND_STAGE
{
  LOAD_TICKS = 0,
  FILL_DATA = 1
}ind_stage;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   end_time = datetime(SymbolInfoInteger(Symbol(), SYMBOL_EXPIRATION_TIME));
   start_time = StTime;
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator Load ticks function                             |
//+------------------------------------------------------------------+
bool LoadTicks(const datetime &a_times[])
{
  int result = CopyTime(Symbol(), PERIOD_M1, start_time, end_time, time_array);
  if(result > 0)
  {
    time_cnt = result;
    if(time_array[result - 1] == a_times[ArraySize(a_times) - 1])
    {
      result = CopyTicksRange(Symbol(), ticks, COPY_TICKS_INFO, ulong(start_time) * 1000, ulong(end_time) * 1000);
      if(result > 0)
      {
        if(ticks[result-1].time >= time_array[time_cnt - 1]) 
        {
          return(true);
        } else Print(__FUNCTION__, ": Не хватает тиков ", Symbol(), "!"); 
      } else Print(__FUNCTION__, ": Не получены тики по символу ", Symbol(), "!");
    } else Print(__FUNCTION__, ": Не хватает баров по символу ", Symbol(), "!");
  } else Print(__FUNCTION__, ": Не скопировано время баров по символу ", Symbol(), "!");
  return(false);
}  
//+------------------------------------------------------------------+
//| Custom indicator Fill Data function                              |
//+------------------------------------------------------------------+
void FillData()
{
  for(int i = 0; i<ArraySize(ticks);i++)
  {
    if((ticks[i].ask == 0) && (ticks[i].bid == 0) && (ticks[i].last == 0)) 
    {
     Print("Empty book with empty Last! Time: ", ticks[i].time);
    }
    else
    if((ticks[i].ask == 0) && (ticks[i].bid == 0) && (ticks[i].last != 0)) 
    {
      Print("Empty book. Last = ", ticks[i].last, " Time: ", ticks[i].time);
    } 
  }
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate (const int rates_total,  
                 const int prev_calculated, 
                 const datetime& time[], 
                 const double& open[], 
                 const double& high[], 
                 const double& low[], 
                 const double& close[], 
                 const long& tick_volume[], 
                 const long& volume[],
                 const int& spread[] )
{  
    switch(ind_stage)
    {
      case LOAD_TICKS:
        if(LoadTicks(time) == true)
        {
          ind_stage = FILL_DATA;
        } else return(0); 
      break;
      case FILL_DATA:
        FillData();
      break;
    }
   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+

Result:

..............................................................................
2021.03.01 21:58:20.820 Ticks_zero (RTS-3.21,M1)        Empty book with empty Last!
2021.03.01 21:58:20.820 Ticks_zero (RTS-3.21,M1)        Empty book with empty Last!
2021.03.01 21:58:20.820 Ticks_zero (RTS-3.21,M1)        Empty book with empty Last!
2021.03.01 21:58:20.820 Ticks_zero (RTS-3.21,M1)        Empty book. Last = 152910.0
2021.03.01 21:58:20.820 Ticks_zero (RTS-3.21,M1)        Empty book. Last = 152910.0
2021.03.01 21:58:20.820 Ticks_zero (RTS-3.21,M1)        Empty book with empty Last!
2021.03.01 21:58:20.820 Ticks_zero (RTS-3.21,M1)        Empty book with empty Last!
...................................................................................
 
JRandomTrader:

It's clearing.

Not only that, it is also pre-market, not trading time and so on, as I said earlier

2021.03.01 22:08:11.016 Ticks_zero (RTS-3.21,M1)        Empty book. Last = 125620.0 Time: 2020.03.02 19:00:02
2021.03.01 22:08:11.016 Ticks_zero (RTS-3.21,M1)        Empty book with empty Last! Time: 2020.03.03 00:04:31
2021.03.01 22:08:11.016 Ticks_zero (RTS-3.21,M1)        Empty book. Last = 130070.0 Time: 2020.03.03 18:44:58
2021.03.01 22:08:11.016 Ticks_zero (RTS-3.21,M1)        Empty book. Last = 130070.0 Time: 2020.03.03 19:00:01
The clearing trade went into the empty glass at trading time.
 
prostotrader:

Where do you come up with such "know-it-alls"?

Code (RTS-3.21 futures, Openreach real):

Result:

This is not an empty glass, but a tick with empty bid and/or ask, which, as I said, happens probably as a result of some kind of glitch.

What I would look at is an empty tick on the current RTS or Si.

 
JRandomTrader:

It's not an empty glass, but a tick with empty bid and/or ask, which, as I said, is probably the result of some kind of failure.

That's the empty tick on the current RTS or Si I'd look at.

Dear!

Do you read what is being written to you?

Open, real, RTS-3.21 futures.

2021.03.01 22:08:11.016 Ticks_zero (RTS-3.21,M1)        Empty book. Last = 130070.0 Time: 2020.03.03 19:00:01

You have a code, maybe there is no real account?

RTS-3.21 futures "born"
D'2019.03.15 19:05:00

And the glass is often empty at the beginning of "life".

 
prostotrader:

Dear Sir!

Do you read what is written to you?

Open, real, RTS-3.21 futures

There is a code, maybe there is no real account?

Didn't see MarketBookGet() in the code

I'm talking about the actual - i.e., the nearest futures. And it may have ticks with zero ask/bid, but that does not make the glass empty.
Документация по MQL5: Получение рыночной информации / MarketBookGet
Документация по MQL5: Получение рыночной информации / MarketBookGet
  • www.mql5.com
MarketBookGet - Получение рыночной информации - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
JRandomTrader:

Didn't see MarketBookGet() in the code

I see...

 
prostotrader:

And often the glass is empty at the beginning of 'life'.

It was about today.

 
fxsaber:

It was about today.

Look at the time, it could be clearing.

Schedule of sessions

7-00 - 14-00

Prom clearing

14-05 - 18-45

main clearing

19-00(19-05) - 23-50

Are you the empty glass at 18:51:09 today?

This is the Main Clearing.

Added

The trading day can start either at 19-00 or 19-05

If there is an expiry of a futures or option, then the day starts at 19-05

Reason: