Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Char to string

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Char to string

    Hello!
    I have the following piece of code:

    HTML Code:
    private string[] myArray = new string[15];
    for(int i = 0; i < 7; i++)
    {
         myArray[i] = Char.ToString(i);
    }
    While compiling, I receive the error message that my method does not have a valid argument.
    What am I doing wrong?
    I would appreciate any help.
    Thanks!

    #2
    Hello Stanfillirenfro,

    Thanks for your post.

    There is not enough context here to see how exactly you are reproducing the error. I suggest placing the code in question in a very barebones indicator that just illustrates that part so you are having trouble with and produces the error.

    You can then copy the code into a text file and post it here as an attachment so others are more able to see the full context and give input.

    Some questions I have:

    Why are you using i with ToString(i)?

    What is Char?

    We look forward to hearing from you.

    Comment


      #3
      Many thanks Jim for your reply.
      I am trying to translate a MT4 code into a code suitable for Ninjatrader and in Mt4, there is a function: CharToStr(), A quick search in google gives me the following definition: "Conversion of the symbol code into a one-character string."
      I was expecting to have similar function in Ninjatrader, but I can not find any.
      Char should be a character ( I mean a string).

      Following up, I also have a function StrToInteger(), which I suppose is to cast a string to integer, but I can also not find similar function in Ninjatrader.
      Could these two functions have similarities (equivalents) in Ninjatrader? If not, is there a way to obtain results that would be given by these two functions?

      Comment


        #4
        Hello Stanfillirenfro,

        I would recommend getting more familiar with variable types used in MT4 and those used in C# (NinjaScript) CharToStr() and StrToInteger() sound like functions/methods that are needed to convert variables from one type to another. NinjaScript does not offer such methods and this would be something on the C# level.

        Char's are typically one character, when a string is multiple characters tied together in one object. I'm not an expert with MT4 so I am not sure if Char has a different meaning there.

        Publicly available information for converting a string to a numerical value in C# can be found below.

        Learn how to convert a string to a number in C# by calling the Parse, TryParse, or Convert class methods.


        Essentially, when we are performing any conversion, we will want to be fluent enough with both programming languages to understand what the main goal is. We would then want to adapt the code to use the target programming language's equivalent.

        You may find some more in depth resources for MT4 and their code from their end, but for educational resources on C#, you could consider some publicly available resources below. Other C# concepts can be looked up with the right key words using your favorite search engine too.

        Learn C# using GitHub Codespaces, and get started with your own development environment.






        Outside of understanding both programming languages, platform specific methods/functions would also need to be understood. Our Help Guide can be referenced to find documentation for platform specific code, where you can likely find equivalents for MT4 code, but this does not mean we document C# or provide C# programming education.

        Comment


          #5
          Many thanks again Jim for your reply and very valuable links and advices.
          Very helpfull. I am having a look on the links.
          Thanks again!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          571 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          331 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          549 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          549 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X