Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

adding comma between numbers from barIndex

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

    adding comma between numbers from barIndex

    Hello,

    Is it possible to add commas between numbers from method of a for loop.

    Code:
    for(int barIndex = foundIndex; barIndex <= ChartBars.ToIndex; barIndex++)
    {
    closePrice = Bars.GetClose(barIndex);
    }
    I want all closePrice to appear seperated by commas in output window. Any pointers?

    Thank you

    #2
    Hello frankduc, thanks for your question.

    You would need to keep a List<String> and add the closePrice and comma to that string.

    e.g.
    Code:
    int x = 1;
    
    List<string> mylist = new List<string>();
    
    string tempString = x.ToString();
    
    tempString += ",";
    
    mylist.Add(tempString);
    Please let me know if I can assist any further.

    Comment


      #3
      Chris,

      Code:
       int po = 1;
      
      List<string> mylist = new List<string>() {closePricel};
      
      string tempString = po.ToString();
      
      tempString += ",";
      
      mylist.Add(tempString);
      
      Print("mylist" +mylist);
      It return impossible to convert double to string.

      But my goal is to apply a lambda to closePrice.

      Code:
      double CW = mylist.Aggregate((x, y) => Math.Abs(x - 2800) < Math.Abs(y - 2800) ? x : y);
      It will find the closest price from 2800.

      Code:
      List<double> mylist = new List<double>() {closePrice};
      The problem if i list a variable i thought it would search in all the price in the list. But instead it returns the last double value in the list.
      Will add commas to the list will solve the problem?

      Thank you

      Comment


        #4
        Hi frankduc, thanks for your reply.

        Unfortunately, I can not provide support for common C# or LINQ commands. I rarely use them, and better information can be found on the internet elsewhere on these subjects.

        Comment

        Latest Posts

        Collapse

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