Download MetaTrader 5

Compiled file size and way of working

To add comments, please log in or register
Thanasis Filippidis
Thanasis Filippidis  

I am creating a custom indicator and I am facing a dilemma on the approach I am currently using.

The indicator creates approximately 300-400 labels (prices & calculation results), most of which are live updated, like a hud.

My initial approach was to create each label like that:

obname=Name+" "+"usdc7";
ObjectSet(obname, OBJPROP_XDISTANCE, x+3*xs);
ObjectSet(obname, OBJPROP_YDISTANCE, y+yb+6*ys);
ObjectSetText(obname, "T: " + DoubleToStr(usdt,0), FontSize-1, Font, FontC);

However the indicator source file reached critical size (~ 750kb, 20k lines) and was giving me issues in scite with scrolling and finding things.

I then switched to making a custom function to pass my labels:

void LabelMake(const string name,
               const int corner,
               const int x,
               const int y,
               const string label,
               const int FSize,
               const color FCol)
         Print("error: can't create label_object! code #",GetLastError());   

like that:

obname=Name+" "+"usdc7";
LabelMake(obname,0,x+3*xs,y+yb+6*ys,"T: " + DoubleToStr(usdt,0),FontSize-1,FontC);

Now the resulting source file is ~450kb and 7k lines smaller.

However the odd thing I noticed is that while the compiled file in the first version was approximately 750kb, the new compiled file when using the custom function is ~1.9mb. Tried both by having the custom function in the source itself or as an mqh.

I am wondering whether there are any implications in using the second method, such as slower response times, higher ram usage (didn't see any notable difference) or in cpu usage (cpu seems to have decreased from 8-9% to 3% but this might be due to the time of the day and low volatility).

Can anyone confirm that there shouldn't be really any difference despite the file size in speed/ram/cpu?


To add comments, please log in or register