I wrote the decoding of magic, and the compilation swears. What doesn’t she like?
void decode_ExpertMagic(ulong mag)
{
string strmag = IntegerToString(mag);
if(StringLen(strmag) != 18) Print("MAGIC is selected manually.");
else
{
string str_name, str_period, str_symbol, str_symb, string_symbol = "";
int num_name, num_period, num_symbol;
for(int i = 1, k = 0; i <= 6; i++)
{
str_symb = StringSubstr(strmag,k,2);
k += 2;
num_symbol = StringToInteger(str_symb); // swearing, possible loss of data due to type conversion
string_symbol += numCharDecode(num_symbol);
}
num_period = StringToInteger(StringSubstr(strmag,12,3)); / / swears possible loss of data due to type conversion
str_period = numPeriodDecode(num_period);
num_name = StringToInteger(StringSubstr(strmag,15,3)); / / swears possible loss of data due to type conversion
str_name = numExpertNameDecode(num_name);
Print("The Expert Advisor "+ str_name+"is launched on the symbol"+str_symbol+", the chart period "+str_period);
}
}
//+------------------------------------------------------------------+
string numExpertNameDecode(int num)
{
if(num == 703) return("MAS_2.13");
else
.....
}
//+------------------------------------------------------------------+
string numPeriodDecode(int tmf)
{
if(tmf == 115) return("M15");
else
.....
}
//+------------------------------------------------------------------+
string numCharDecode(int chr)
{
if(chr == 11) return("A");
else
if(chr == 12) return("B");
else
.....
}
Nevertheless it works out almost correctly:
The MAS_2.13 Expert Advisor is launched on the symbol 171226312914, the chart period is H3
qstr
Somewhere it was that integers are simplistically represented and require an explicit type conversion or an initially correct one.
long DIGIT_pair1=0;
I didn’t find any other ways, either an explicit cast or an initially correct integer type.
sgarnov
Help to correct possible loss of data due to type conversion:
string LowerCase(string value)
{
int i, n;
string st;
st = value;
for (i = 0; i < StringLen(st); i++)
{
n = StringGetChar(st, i);
if (n >= 65 && n <= 90) st = StringSetChar(st, i, n + 32); / / here is possible loss of data due to type conversion exactly where underlined
}
return(st);
}
string UpperCase(string value)
{
int i, n;
string st;
st = value;
for (i = 0; i < StringLen(st); i++)
{
n = StringGetChar(st, i);
if (n >= 97 && n <= 122) st = StringSetChar(st, i, n-32); / / here is possible loss of data due to type conversion exactly where underlined
}
return(st);
}
trendhunter
I have like with types of all OK, but swears:
input string PAIR1 = "EURUSD";//The first pair
int DIGIT_pair1=0;
int OnInit()
{
DIGIT_pair1 = SymbolInfoInteger(PAIR1,SYMBOL_DIGITS);// here is possible loss of data due to type conversion
return(INIT_SUCCEEDED);
}
But this is normal:
DIGIT_pair1= (int) SymbolInfoInteger(PAIR1,SYMBOL_DIGITS);
And all from the fact that SymbolInfoInteger
– this is long. But I do
not need long, because then I use
tp = NormalizeDouble(tp,DIGIT_pair1);
where DIGIT_pair1 should be int. In short, I don’t know what to say. So everything is twisted))
laryx
All right, I don’t like it.
Look:
num_symbol = StringToInteger(str_symb); // swearing, possible loss of data due to type conversion
You convert the string to long, and then equate it to int – it is clear that losses are possible. I’d swear, too…
avos
I found an error. It works.
2018.10.22 18:25:11.630 Core 1 2018.04.22 00:00:00 The MAS_2.13 Expert Advisor is launched on the GBPUSD symbol, the chart period is H1
But the warnings remained. What doesn’t he like?