Questions from Beginners MQL5 MT5 MetaTrader 5 - page 985

 

do { ... buffer filling code

}

while(these two values do not match)

in short, get the values in the loop until they match, only then execute the following code
 
Maxim Dmitrievsky:

do { ... buffer filling code

}

while(these two values are not the same)

In short, get the values in the loop, until they are the same, only then execute the following code

The point is that until one indicator works, the data (flow) is not passed to the other one, i.e., the loop in the indicator withoutOnCalculate of this indicator will not help. And as soon as OnCalculate is finished, the data is passed to the Expert Advisor, and it is wrong.

Or maybe I don't understand your idea.
 
Aleksey Vyazmikin:

So, the point is that until one indicator works, the data (flow) is not transferred to another one, i.e. the loop in the indicator without termination of OnCalculate of this indicator will not help.

you receive values from buffers of other indicators one by one, if their number is not the same, you get them again until it is the same, forget about streams. But in general, no one does it this way - it ' s very slow

 
Aleksey Vyazmikin:

So, the point is that until one indicator works, the data (flow) is not passed to another one, i.e. the loop in the indicator without OnCalculate of this indicator will not help. But as soon as OnCalculate is finished, the data is passed to the Expert Advisor, and it is erroneous.

Or I don't understand your idea.

you need the condition to be fulfilled, then only the buffers will be filled, as I understand it (the number of bars in the buffers of other indicators will be the same)

forcibly fulfill all conditions before filling the buffers of the current indicator

or give it back to the wrong programmer - why should we solve his problems in the wrong field?

 
Maxim Dmitrievsky:

you get the values from the buffers of other indicators one by one, if their number is not the same, you get them again until it is the same, forget about streams. but in general, no one does it, it's a perversion of indicators from indicators, very slow

Maxim Dmitrievsky:

you need the condition to be fulfilled, then only the buffers will be filled, as I understand (the number of bars in the buffers of other indicators will be the same)

Forced execution of all conditions before the buffers of the current indicator are filled

or give it back to the programmer with a bad hand, why should we solve his problems in the wrong place?

If the calculation is not ready from other indicators, the values will be zero, so there is no sense to force-fill here, you can fill the past data, but with the same effect, you can request data not for the current bar from the indicator, but for the past one, and then the code should not be changed at all.

Why are we discussing here? Because the situation in the tester and in the real account is different, the simulation of Sleep works very strange, and recalculation of indicator for 15 seconds slip occurs only once, while it must occur at every tick, or at request, and it occurs not in 15 seconds, but in 13, according to the log.

In addition, the synchronization problem is relevant, and it would be good to add for such situations the possibility to inform the indicator about the need to pass the data flow to other indicators, without which it is impossible to perform further calculations - this would be a solution - the command to pass the flow to another indicator without completion of calculation.

Respectively, the Expert Advisor should wait for the data from the indicator and skip ticks until the complete calculation is made; now, when trying to use "while" statement, the result of the calculation hangs/goes stalled (i.e. nothing happens, the tester just stands there), and that is also not correct.

I have, of course, informed the developer, but I haven't heard from him in over a month - the cost of freelancing.

 

the situation in the tester and in the real account is different, the Sleep simulation works very strange, and recalculation of indicator for 15 seconds slip occurs only once, while it should occur on every tick, or on request, and it occurs not in 15 seconds but in 13, according to the log.

In addition, the synchronization problem is relevant, and it would be good to add for such situations the possibility to inform the indicator about the need to pass the data flow to other indicators, without which it is impossible to perform further calculations - this would be a solution - the command to pass the flow to another indicator without completion of calculation.

Respectively, the Expert Advisor should wait for data from the indicator and skip ticks until the end of the full calculation, but now, when trying to use"while" statement to wait for the correct results of the calculation, it freezes/goes stalled (i.e. nothing happens, the tester just stands there), and that's also not correct.

 

DearArtyom Trishkin!

I very much hope that since you have determined that the above questions are for beginners, you already know the answer and can help me!

I am waiting for an answer from a professional.

 
Aleksey Vyazmikin:

DearArtyom Trishkin!

I very much hope that since you have determined that the above questions are for beginners, you already know the answer and can help me!

I am waiting for an answer from a professional.

The only advice I can give is this: the indicator should exit OnCalculate() if it has not received the required number of bars for the calculation: if(rates_total<number of_bars required) return 0;

The Expert Advisor should check the data received from the indicator, and if they are not equal to the empty indicator value, only then perform calculations with the received data.

  1. In the indicator, first, the buffers are initialized with an empty value (what is it - can be set in the indicator)
  2. In the indicator (buffers are already filled with an empty value), check the number of available bars (I described above)
  3. If the check of bar availability is passed, the calculation cycle of indicator is executed with filling the buffers with the necessary values.
    ... ... ...
  4. In the Expert Advisor, check how many bars are calculated by the indicator (there is a standard function BarsCalculated())
  5. Get data from the indicator
  6. Depending on what we get - it depends on the logic of your TS
    1. If the indicator is a line, then its empty value indicates that it has not yet been calculated - we do not take it for calculations
    2. If the indicator - arrows, then there is another logic (because the empty value is also its working data), for example, if this is a fractal, then we check the bar number 3, and from the values obtained push back.
  7. Well, include your own logic and do not blame everything on the terminal Bugs.
  8. First of all I check Bugs with myself.
  9. And you?
 
Artyom Trishkin:

