Questions from Beginners MQL5 MT5 MetaTrader 5 - page 988

 
Aleksey Vyazmikin:

I've already done a check for myself, but this check is for bypassing the error of this function, the help doesn't say at all about the need for a check, which means it should be built in.

And then, you are talking about indicator check, while I am using Bars to calculate the correct bar start time, as iBarShift is in my mind and only suitable for forex, where there are no frequent failures with history due to clearing and trading sessions not for the whole day.

And where is your validation? And why introduce some variable if ( when you bump the history or change the history) you just need to recalculate the indicator completely. This is usually done from "0" to "rates_total-1".

 
Vladimir Karputov:

And where is your check? And why would you enter a variable if you just need to recalculate the indicator completely (when you swap the history or change the history). As a rule this is done from "0" to "rates_total-1".

My problem has nothing to do with indicator or history paging. Here is a piece of code

      datetime         StartDt=iTime(Symbol(),PERIOD_CURRENT,Bars(Symbol(),PERIOD_CURRENT,iTime(Symbol(),TF_iDeltaP,0),iTime(Symbol(),PERIOD_CURRENT,0))-1);
      datetime         StopDt=iTime(Symbol(),PERIOD_CURRENT,1); //Берем прошлый бар, что б не было расхождений между реалом и тестером при задержки на реальных данных

      int BarsGo=Bars(Symbol(),PERIOD_CURRENT,StartDt,StopDt);
      if(StartDt>StopDt)BarsGo=0;
      if(StartDt==StopDt)BarsGo=1;
      if (BarsGo>0)
        {
                //Полный расчет с вычислениями - копирование массивов цен и прочие тяжелые функции
        }
      else
        {
                //Упрощенный расчет с присвоением эмпирических значений переменным
        }
The problem occurs when opening a new bar in general, when the start date of the bar is greater than the shift of 1 bar from the zero bar on the current TF.
 
Aleksey Vyazmikin:

This is not a defence, but an obstacle to detecting an error in the code!

Moreover, it is not at all logical to return number 2 if the dates coincide - what is the reasoning here?

The start time of a bar on FORTS may not coincide and this leads to errors in calculations, for example, a bar opens not at 14:00 but at 14:05 - I suffered with it too.

Maybe the programmer started working in the way the documentation says but later decided it would be better to return 'between' rather than 'from' and 'to' the indicated dates but the documentation hasn't corrected this description. Actually, it is not very necessary.

I don't even have a demo on FORTS. I can't check it.

 
Alexey Viktorov:

Maybe they originally did it as described in the documentation, but then decided that it would be better to return 'between' dates instead of 'from' and 'to' dates, but the description in the documentation was not corrected. But they didn't fix the description.

I don't even have a demo on FORTS. I can't check it out.

How can it be unnecessary, I can't guess, and if it's an error, which will be corrected later, the code won't work again, and I will be searching for an error for a long time... But Artem has decided that it's not an error and hasn't written anything in essence....

It seems that on the demo account from MQ people connect to FORTS...

 
Aleksey Vyazmikin:

How can it not be, I can't guess, and if it's an error, which will be corrected later, then the code won't work again, and I'll be looking for an error for a critical time... But Artem has decided that it's not an error and hasn't written anything in essence....

It seems like people are connecting to FORTS on a demo account from MQ...

Well if you're careful enough now and can't get the start time and end time wrong, then there's nothing to fear. Let them rule.

 
Aleksey Vyazmikin:

I don't have a problem with the indicator or history paging. Here is a piece of code

The problem occurs when opening a new bar in general, when the start date of the bar is more than 1 bar offset from the zero bar on the current TF.
datetime StartDt=iTime(Symbol(),PERIOD_CURRENT,Bars(Symbol(),PERIOD_CURRENT,iTime(Symbol(),TF_iDeltaP,0),iTime(Symbol(),PERIOD_CURRENT,0))-1);
datetime StopDt=iTime(Symbol(),PERIOD_CURRENT,1); //Берем прошлый бар, что б не было расхождений между реалом и тестером при задержки на реальных данных

There is no check on what iTime(), Bars() return

You should have. You really should have. Look in the help - what do iTime() and Bars() return ? And what does it say in the notes?

 
Alexey Viktorov:

Well, if you are careful enough now that you can't get the start time and the end time wrong, there's nothing to be afraid of. Let them rule.

I just don't like to sit and passively wait, and I was forbidden to ask the developers specifically about it - the question was originally for them.

 
Artyom Trishkin:

There are no checks on what iTime(), Bars() return

Well, you should. You really should. Look in help - what do iTime() and Bars() return? And what does it say in the notes?

Is it enough to do these checks once in code, or should they be done after/before each function call?

What kind of checks are proposed to do, for current bar/history? What is the best way to do them?

 

How do I find the reason for this message?

2019.01.24 21:32:01.570 i-Regr4_05i (Si-3.19,M1)        indicator is too slow, 3011 ms. rewrite the indicator, please
 
Aleksey Vyazmikin:

Is it enough to do these checks once in the code, or should they be done after/before each function call?

What kind of checks do you propose to do, for the current bar/history? What is the best way to do them?

You don't know how to check the return value for zero? And don't know how to exit OnCalculate() with a return of zero? Have you ever tried searching for information on a website?

  1. Getting the required value from the function
  2. Check it for zero
    1. If it is zero, then return 0;
    2. If it is not zero, then to step 3
  3. Working with this value
I never thought I'd be teaching the basics of logic to a man with a rating exceeding 13 thousand...
Reason: