Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 111

 
trader781:
I don't understand how, I corrected the names, the line is still red regardless of the order type, just called differently. (then I have to find a way to cut it to 10 bars), I need exactly the way
Try it now
Files:
 
Sergey Gritsay:
try it now.

It's a good thing there's a sourcebook hanging around)

When you press the compile button the bot dies along with the terminal, and after opening EX it doesn't open and this file is empty.

It looks like this.

Also looked, if you put blue, green, gold, white, these colours change, but darkgray and azure does not put, it turns out white.

Files:
 
trader781:

It's a good thing there's a sourcebook hanging around)

When you press the compile button the bot dies along with the terminal, and after opening EX it doesn't open and this file is empty.

It looks like this.

Also looked, if I put blue, green, gold, white, these colours change, but darkgray and azure does not put, it turns out white.

I'm compiling fine.
 
Sergey Gritsay:
string  StringSubstr(
   string  string_value,     // строка
   int     start_pos,        // с какой позиции начать
   int     length=0          // длина извлекаемой строки
   );
...

Thank you!

I also need help - I need to find out how many characters are in a string - how do I do that?

 
Good afternoon.
I use StringSplit to split a string read from a file. But the array output loses strings, all except first string. On output all except first string are empty, though array size is correct.

Also, I've encountered incomprehensible behavior with arrays of strings. I have to make two-dimensional arrays to save strings into an array.

Has anyone encountered this behavior?

while( idx < size ) {
    if( StringFind( fileBuffer[idx][0], "[Main]" ) >= 0 ) {
        idx++;
        Print( "Buffer(main) = " + fileBuffer[idx][0] ); // debug
        if( StringFind( fileBuffer[idx][0], "Kit_Names=" ) >= 0 ) {
            Print( "check1 - " + fileBuffer[idx][0] ); // debug
            string tmp = StringSubstr( fileBuffer[idx][0], 10 );
            Print( tmp );                              // debug
            StringReplace( tmp, "\"", "" );
            Print( tmp );                              // debug
            Print( StringSplit( tmp, sep, list ) );
            Print( "check22 - " + tmp );               // debug
            for(int i = 0; i < ArrayRange(list,0); i++) Print(list[i][0]);  // debug
        }
    }
    idx++;
}
 
-Aleks-:

Thank you!

Also need help - need to find out how many characters are in a string - how do I do that?

Returns the number of characters in the string.

int  StringLen(
   string  string_value      // строка
   );

 
terentjew23:

Returns the number of characters in a string.

int  StringLen(
   string  string_value      // строка
   );

Thank you!

 
A word of advice, please.

I declare an array at global EA level. Then in special function init() I call user function that fills the array with string constants.

Then in special function start(), I use the array only to read data.

Some time later, other data will fill the array. I.e., when I run the EA, I expect the array to remain unchanged while the EA is working, but the data somehow gets into the array, and only after some time (more than 10 minutes). When I restart the Expert Advisor, the array will be filled as it should be, but some time later, for reasons I don't understand, the array will again contain wrong values.

The only way out is to constantly reload the array in the start(), but I don't really like it, because the array should actually be filled only during the initialization.

What could be the problem? How to protect the array from modifications?
 
Maksym Mudrakov:
Can you give me a hint, please?
...
What could it be? How to keep an array from being modified?
Check the code thoroughly.
 
Maksym Mudrakov:
A word of advice, please.

I declare an array at global EA level. Then in special function init() I call user function that fills the array with string constants.

Then in special function start(), I use the array only to read data.

Some time later, other data will fill the array. I.e., when I run the EA, I expect the array to remain unchanged while the EA is working, but the data somehow gets into the array, and only after some time (more than 10 minutes). When I restart the Expert Advisor, the array will be filled as it should be, but some time later, for reasons I don't understand, the array will again contain the wrong values.

The only way out is to constantly reload the array in the start(), but I don't really like it, because the array should actually be filled only during the initialization.

What could be the problem? How to protect the array from modifications?
Can I see the code?