LIP/Arch/RU/Test_02.mq5
super.admin 291e846eab convert
2025-05-30 15:03:51 +02:00

179 lines
9.1 KiB
MQL5

//1. Инструмент
//2. Тикет
//3. Магик
//4. Операция
void OnInit(){
//-----
datetime TimeSet=0;
double DateSet=0.0;
{if(GlobalSetDouble("tst_01",TimeSet,999.999))
{
Print("TimeSet1=",TimeSet);
{if(GlobalGetDouble("tst_01",DateSet))
{
Print("DateSet1=",DateSet);
}}//if(GlobalGetDouble("tst_01",DateSet))
}}//if(GlobalSetDouble("tst_01",999.999,TimeSet))
//-----
string StringSet="";
{if(GlobalSetString("tst_02",TimeSet,"EURUSD.z"))
{
Print("TimeSet2=",TimeSet);
{if(GlobalGetString("tst_02",StringSet))
{
Print("StringSet2=",StringSet);
}}//if(GlobalGetString("tst_02",StringSet))
}}//if(GlobalSetString("tst_02",TimeSet,"EURUSD.z"))
//-----
ulong UlongSet=0;
{if(GlobalSetUlong("tst_03",TimeSet,56456198741))
{
Print("TimeSet3=",TimeSet);
{if(GlobalGetUlong("tst_03",UlongSet))
{
Print("UlongSet3=",UlongSet);
}}//if(GlobalGetUlong("tst_03",UlongSet))
}}//if(GlobalSetString("tst_03",TimeSet,56456198741))
}//OnInit()
bool GlobalSetDouble(string iName,datetime &iTimeSet,double iDateSet=0.0){
//-----
iTimeSet=GlobalVariableSet(iName,iDateSet);
{if(iTimeSet!=0)//Значение удалось установить
{
return(true);
}else{//Не удалось установить
return(false);
}}//if(iTimeSet!=0)
//-----
return(false);
}//GlobalSetDouble()
bool GlobalGetDouble(string iName,double &iDateGet){
//-----
iDateGet=0.0;
{if(GlobalVariableCheck(iName))//Переменная есть
{
{if(GlobalVariableGet(iName,iDateGet))//Значение удалось считать
{
return(true);
}else{//Не удалось считать
iDateGet=0.0;
return(false);
}}//if(GlobalVariableGet(iName,iDateGet))
}else{//Переменной нет
iDateGet=0.0;
return(false);
}}//if(GlobalVariableCheck(iName))
//-----
return(false);
}//GlobalGetDouble()
//
bool GlobalSetString(string iName,datetime &iTimeSet,string iStringSet=""){
//-----
union ulong_double
{
double iDateSet;
ulong iLongSet;
uchar iCharSet[8];
};
ulong_double ud;
ud.iLongSet=0;
//-----
StringToCharArray(iStringSet,ud.iCharSet,0,8);
//-----
iTimeSet=GlobalVariableSet(iName,ud.iDateSet);
{if(iTimeSet!=0)//Значение удалось установить
{
return(true);
}else{//Не удалось установить
return(false);
}}//if(iTimeSet!=0)
//-----
return(false);
}//GlobalSetString()
bool GlobalGetString(string iName,string &iStringGet){
//-----
iStringGet="";
//-----
union ulong_double
{
double iDateGet;
ulong iLongGet;
uchar iCharGet[8];
};
ulong_double ud;
ud.iLongGet=0;
//-----
{if(GlobalVariableCheck(iName))//Переменная есть
{
{if(GlobalVariableGet(iName,ud.iDateGet))//Значение удалось считать
{
iStringGet=CharArrayToString(ud.iCharGet,0,8);
return(true);
}else{//Не удалось считать
iStringGet="";
return(false);
}}//if(GlobalVariableGet(iName,ud.iDateGet))
}else{//Переменной нет
iStringGet="";
return(false);
}}//if(GlobalVariableCheck(iName))
//-----
iStringGet="";
return(false);
}//GlobalGetString()
//
bool GlobalSetUlong(string iName,datetime &iTimeSet,ulong iUlongSet=0){
//-----
union ulong_double
{
double iDateSet;
ulong iLongSet;
};
ulong_double ud;
ud.iLongSet=iUlongSet;
//-----
iTimeSet=GlobalVariableSet(iName,ud.iDateSet);
{if(iTimeSet!=0)//Значение удалось установить
{
return(true);
}else{//Не удалось установить
return(false);
}}//if(GlobalVariableGet(iName,iDate))
//-----
return(false);
}//GlobalSetDouble()
bool GlobalGetUlong(string iName,ulong &iUlongGet){
//-----
iUlongGet=0;
//-----
union ulong_double
{
double iDateGet;
ulong iLongGet;
};
ulong_double ud;
ud.iLongGet=0;
//-----
{if(GlobalVariableCheck(iName))//Переменная есть
{
{if(GlobalVariableGet(iName,ud.iDateGet))//Значение удалось считать
{
iUlongGet=ud.iLongGet;
return(true);
}else{//Не удалось считать
iUlongGet=0;
return(false);
}}//if(GlobalVariableGet(iName,iDate))
}else{//Переменной нет
iUlongGet=0;
return(false);
}}//if(GlobalVariableCheck(iName))
//-----
iUlongGet=0;
return(false);
}//GlobalGetDouble()