//+------------------------------------------------------------------+ //| Utils.mqh | //| Copyright 2021, MetaQuotes Ltd. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2021, MetaQuotes Ltd." #property link "https://www.mql5.com" #property version "1.00" class Utils { private: static string GetRelativeProgramPathWithFileName() { int pos2; //--- obtenemos la ruta absoluta hacia la aplicación string path=MQLInfoString(MQL_PROGRAM_PATH); //--- buscamos la posición de la subcadena "\MQL5\" int pos =StringFind(path,"\\MQL5\\"); //--- subcadena no encontrada - error if(pos<0) return(NULL); //--- saltamos la carpeta "\MQL5" pos+=5; //--- saltamos los símbolos '\' que sobran while(StringGetCharacter(path,pos+1)=='\\') pos++; //--- si es un recurso, devolvemos la ruta respecto al directorio MQL5 if(StringFind(path,"::",pos)>=0) return(StringSubstr(path,pos)); //--- buscamos el divisor para el primer subdirectorio en MQL5 (por ejemplo, MQL5\Indicators) //--- si no hay, devolvemos la ruta respecto al directorio MQL5 if((pos2=StringFind(path,"\\",pos+1))<0) return(StringSubstr(path,pos)); //--- devolvemos la ruta respecto al subdirectorio (por ejemplo, MQL5\Indicators) return (StringSubstr(path,pos2+1)); } public: Utils(); ~Utils(); static string GetRelativeProgramPath() { string path = GetRelativeProgramPathWithFileName(); //path = StringSubstr(path,0,StringLen(path) - 1); int length = StringLen(path); int lastPositionI = length - 1; for(int i=0; i