Sign Up

Have an account? Sign In Now

Sign In

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here
Sign InSign Up

First independent community of traders

First independent community of traders Logo First independent community of traders Logo

First independent community of traders Navigation

  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • Buy Theme
  • Home
  • About Us
  • Blog
  • Contact Us
Home/ Questions/Q 6204
Next
In Process
avos
avos

avos

  • 2 Questions
  • 15 Answers
  • 0 Best Answers
  • 44 Points
View Profile
  • 0
avos
Asked: January 26, 20212021-01-26T04:22:28+00:00 2021-01-26T04:22:28+00:00In: Forex Expert Advisors

What’s wrong? possible loss of data due to type conversion

  • 0

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

  • 5 5 Answers
  • 0 Followers
  • 0
Answer
Share
  • Facebook

    5 Answers

    • Voted
    • Oldest
    • Recent
    1. qstr

      qstr

      • 0 Questions
      • 2 Answers
      • 0 Best Answers
      • 24 Points
      View Profile
      qstr
      2021-01-26T04:23:02+00:00Added an answer on January 26, 2021 at 4:23 am

      Evgeniy Zhdan:

      I have like with types of all OK, but swears:

      But this is normal:

      And all from the fact that SymbolInfoInteger is long. But I do not need long, because then I use 

      where DIGIT_pair1 should be int. In short, I don’t know what to say. So everything is twisted))

      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.

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    2. sgarnov

      sgarnov

      • 0 Questions
      • 1 Answer
      • 0 Best Answers
      • 22 Points
      View Profile
      sgarnov
      2021-01-26T04:22:55+00:00Added an answer on January 26, 2021 at 4:22 am

      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);

      }

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    3. trendhunter

      trendhunter

      • 0 Questions
      • 23 Answers
      • 0 Best Answers
      • 66 Points
      View Profile
      trendhunter
      2021-01-26T04:22:48+00:00Added an answer on January 26, 2021 at 4:22 am

      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))

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    4. laryx

      laryx

      • 0 Questions
      • 46 Answers
      • 0 Best Answers
      • 112 Points
      View Profile
      laryx
      2021-01-26T04:22:39+00:00Added an answer on January 26, 2021 at 4:22 am

      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…

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    5. avos

      avos

      • 2 Questions
      • 15 Answers
      • 0 Best Answers
      • 44 Points
      View Profile
      avos
      2021-01-26T04:22:33+00:00Added an answer on January 26, 2021 at 4:22 am

      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?

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    Leave an answer

    Leave an answer
    Cancel reply

    Browse

    Sidebar

    Ask A Question

    Stats

    • Questions 530
    • Answers 2k
    • Posts 5
    • Comments 0
    • Best Answers 0
    • Users 749
    • Popular
    • Comments
    • Tags
    • forexcommunity

      Highlighting what’s important about questions & Answers on Discy Community!

      • 0 Comments
    • forexcommunity

      Introducing Keyboard Shortcuts, our first Labs feature

      • 0 Comments
    • forexcommunity

      Defining quality on Discy Engine — what a helpful answer ...

      • 0 Comments
    • forexcommunity

      Organizational and company accounts on Discy Engine the next step

      • 0 Comments
    • forexcommunity

      Hello world!

      • 0 Comments

    Related Questions

    • BrantHaps

      write my essay ndl

      • 0 Answers
    • Galengask

      write my paper qxg

      • 0 Answers
    • Johnbup

      Слоты в онлайн казино. Игровые автоматы бесплатно

      • 0 Answers
    • StephenWaibe

      Торгуйте акциями основных технологических компаний США

      • 0 Answers
    • Doublebtc-Ceact

      DoubleBTC.WIN - Double your bitcoin in 24 hours

      • 0 Answers

    Users

    Roberdraf

    Roberdraf

    • 0 Questions
    • 0 Answers
    LouisJah

    LouisJah

    • 0 Questions
    • 0 Answers
    JoshuaCrymn

    JoshuaCrymn

    • 0 Questions
    • 0 Answers

    Footer

    First independent community of traders

    About

    An independent community of forex traders. This is where traders communicate. You can ask your questions and you will receive an answer to your question.
    • Terms of Use
    • Privacy Policy
    • Cookie Policy
    • Knowledge Base
    • Support

    © 2021 Forexcommunity.net. All Rights Reserved