Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1009

 
Aleksey Vyazmikin:

It probably depends on the tick modelling method...

Possibly. But this broker has 100% quote quality on all pairs, exceptEUR/USD(the most popular pair). If you optimize your EA on such a quality, you are guaranteed to fail).

 
Aleksandr Prishenko:

Maybe. But this broker has 100% quote quality on all pairs, exceptEUR/USD(the most popular pair). If you optimize your Expert Advisor using such a quality, it is guaranteed to fail).

You can adjust it to any conditions, the main thing is to use more variables/indicators. No one guarantees a repetition of the sequence of the same prices as on the history - it's just the probability on which the Expert Advisor has to survive.

 
One trade per bar or time. How to implement?
 
Vladimir Baskakov:
One trade per bar ***

In OnTradeTransaction we catch the transaction TRADE_TRANSACTION_DEAL_ADD and determine the type of transaction. If the deal is DEAL_TYPE_BUY or DEAL_TYPE_SELL, we memorize the current bar open time. In the signal generation block, we compare this time with the current bar opening time.

 
Vladimir Karputov:

In OnTradeTransaction we catch the transaction TRADE_TRANSACTION_DEAL_ADD and determine the type of transaction. If the deal is DEAL_TYPE_BUY or DEAL_TYPE_SELL, we memorize the current bar open time. In the signal generation block, we compare this time with the opening time of the current bar.

if (day!=TimeDay(TimeCurrent()))
      {
      
      // проверяем условие открытия
          {
          //если условие подходит, открываем сделку — и изменяем флаг day
          day=TimeDay(TimeCurrent());
          }
 
Vladimir Baskakov:

"TimeDay" - there is no such function.

 
Vladimir Karputov:

"TimeDay" - there is no such function.

Pardon my mistake, is it?
MqlDateTime currTime=TimeToStruct(TimeCurrent());
   if (day!=currTime.day)
      {
      day=currTime.day);
      
      // открываем сделку
      
 

Vladimir Baskakov:
Пардон ошибся, а так?

MqlDateTime currTime=TimeToStruct(TimeCurrent());
   if (day!=currTime.day)
      {
      day=currTime.day);
      
      // открываем сделку
      

This will work as "one deal a day".

 
Vladimir Karputov:

This will work as a "one deal a day".

Oh, that's it!

 
Hello.
Question: How to calculate the actual number of timeframe bars. When requesting Bars, iBars gives 01.01.1970 (if converted to date). Realistically, the actual bar on the screen is from 21.09.2019.
The entire history on the chart is 25 weeks... (PERIOD_W1).

What exactly does the query code line look like, what is actually on the screen? How to reconcile? Thank you.
Reason: