Libraries: Сode that records balance and equity charts and calculates additional optimization criteria
save_Add( AvgPips, 2, "Custom 1", true);//value, digits, name, sort_min_to_max I've found a way to add unicode to custom criteria names. Use character codes. For example:
Новая страница
It looks like this in Russian:

I've found a way to add unicode to custom criteria names. Use character codes . For example:
Новая страница
It looks like this in Russian:
While this is feasible, I don't understand the difficulties in supporting UTF8. Could the codepage be set?
int StringToCharArray ( string text_string, uchar & array[], int start= 0 , int count=- 1 uint codepage= CP_ACP ); string CharArrayToString( uchar array[], int start=0, int count=-1 uint codepage=CP_ACP );
codepage=CP_ACP is the default value.
1 byte is stored in the Char array. I have proposed a working unicode solution. Each of the characters in я can be encoded in 1 byte.
You can use this online converter: https://r12a.github.io/app-conversion/
For your sample: 自定义1 = 自定义1
If you find another working solution, please share it.
- r12a.github.io
codepage=CP_ACP is the default value.
1 byte is stored in the array. I have proposed a working unicode solution. Each of the characters in & # 1103 can be encoded in 1 byte .
If you find another working solution, please share it.
void add( uchar &a[], string v){add(a, StringLen (v)); StringToCharArray (v, a, ArraySize (a), -1, CP_UTF8 );}Then can't we just read it in the panel by setting the last parameter of `CharArrayToString` to `CP_UTF8`?
#property script_show_inputs enum ENUM_OPERATION { OP_SAVE = 0 , // Save OP_LOAD = 1 // Load }; input ENUM_OPERATION InpOperation = OP_SAVE; //+------------------------------------------------------------------+ bool SaveStringToFile( string fileName, string text) { int handle = FileOpen (fileName, FILE_WRITE | FILE_BIN ); if (handle == INVALID_HANDLE ) return false ; uchar data[]; int size = StringToCharArray (text, data, 0 , - 1 , CP_UTF8 ); Print ( "text length: " , StringLen (text)); Print ( "data size: " , ArraySize (data)); if (size > 0 ) { FileWriteArray (handle, data, 0 , size); FileClose (handle); Print ( "Save OK" ); return true ; } FileClose (handle); return false ; } //+------------------------------------------------------------------+ bool LoadStringFromFile( string fileName, string &text) { int handle = FileOpen (fileName, FILE_READ | FILE_BIN ); if (handle == INVALID_HANDLE ) return false ; uint fileSize = ( uint ) FileSize (handle); if (fileSize == 0 ) { FileClose (handle); return false ; } uchar data[]; ArrayResize (data, fileSize); FileReadArray (handle, data, 0 , fileSize); FileClose (handle); text = CharArrayToString (data, 0 , WHOLE_ARRAY , CP_UTF8 ); Print ( "read: " ,text); return true ; } //+------------------------------------------------------------------+ void OnStart () { string fileName = "test.bin" ; string testText = "Test Chinese text: 这是测试中文字符串" ; if (InpOperation == OP_SAVE) { SaveStringToFile(fileName, testText); } else { string loadedText = "" ; LoadStringFromFile(fileName, loadedText); } } //+------------------------------------------------------------------+My tests did not find any issues. You might need to pay attention to the length of the saved string; it should be "ArraySize" after being converted to an array, not "StringLen".
void add( uchar &a[], string v){add(a, StringLen (v) ); StringToCharArray (v, a, ArraySize (a), - 1 , CP_UTF8 );}
This should not be StringLen.
void add(uchar &a[], string v) { uchar temp[]; int byteCount = StringToCharArray(v, temp, 0, -1, CP_UTF8); add(a, byteCount); if(byteCount > 0) { int currentSize = ArraySize(a); ArrayResize(a, currentSize + byteCount); ArrayCopy(a, temp, currentSize, 0, byteCount); } }
This is a great solution.
I have added UTF support for UTF characters in Custom Criteria names to this library and to the report.

Note: UTF files are twice as large as ASCII files. For large reports > 50,000 passes, it is preferable to use only Latin characters or/and solution from this post https://www.mql5.com/en/forum/504277#comment_59090091.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Сode that records balance and equity charts and calculates additional optimization criteria:
If you have access to the Expert Advisor code, you can save balance and equity charts and calculate additional optimization criteria by adding additional code from this library.
Author: Aleksei Kuznetsov