MQL4 Coding Question
-
I'm not a programmer but want to learn to write custom blocks. I am trying to write one that resets multiple counters by just copying/pasting the single counter reset code but it's not compiling. Any suggestions how to do this more concisely would be much appreciated:
//////////////////////
// Input parameters //
//////////////////////string ResetThisID="2"; // Reset counter with this ID
///////////////
// Main code //
///////////////string list[];
StringExplode(",", ResetThisID, list);
int size=ArraySize(list);for (int i=0; i<size; i++) {
list*=StringTrim(list*);
Counter(StrToInteger(list*),"reset");
}/* Orange output */
string ResetThisID="4"; // Reset counter with this ID
///////////////
// Main code //
///////////////string list[];
StringExplode(",", ResetThisID, list);
int size=ArraySize(list);for (int i=0; i<size; i++) {
list*=StringTrim(list*);
Counter(StrToInteger(list*),"reset");
}/* Orange output */
string ResetThisID="6"; // Reset counter with this ID
///////////////
// Main code //
///////////////string list[];
StringExplode(",", ResetThisID, list);
int size=ArraySize(list);for (int i=0; i<size; i++) {
list*=StringTrim(list*);
Counter(StrToInteger(list*),"reset");
}/* Orange output */
string ResetThisID="8"; // Reset counter with this ID
///////////////
// Main code //
///////////////string list[];
StringExplode(",", ResetThisID, list);
int size=ArraySize(list);for (int i=0; i<size; i++) {
list*=StringTrim(list*);
Counter(StrToInteger(list*),"reset");
}/* Orange output */
string ResetThisID="10"; // Reset counter with this ID
///////////////
// Main code //
///////////////string list[];
StringExplode(",", ResetThisID, list);
int size=ArraySize(list);for (int i=0; i<size; i++) {
list*=StringTrim(list*);
Counter(StrToInteger(list*),"reset");
}/* Orange output */
-
There are some things to be considered...
Input parameters should not be entered, they are automatically created depending on the input parameters you create on the right side. Use ~next~ where it should go to execute next blocks and ~inext~ if you want to have yellow output. Always use 1 ~next~ and 0 or 1 ~inext~, it's not that more than 1 can't be used, but it's better to be 1.
I can suggest to write something, save, and see what code is going out of the block. Notice that when you save it, it does not check for errors, I was always too lazy to implement this, but I'm using this Studio and it's enough for me and obviously there are no many other people using it, so... I imagine that I'm the only one that is using it :)))