ObjectCreate function ...question - page 2

 
Doerk:

1009 Objects exactly. Performance is really no criteria.

OK, good to know! Still, I find it very "messy". I prefer using "buffers".
 
WHRoeder:
If you use a buffer
If you use objects
You just set the buffer[] and are done.You must use unique names for the objects, set every property every time.
Read the buffer with one iCustom call. Perhaps in a loop to find the last set one.
Must loop through all objects, find names with a specific pattern, find the one with the last time.

Names - write a simple function that creates random names by increasing a number. Use classes, not native ObjectCreate().

Loop - Yes and No. If you use the MQL5 standard lib, yes, but these libs are simply programmed very bad. Create 20 objects, just move the mouse and watch the CPU - nothing more to say. There you are right, yes. But if you use Objects in classes and organize them proper in containers by a hierarchic model, you won´t have any performance problems at all. But of course, you have to develop your own control class library

MQL5 is absolutely awesome, but highly underestimated. 

 

The biggest brake, by the way, is ChartUpdate(). Some objects require to update the chart, especially bitmap objects. If you update the chart after every change, and you have 200-300 objects, you can go out and have lunch while it´s updating. This function must really be handled with care. 

Edit: ChartRedraw() not ChartUpdate(). Sorry. 

 
Thank you for this generous explanation I will try to make an example that addresses the same idea but with both method
 
Doerk:
The biggest brake, by the way, is ChartUpdate(). Some objects require to update the chart, especially bitmap objects. If you update the chart after every change, and you have 200-300 objects, you can go out and have lunch while it´s updating. This function must really be handled with care. 
So I was not wrong to suspect high CPU and RAM usage! It just gets all accumulated onto the "update" phase.
 

Sorry, but probably no again ;) It gets not accumulated, at least its usually not done that way by other CGIs I met in the past. Normally, when bitmaps are created in memory, the are created on a screen layer with an alpha channel either in CPU RAM (I suspect this option in MQL) or in GPU RAM (faster). When ChartRedraw() is used, this overlay gets flashed for one time to the main GPU buffer which is RGB and it makes no difference, if there are 1000 objects or one. To avoid a delay and lack of performance, you must not call ChartRedraw() multiple times, instead call it only one time. The growth of performance is drastically with this simple trick and thats why I assume that MQL does this this usual way too.

I implemented this in my graphical libraries by a nested "Freeze"-functionality. As long "Freeze" is activated, no chart updates get through. And due to hierarchic organization within regions plus time-based filters for visual outputs (the eye cannot capture more than 15-18 updates per second) there is a graphical performance that you won't except with MQL - but impossible to achieve with the standard control classes, yes. And this is also not an invention of me, its also just kind of normal for optimized graphical engines. I deal <>50% with such vector based bitmaps.

 
jeef_1985:
Thank you for this generous explanation I will try to make an example that addresses the same idea but with both method
What exactly are you planning to do? Maybe I have something ready which you may try to use.
 
Doerk:
What exactly are you planning to do? Maybe I have something ready which you may try to use.
IMA50 in separate_window like MACD but with ObjectCreate function using OBJ_TREND 
    it s simple with void  SetIndexStyle(
   int     index,     
   int     type,        
   int     style=EMPTY
   int     width=EMPTY
   color   clr=clrNONE  
   );

style DRAW_HISTOGRAM  

thank you Mr Doerk
 
jeef_1985: IMA50 in separate_window like MACD but with ObjectCreate function using OBJ_TREND
Why would you want to do that? Add another buffer to your indicator and populate it. Done.
 
example is that it is correct or it there's a more better way

Thank you

 

for(int i = 0; i <limit; i++)

     {

     

       string histogram = StringConcatenate("histogram",i);

 

      ObjectCreate(histogram,OBJ_TREND,Index,Time[i],iMA(NULL,0,50,0,MODE_EMA,PRICE_CLOSE,i));       

      ObjectSet(histogram,OBJPROP_COLOR,Green);

      ObjectSet(histogram,OBJPROP_WIDTH,2);

 

      WindowRedraw();      

   

      

     } 


Reason: