Questions from Beginners MQL5 MT5 MetaTrader 5 - page 525

 
-Aleks-:
Let string a="true" be used;

alternatively through a custom function

bool StrToBool(string text)
{
 if(text=="true")return(true);
 if(text=="false")return(false);
}

if you read the string from a file, you can

bool  FileReadBool( 
   int  file_handle      // handle файла 
   );
 
Sergey Gritsay:

alternatively through a custom function

if you read the string from a file, you can

Thanks, interesting solution!

I need to read from a file - I had a custom class made, I wanted to make a function for bool values, but I understand that FileReadBool will not work by analogy?

The class returns a value by column and cell number. Excerpt:

//+------------------------------------------------------------------+

//| GetDoubleValue                                                   |

//+------------------------------------------------------------------+

double CSVReader::GetDoubleValue(int row,int column)

  {

   if(CheckIndexes(row,column)==false) return(0.0);

//---

   int index=m_total_columns*row+column;

   if((index>=0) && (index<ArraySize(m_cells)))

     {

      return(StringToDouble(m_cells[index]));

     }

   return(0.0);

  }

//+------------------------------------------------------------------+

//+------------------------------------------------------------------+

//| GetBoolValue                                                   |

//+------------------------------------------------------------------+

double CSVReader::GetBoolValue(int row,int column)

  {

   if(CheckIndexes(row,column)==false) return(0.0);

//---

   int index=m_total_columns*row+column;

   if((index>=0) && (index<ArraySize(m_cells)))

     {

      return(FileReadBool(m_cells[index]));

     }

   return(0.0);

  }

//+------------------------------------------------------------------+

 

Forum on trading, automated trading systems and trading strategy testing

Bugs, bugs, questions

Nickolay72, 2016.02.29 13:56

Good afternoon gentlemen, maybe someone has faced such a problem, advise.I have written an advisor on my computer Win7x32 works without any problems, but I put it on another computer, Win8x64, and it will not work. Not only that all awkwardly installed, three times reinstall, until I was convinced that the MT4 is installed on the eighth, the advisor only through the database can be thrown in place from a flash drive, and it works refuses.

 

Forum on trading, automated trading systems and trading strategy testing

Bugs, bugs, questions

Vladislav Andruschenko, 2016.02.29 14:13

hit him on the head with a shovel.

But seriously, the psychic department is in the other thread


 
-Aleks-:

Thanks, interesting solution!

I need to read from a file - I had a class made to order, I wanted to make a function for bool values there, but I understand that FileReadBool will not work by analogy?

The class returns a value by column and cell number. Excerpt:

//+------------------------------------------------------------------+

//| GetDoubleValue                                                   |

//+------------------------------------------------------------------+

double CSVReader::GetDoubleValue(int row,int column)

  {

   if(CheckIndexes(row,column)==false) return(0.0);

//---

   int index=m_total_columns*row+column;

   if((index>=0) && (index<ArraySize(m_cells)))

     {

      return(StringToDouble(m_cells[index]));

     }

   return(0.0);

  }

//+------------------------------------------------------------------+

//+------------------------------------------------------------------+

//| GetBoolValue                                                   |

//+------------------------------------------------------------------+

double CSVReader::GetBoolValue(int row,int column)

  {

   if(CheckIndexes(row,column)==false) return(0.0);

//---

   int index=m_total_columns*row+column;

   if((index>=0) && (index<ArraySize(m_cells)))

     {

      return(FileReadBool(m_cells[index]));

     }

   return(0.0);

  }

//+------------------------------------------------------------------+

return(FileReadBool(m_cells[index]));
When you write it like this of course you will get a compile error as you need to pass the file handle into it.
 

Nickolay72, 2016.02.29 13:56

Добрый день господа.Может кто сталкивался с такой проблемой,подскажите.I wrote an EA, on my computer Win7x32 works without any problems. I put it on another computer, Win8x64, and it does not work. Not only is it a mess, I reinstalled it three times, until I was convinced that MT4 is installed on 8, EA only through the database can be put in place from the flash drive, but it does not work. Everything in the test, orders are put. In work smiling bastard, but refuses to work. How to make it work???

The flash drive needs to be formatted as NTFS.
 
Sergey Gritsay:
Of course, you will get a compilation error when you write it that way, because you have to pass the file handle into it.

It's not clear why they didn't make a standard string-to-value translation for bool.

I will write 0 and 1 in the file and make a check.

if ( StringToDouble(m_cells[index])==1 ) return (true);

else return (false);

Will it work?

 
-Aleks-:

It's not clear why they didn't make a standard string-to-value translation for bool.

I will write 0 and 1 in the file and make a check.

if ( StringToDouble(m_cells[index])==1 ) return (true);

else return (false);

will it work?

should, replace this line here

double CSVReader::GetBoolValue(int row,int column)

also change it to

bool CSVReader::GetBoolValue(int row,int column)
 
Sergey Gritsay:

should, this line here.

also replace this line with

Thank you! I'll give it a try.
 
Karputov Vladimir:

Nickolay72, 2016.02.29 13:56

Flash drive needs to be formatted as NTFS.
The flash drive is formatted, the terminal is configured for automatic trading, the EA is on - it does not trade.
Reason: