Watch how to download trading robots for free

Interesting script?
So post a link to it -
let others appraise it

You liked the script? Try it in the MetaTrader 5 terminal

Libraries

Alphabet structure - library for MetaTrader 5

DMITRII PECHERITSA

Views:
470
Rating:
votes: 6
Published:
2020.06.03 08:54
Updated:
2020.06.05 09:49

This structure provides quick access to sets of lowercase and uppercase latin, russian characters, digits, punctuation, brackets, whitespaces, and special sets of symbols after/before which space should be dropped.

I find this useful in applications where i need to manipulate text data.

The Alphabet also contains methods to classify a character/text.

   Alphabet abc;
   /*REPORT*/
   Print("RUSSIAN");
   ArrayPrint(abc.rus.cap.codes);
   ArrayPrint(abc.rus.cap.syms);
   ArrayPrint(abc.rus.low.codes);
   ArrayPrint(abc.rus.low.syms);
   Print("LATIN");
   ArrayPrint(abc.lat.cap.codes);
   ArrayPrint(abc.lat.cap.syms);
   ArrayPrint(abc.lat.low.codes);
   ArrayPrint(abc.lat.low.syms);
   Print("DIGITS");
   ArrayPrint(abc.digit.codes);
   ArrayPrint(abc.digit.syms);
   Print("PUNCTUATION");
   ArrayPrint(abc.punct.codes);
   ArrayPrint(abc.punct.syms);
   Print("NO SPACE BEFORE");
   ArrayPrint(abc.nospacebefore.codes);
   ArrayPrint(abc.nospacebefore.syms);
   Print("NO SPACE AFTER");
   ArrayPrint(abc.nospaceafter.codes);
   ArrayPrint(abc.nospaceafter.syms);
   Print("WRAP");
   ArrayPrint(abc.wrapmarker.codes);
   ArrayPrint(abc.wrapmarker.syms);
   Print("WHITESPACE");
   ArrayPrint(abc.whitesp.codes);
   ArrayPrint(abc.whitesp.syms);
   Print("BRACKETS");
   ArrayPrint(abc.bracket.codes);
   ArrayPrint(abc.bracket.syms);
   Print("CHECK");
   ENUM_ALPHABET_CAT category;
   /**/
   string stringchars[]= {"\\","(","7","$","abc"};
   int sizestringchars=ArraySize(stringchars);
   for(int i=0; i<sizestringchars; i++)
     {
      string stringchar=stringchars[i];
      category=abc.Check(stringchar);
      Print(stringchar," is ",EnumToString(category));
     }
   /**/
   short codes[]= {' ',',','\n',0};
   int sizecodes=ArraySize(codes);
   for(int i=0; i<sizecodes; i++)
     {
      short code=codes[i];
      category=abc.Check(code);
      Print(code," is ",EnumToString(category));
     }
   /**/
   ENUM_ALPHABET_CAT categories[];
   string text="Some text.";
   int qty=abc.Check(text,categories);
   PrintFormat("'%s' is made of %d classes of symbols:",text,qty);
   int size=ArraySize(categories);
   for(int i=0; i<size; i++)
     {Print(EnumToString(categories[i]));}
  }


Output:

RUSSIAN
[ 0] 1040 1041 1042 1043 1044 1045 1025 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055
[17] 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071
"А" "Б" "В" "Г" "Д" "Е" "Ё" "Ж" "З" "И" "Й" "К" "Л" "М" "Н" "О" "П" "Р" "С" "Т" "У" "Ф" "Х" "Ц" "Ч" "Ш" "Щ" "Ъ" "Ы" "Ь" "Э" "Ю" "Я"
[ 0] 1072 1073 1074 1075 1076 1077 1105 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087
[17] 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103
"а" "б" "в" "г" "д" "е" "ё" "ж" "з" "и" "й" "к" "л" "м" "н" "о" "п" "р" "с" "т" "у" "ф" "х" "ц" "ч" "ш" "щ" "ъ" "ы" "ь" "э" "ю" "я"
LATIN
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
"A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R" "S" "T" "U" "V" "W" "X" "Y" "Z"
 97  98  99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
"a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z"
DIGITS
48 49 50 51 52 53 54 55 56 57
"0" "1" "2" "3" "4" "5" "6" "7" "8" "9"
PUNCTUATION
  46   44   59   58   33   63   43   61   42   96  126   39   34   92   47   45 8212 8211
"." "," ";" ":" "!" "?" "+" "=" "*" "`" "~" "'" """ "\" "/" "-" "—" "–"
NO SPACE BEFORE
  46   44   58   59   63   33   41   93   62  125   45 8212 8211
"." "," ":" ";" "?" "!" ")" "]" ">" "}" "-" "—" "–"
NO SPACE AFTER
  40   91   60  123   45 8212 8211
"(" "[" "<" "{" "-" "—" "–"
WRAP
44 93 63 33 32
"," "]" "?" "!" " "
WHITESPACE
32  9 13
" " " " " "
BRACKETS
 40  41  91  93 123 125  60  62
"(" ")" "[" "]" "{" "}" "<" ">"
CHECK
\ is CHAR_PUNCT
( is CHAR_BRACKET
7 is CHAR_DIGIT
$ is CHAR_UNDEF
abc is ENUM_ALPHABET_CAT::-1
32 is CHAR_WHITESP
44 is CHAR_PUNCT
10 is CHAR_BREAK
0 is CHAR_NULL
'Some text.' is made of 4 classes of symbols:
CHAR_LAT_CAP
CHAR_LAT_LOW
CHAR_WHITESP
CHAR_PUNCT


    EMA on RSI EMA on RSI

    Calculates a Exponential Moving Average based on RSI Data, instead of the regular Pricing data. Simple and and to the point.

    Binary Flags Binary Flags

    How to minimize bool parameters in a function signature?

    Correlation angle Correlation angle

    Correlation angle

    Correlation phasor Correlation phasor

    Correlation phasor