I can only advise: the indicator should exit OnCalculate() if it didn't get the right number of bars for the calculation: if(rates_total<number_of_bars required) return 0;

Thanks for the tip, no problem with the exit, but it does not solve the situation, I have done as a failed calculation for now

if(barsch!=channel.BarsCalculated())return(counted_bars=rates_total-1);

And somehow it fills the buffers and gets data from other indicators and data is not passed to the EA until a condition is met. I have not checked data correctness yet, but it looks correct. Or maybe I'm wrong and something is definitely wrong?

Artyom Trishkin:

The Expert Advisor should check the data received from the indicator and if it is not equal to the empty indicator value, only then perform calculations with the received data.

The Expert Advisor performs calculations one at the arrival of a new bar, and respectively, the attempt to wait for the correct value from the indicator leads to a halt of the tester.

Artyom Trishkin:
  1. In the indicator buffers are first initialized with an empty value (what is it - can be set in the indicator)
  2. In the indicator (buffers are already filled with an empty value) check the number of available bars (described above)
  3. If the check of bar availability is passed, the cycle of indicator calculation is performed by filling the buffers with the necessary values
    ... ... ...
  4. In the Expert Advisor, check how many bars are calculated by the indicator (there is a standard function BarsCalculated())
  5. Get data from the indicator
  6. Depending on what we get - it depends on the logic of your TS
    1. If the indicator is a line, then its empty value indicates that it has not yet been calculated - we do not take it for calculations
    2. If the indicator - arrows, then there is another logic (because the empty value is also its working data), for example, if this is a fractal, then we check the bar number 3, and from the values obtained push back.
  7. Well, include your own logic and do not blame everything on the terminal Bugs.
  8. First of all I check for bugs with myself.
  9. And you?

1. it is true.

2. And so it happens. This calculation will be correct on the next tick, but I want to receive correct calculation on the first tick, because Expert Advisor does not wait in the loop for other ticks or the expectation is not commensurable with my patience, i.e. it's not realistic - there is an error.

3.

4. Of course.

5. Yes, we do, but the indicator needs to receive data from other indicators and that is the problem!

6. 1-2. it is not correct to put deliberately false data in the indicator buffer, it will only complicate the detection of algorithm error in the code of the Expert Advisor.

7. I'm describing everything logically, but I didn't write the indicator, so it's hard for me to understand what is the reason, I described the reasonable manifestation of the indicator, namely the inability to perform a calculation without receiving buffered values from other indicators, due to the monopoly of the data stream (indicators are calculated sequentially).

8. I have already noted here and before that I'm not the author, I spent a lot of time - almost a day - to identify the reasons.

9. And I'm looking for a solution to the problem, in addition, if someone has faced with this, can quickly help me. I repeat, in that thread I started to write because of Sleep, and then came out the other features of the tester, which I also believe the error.

Thanks for the reply.

 
Aleksey Vyazmikin:

Thanks for the tip, no problem with the output, but it does not solve the situation, I have made as a failed calculation so far

And somehow it fills the buffers and gets data from other indicators, the data is not passed to the EA until the condition is met. I have not checked data correctness yet, but it looks correct. Or maybe I'm wrong and something is definitely wrong?

The Expert Advisor performs the calculation alone when a new bar arrives and therefore, when trying to wait for the correct value from the indicator, it leads to a halt of the tester.

1. it does.

And so it is. 2. This calculation will be correct on the next tick, but I need to get a correct calculation on the first tick, because my Expert Advisor doesn't wait in the loop for other ticks or the expectation is not commensurable with my patience, i.e. it's not realistic - there is an error.

3.

4. Of course.

5. Yes, we do, but the indicator needs to receive data from other indicators and that is the problem!

6. 1-2. it is not correct to put deliberately false data in the indicator buffer, it will only complicate the detection of algorithm error in the code of the Expert Advisor.

7. I'm describing everything logically, but I didn't write the indicator, so it's hard for me to understand what is the reason, I described the reasonable manifestation of the indicator, namely the inability to perform a calculation without receiving buffered values from other indicators, due to the monopoly of the data stream (indicators are calculated sequentially).

8. I have already noted here and before that I'm not the author, I spent a lot of time - almost a day - to identify the reasons.

9. And I'm looking for a solution to the problem, in addition, if someone has faced with this, can quickly help me. I repeat, in that thread I started to write because of Sleep, and then came out the other features of the tester, which I also believe the error.

Thanks for the reply.

In OnInit() call the time series of the symbol: iTime(Symbol,Timeframe,1);

At the very beginning, in OnTick(), ask for the required bar of the required timeseries using the corresponding iFunc(), or if( iTime(Symbol,Timeframe,10)==0) return;

In this case, the Expert Advisor will not detect a new bar and will wait for the next tick.

In OnInit() we have requested the time series data, thereby activating data paging.

In OnTick() we check if the minimally required history is available to the EA and if it is not yet available, we wait for the next tick.

And until all of the data required by the Expert Advisor is received, it will wait for the next tick.

As soon as all of the necessary data is pumped and obtained, the Expert Advisor will start to work with the new bar and the required history.

To keep the serial data up to date, it is imperative that it be accessed at least once every two minutes. Make a second timer for about a minute and a half (90 seconds) and in it simply refer to any timeseries of the desired symbol, for example iTime(Symbol,Timeframe,1); Without checking the received data - just "wiggle" the history. Then all data on the symbol will always be up to date.

Reason: