Possible bug: ObjectFind freezes MT5 - page 2

 
Martin Bittencourt:

\o/ You have the part of the code where the drawing starting point is done. Have you seen any bug on it? Because I've already done dozens of indicators and always used that same structure and it always worked as I wanted :| I can't see any bugs on it. With that in mind, I thank you for your tip, but it is already 'used' so to speak: I already used the minimalistic amount of candlesticks for my indicator to function.

You'll be surprise if you trace it with a simple 
print (rates_total, ' : ', prev_calculated)
and notice how many time you ObjectFind() will be looped/executed, especially, when you move your chart so that it reloads/repaints older candles.

PS: a global counter that increments on each call of ObjectFind() might help to trace it too.

Good luck.
 
Soewono Effendi:
You'll be surprise if you trace it with a simple 
print (rates_total, ' : ', prev_calculated)
and notice how many time you ObjectFind() will be looped/executed, especially, when you move your chart so that it reloads/repaints older candles.

PS: a global counter that increments on each call of ObjectFind() might help to trace it too.

Good luck.

But my code doesn't consider older candles, it won't give a damn for repainted older candles. Haven't you read my code? And recent calls of OnCalculate due to new ticks been formed are necessary since inbetween a new object may have been drawn, but that doesn't even seems to be what you are talking about.

Read the code I posted in the OP and you will find out I don't consider any more candles and ticks updates then what I need.

int startPos;
   
   const bool isCalculatingForNow = prev_calculated == rates_total;
   
   if (prev_calculated == 0)
   {
      startPos = MathMax(rates_total - 2,1); //Don't need to calculate the entire history
                
      PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,startPos);
      PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,startPos);
   }
   else if (isCalculatingForNow)
   {
      //Print("Is now");
      startPos = prev_calculated - 1;
   }   
   else
   {
      //Print("New candle produced");
      startPos = prev_calculated;
   }
      
   for (int aaa = startPos; aaa < rates_total && !IsStopped(); ++aaa)
 
Martin Bittencourt:

No, the freeze don't require any drawing to happen. Just run it and wait, that's how is happening here with me.

That doesn't make sense. If I run the posted code on a chart without objects, the ObjectFind() is not even called. You must missed something, as for sure I can't reproduce your issue.

      if (totObj == 0)
         continue;
 
Martin Bittencourt:

But my code doesn't consider older candles, it won't give a damn for repainted older candles. Haven't you read my code? And recent calls of OnCalculate due to new ticks been formed are necessary since inbetween a new object may have been drawn, but that doesn't even seems to be what you are talking about.

Read the code I posted in the OP and you will find out I don't consider any more candles and ticks updates then what I need.

Don't lost your time with this guy, it's his usual troll behaviour. He obviously didn't even checked or understood your code.
 
Read the code I posted in the OP and you will find out I don't consider any more candles and ticks updates then what I need.

Good luck and enjoy your bug hunting ;)

 
Alain Verleyen:

That doesn't make sense. If I run the posted code on a chart without objects, the ObjectFind() is not even called. You must missed something, as for sure I can't reproduce your issue.

Heheh here I must ask you to forgive me: I was doing these tests in a graph where one of my EAs was charged and it automatically plots some objects on the graph, they just don't appear in the common Object List dialog box (moreover there are some previous buy and sell operations in that graph from previous tests):

Object List

As you may see in the image above, the object list dialog is empty, but the ObjectFind() returned a lot of objects which came from previous operations test in this demo account plus some objects drawn by the EA that is loaded.


 
Alain Verleyen:
Don't lost your time with this guy, it's his usual troll behaviour. He obviously didn't even checked or understood your code.

Well I can totaly agree with that! ^.^

 

Well, it seems I managed to avoid the bug which was leading to the freeze: in the previous posted code, I was doing a whole object reading after each new tick which was, at the end, quite a lot of unacessary processing. So I divided the object processing into 5 groups and added a counter from 0 to 100 so now only once after each 20 ticks a processing is done and for only one group of objects.

//To avoid over-processing, calculates only each 10 ticks
   static int tickSkipCounter = -1;
   bool readC = false;
   bool readST = false;
   bool readRL = false;
   bool readHL = false;
   bool readA = false;
   
   ++tickSkipCounter;
   
   if (tickSkipCounter > 100)
      tickSkipCounter = 0;
   
   if (tickSkipCounter == 0)
      readC = true;
   else if (tickSkipCounter == 20)
      readST = true;
   else if (tickSkipCounter == 40)
      readRL = true;
   else if (tickSkipCounter == 60)
      readHL = true;
   else if (tickSkipCounter == 80)
      readA = true;
   else
      return(rates_total);

After that, no more freezing happened. This seems to suggest there is something to be fixed here, but nothing that can't be circumvented.

Reason: