fxDreema

    • Register
    • Login
    • Search
    • Back to the main page
    • Categories
    • Recent
    • Tags
    • Popular
    • Search

    MQL4 Coding Question

    Questions & Answers
    2
    2
    704
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      Trader3487 last edited by

      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 */

      1 Reply Last reply Reply Quote 0
      • fxDreema
        fxDreema last edited by

        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 :)))

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post

        Online Users

        F
        A
        H
        A
        S

        12
        Online

        146.7k
        Users

        22.4k
        Topics

        122.6k
        Posts

        Powered by NodeBB Forums | Contributors