Need advice on how to do this more "neatly".

 

Greetings experts,

I'm a noob on MQL.  So far, had created more than 3 dozen EAs (very simple ones mind you).  My problem is I need to uniformly display information on each chart/each EA goes on like the one below.  Every time I need to add more info to be displayed I need to go to each EA and change it.  

Is there a way that I can put CreateInfo into a file somewhere and just reference it from each of my EA?

Thank you in advance and apologies for the noob question.

  void CreateInfo()

  {

   int Y=30;

   int YSpace=12;

   int fontsize=8;


   ObjectCreate("EA",OBJ_LABEL,0,0,0);

   ObjectSetText("EA","Forex Gump USDJPY H15 v1.50",fontsize,"Verdana",Yellow);

   ObjectSet("EA",OBJPROP_CORNER,0);

   ObjectSet("EA",OBJPROP_XDISTANCE,20);

   ObjectSet("EA",OBJPROP_YDISTANCE,Y);

   Y=Y+YSpace;

   ObjectCreate("Leverage",OBJ_LABEL,0,0,0);

   ObjectSetText("Leverage","Leverage : "+IntegerToString(ActLev),fontsize,"Verdana",Lime);

   ObjectSet("Leverage",OBJPROP_CORNER,0);

   ObjectSet("Leverage",OBJPROP_XDISTANCE,20);

   ObjectSet("Leverage",OBJPROP_YDISTANCE,Y);

   Y=Y+YSpace;

   ObjectCreate("ATR",OBJ_LABEL,0,0,0);

   ObjectSetText("ATR","ATR : "+ DoubleToString(ATR) ,fontsize,"Verdana",Lime);

   ObjectSet("ATR",OBJPROP_CORNER,0);

   ObjectSet("ATR",OBJPROP_XDISTANCE,20);

   ObjectSet("ATR",OBJPROP_YDISTANCE,Y);


   ...

   }

void OnTick()

  {

   CreateInfo();

  }

 
#include <MyFolder/CreateInfo.mqh>

void OnTick()
  {
   CreateInfo();
   ...
  }

where MyFolder is located in the Include dir and CreateInfo.mqh contains your function from above or maybe a class definition with your function.

https://www.mql5.com/en/docs/basis/preprosessor/include

Documentation on MQL5: Language Basics / Preprocessor / Including Files (#include)
Documentation on MQL5: Language Basics / Preprocessor / Including Files (#include)
  • www.mql5.com
with the content of the file WinUser32.mqh. Angle brackets indicate that the WinUser32.mqh file will be taken from the standard directory (usually it is If the file name is enclosed in...
 
lippmaje:

where MyFolder is located in the Include dir and CreateInfo.mqh contains your function from above or maybe a class definition with your function.

https://www.mql5.com/en/docs/basis/preprosessor/include

You sir are AWESOME!  You just saved me!  Thank you and stay safe.
Reason: